Track
Express
Review app factories, routers, middleware order, validation, auth, and error handling.
- 01
App factory vs server startup
Create the Express app separately from the process that starts listening.
startuparchitecturetesting - 02
Router boundaries
Group related routes behind routers with explicit dependencies.
routingroutersboundaries - 03
Middleware order
Order middleware so parsing, security, routes, 404s, and errors run in the intended sequence.
middlewareroutingerrors - 04
Request validation
Validate request input at the route boundary before calling business services.
validationrequestssecurity - 05
Async route error forwarding
Let async route failures reach the Express error pipeline instead of becoming unhandled work.
asyncerrorsroutes - 06
Central error handler
Use one Express error handler to map application errors into HTTP responses.
errorsmiddlewareresponses - 07
Response shape consistency
Return predictable success and error envelopes across routes.
responsesapicontracts - 08
Auth middleware boundaries
Authenticate once in middleware and pass a safe user context to route handlers.
authmiddlewaresecurity - 09
Rate limiting and trust proxy
Configure client IP trust deliberately before using IP-based controls.
securityrate-limitingproxy - 10
Avoiding business logic in routes
Keep route handlers thin by delegating business decisions to services.
architectureroutesservices