A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label node. Show all posts
Showing posts with label node. Show all posts

New software cheat sheet

 

## Languages

- Perl: best for fast prototyping
- Ruby: best for having fun
- Node: best for public projects
- Python: best for experiments

## Frameworks

### Perl

- DBIx::Class 💯
- Mojolicious 💯

### Node

- Express (popular)
- React?
- Koa?
- NestJS?
-....? for testing: Qunit?
-....? for web framework

### Python

- Django? (this one)
- Flask?

### Ruby

- Rails?
- Active Record?

## Libraries

### Perl

- just everything

### Node

- minimist reads command line arguments
- cheerio parses HTML
- daysjs manages dates/times
  - customParseFormat plugin parses dates
- knex does CRUD on databases
- fs perfoms operations on the file system
- import process from 'node:process'; // process.exit(1);

Javascript web frameworks, 2022

 A list:

  • React - library, jsx, facebook
  • Vue - easier than backbone, good cli
  • Angular - typescript, heavy, google
  • Ember - opinionated, fast development <-- this one is good
  • Backbone - stable, reliable, data rendering, easy, lightweight
  • Aurelia - convention over configuration, standards, very easy
  • Lit - very fast, lightweight, google
  • Mithril - lean, fast, simple

Node CRUD basics

Javascript philosophy and execution flow is quite different to Perl:

  • With Perl it's strongly discouraged to wrap an operation in a `try { ... }` block without a `catch { ... }` block following it, because any errors would be hidden and the operation might silently fail.
  • With Javascript and Promises, many operations are automatically wrapped in a `try { ... }` block, and are not even executed if they don't have a `.then()` or a `.catch()` added, so they silently fail!
Knex basics

Basic Node package recommendations

Recommendations for your javascript application:

  • Web framework: express
  • DB abstraction: knex, sequelize, db-migrate
  • DB Migration: knex, db-migrate
  • HTTP client (for external API requests): axios (older apps use superagent, axios has better features)
  • Templating: handlebars
  • Testing: mocha, sinon (mocking), chai (assertions), karma, jasmine, qunit, jest, cypress, storybook, ava
  • Integration testing: puppeteer, playwright, webdriverIO
  • Code Coverage: Istanbul
  • Process management (in production): pm2
  • Linting and code standards: eslint prettier
  • Inline documentation: JSDoc
  • Typescript: https://www.typescriptlang.org/docs/handbook/interfaces.html