Bootstrap and Startup
Startup sequence
Section titled “Startup sequence”backend/src/server.tsimports app and resolvesPORT.backend/src/app.tscallsloadEnvironment()before creating Express app.- Middlewares are registered in this order:
cors()express.json()globalLimiter
- Health endpoint is mounted:
GET /health. - API routers are mounted under
/api/v1viaapiRoutes(app). - Centralized error middleware is mounted last.
Why this order matters
Section titled “Why this order matters”- Global rate limit protects all endpoints, including auth and health-adjacent paths.
- Validation/auth errors are normalized by the shared error middleware.
- Route registration after base middleware guarantees JSON parsing and CORS are always applied.
Minimal code anchor
Section titled “Minimal code anchor”app.get('/health', (_req, res) => { res.status(200).json({ status: 'ok' });});Source: backend/src/app.ts.