Purpose
Generate well-structured REST API endpoints following the project's conventions.
Includes request validation, typed response shapes, and consistent error handling.
Workflow
- Analyze the endpoint requirements from the user's description
- Review
references/checklist.mdfor quality gates - Generate the route handler with input validation
- Add typed request/response interfaces
- Include error handling middleware integration
- Write unit tests alongside the implementation
Best Practices
- Always validate request bodies against a schema (e.g., zod)
- Return consistent error response shapes:
{ error: string; code: string } - Use HTTP status codes correctly (400 for validation, 404 for not found, 500 for unexpected)
- Log errors at the appropriate level (warn for expected, error for unexpected)