<One sentence: what this API does and its main consumers.>
Stack
- Node.js (<version from .nvmrc>) + TypeScript + Express
-
DB: <PostgreSQL via Prisma Knex pg>; validation: ; logging: -
Tests: <Vitest Jest> + Supertest
Commands
- Install:
npm ci - Dev (watch):
npm run dev - Typecheck:
npx tsc --noEmit - Lint:
npm run lint - Tests:
npm test(needsdocker compose up -d dbfirst) - Migrations:
<npx prisma migrate dev>
Layout
src/routes/HTTP layer only: parse, validate, call a service, map the result to a responsesrc/services/business logic, no Express types heresrc/db/queries/repositories;src/lib/shared utilitiestests/mirrorssrc/
Rules
- Validate every request body, query and param with
at the route boundary. - Errors: throw typed errors (
NotFoundError,ValidationError) from services; the error middleware maps them to HTTP status codes. Never send stack traces to clients. - Async route handlers must propagate errors to the error middleware (Express 5 does this for returned promises; on Express 4 use a wrapper).
- All SQL parameterized. No string-built queries.
- Log with the request-scoped logger and include the request id; never log tokens, passwords or full card numbers.
- New endpoints need: input schema, auth check, tests for success, validation failure and authorization failure.
- Keep the OpenAPI spec in
<openapi.yaml>in sync with route changes.
Definition of done
- Typecheck, lint and tests pass; new endpoints documented; migrations reversible or noted as forward-only.