| name | add-endpoint |
| description | Add a REST endpoint to the canonical NestJS backend (backend-nestjs) with DTO validation, guards, audit logging, Swagger docs, and scoped tests. |
Add a REST Endpoint (backend-nestjs)
Endpoint to add: $ARGUMENTS
- Locate or create the domain module in
backend-nestjs/src/<domain>/ (<domain>.module.ts, .controller.ts, .service.ts, dto/). Mirror an existing module such as src/cases/ — do not invent new structure.
- Define request/response DTOs in
dto/ with class-validator decorators.
- Implement the controller route with Swagger decorators (
@ApiTags, @ApiOperation, @ApiResponse) and @UseGuards(JwtAuthGuard) (+ PermissionsGuard if role-restricted), matching sibling controllers.
- Implement the service method using
@silver-cross/shared Sequelize models (no raw SQL). Add audit-log entries for mutating operations, following existing services.
- If the module is new, register it in
src/app.module.ts.
- Confirm external reachability: the API gateway (
services/api-gateway) proxies /api/* to BACKEND_SERVICE_URL; verify the path is covered.
- Write a controller/service spec next to the code, then verify scoped:
npm run type-check -w @silver-cross/backend-nestjs
npm run test -w @silver-cross/backend-nestjs
- Show the passing test output as evidence before declaring the endpoint done.