| name | api-endpoint |
| description | Scaffold a new REST endpoint in packages/api following project layering (route → service → repository). Use when adding a new API route. |
Create an API Endpoint
Follow these steps to add a new endpoint:
- Copy
template.ts (in this skill folder) as the starting point.
- Create
packages/api/src/routes/<resource>.ts with a thin handler.
- Add validation with a Zod schema in
@shared/validators.
- Put business logic in
packages/api/src/services/<resource>.service.ts.
- Data access goes in
packages/api/src/repositories/.
- Register the route in
src/app.ts.
- Add a
supertest test <resource>.test.ts and run npm run test:api.
Keep controllers free of business logic. Wrap handlers in asyncHandler().