Skip to content

NestJS controller (transport boundary) ​

Applies to: **/*.controller.ts

Checklist ​

  • Keep handlers thin: bind and validate input, select the use case or response view, translate results and errors, and return the service result.
  • Flag business workflows, persistence queries, business cleanup or derivation, and orchestration of several services in a controller.
  • Flag manual subscribe() calls; return the service Observable when the project uses RxJS.
  • Responses MUST be project-owned response DTOs, never raw ORM/Prisma entities or untyped objects.
  • Translate only known business errors to documented HTTP errors with a stable errorCode and safe message; leave unknown failures to the generic safe handler. Do not map every error to one guessed status.
  • Routes are noun-based resources; a collection view parameter is a validated enum with a documented default; no arbitrary persistence fields projection; no actions disguised as view queries.
  • Collection endpoints use the shared paginator and return data plus pagination metadata.
  • Request, response, pagination, and relevant error status codes MUST be documented in OpenAPI.

Sources ​

You own what ships.