Advanced
Node.js · Proficient - advanced patterns and performance
- Architecting an API: routes, controllers, servicesStructure your API into single-responsibility layers and wire them together with lightweight injection to make it testable.
- Persistence with SQLite: the data access layerUse better-sqlite3 with prepared statements, transactions, and a dedicated repository for fast, safe persistence.
- Input validation and error middlewareValidate data at the edge of the API and centralize all error handling in a single four-parameter middleware.
- Authentication: hashing, sessions vs JWTHash passwords with a costly function, choose between sessions and JWT with full awareness, and protect your routes with middleware.
- Testing your API: node:test, fetch, and a test databaseTest your routes end to end with node:test and fetch on an ephemeral port, each test getting its own in-memory SQLite database.