| name | api-skill |
| description | Build or modify API endpoints in this repository by driving changes from openapi.yaml, regenerating API models, implementing routes manually, and wiring validation/auth/timing correctly. Use when creating new APIs, changing existing APIs, or updating API request/response models. Use when this capability is needed. |
| metadata | {"author":"6529-collections"} |
API Development Workflow
Follow this workflow for any API change in this repository.
Core Rules
- Define API contract first in
src/api-serverless/openapi.yaml.
- Start every new schema/model name with
Api.
- After editing
openapi.yaml, run:
cd src/api-serverless && npm run generate
- Treat
src/api-serverless/src/generated as generated-only.
- Never edit files in this folder manually.
- Remember generation scope:
- Generates request/response body models.
- Does not generate routes.
- Does not generate query/path param types.
Route Implementation Rules
- Implement routes manually in files ending with
.routes.ts.
- Ensure routes align 100% with
openapi.yaml (paths, params, payloads, responses).
- If query/path param typing is needed, define those types manually in the route file (or nearby file as appropriate).
- Wire every new route file into
src/api-serverless/src/app.ts.
- Validate route input with Joi using
getValidatedByJoiOrThrow (getValidatedByJoi) and a schema (typically defined in the route file).
- Never mark routes as cached unless explicitly instructed.
Auth and Request Context Rules
- Use
needsAuthenticatedUser() when authentication is required.
- Use
maybeAuthenticatedUser() when authentication is optional.
- Use
getAuthenticationContext(req) after auth middleware when auth context is needed.
- In routes, always initialize timer:
const timer = Timer.getFromRequest(req);
- Pass
timer to downstream service calls and use it to time work as needed.
Route Layer Responsibilities
Keep routes thin:
- Validate input with Joi.
- Do only very light request preparation.
- Call an appropriate service class for business logic.
- Await the service result and return it.
Do not place heavy business logic in routes.
Practical Checklist
Converted and distributed by TomeVault — claim your Tome and manage your conversions.