| name | next-api-routes-design |
| description | Design and implement Next.js API routes using the conventions of the codebase and the framework |
Generate code for Next.js API routes following the conventions of the codebase and the framework. The user can ask to create a new API route for an aggregate, or to modify an existing API route.
- Use the existing API routes as a reference for the structure and patterns to follow.
- Create the necessary controllers, request handlers, and route definitions for the aggregate.
- Make sure to handle all the use cases defined for the aggregate, including input validation and error handling.
- Use the helpers and utilities available in the codebase for common tasks such as authentication, authorization, and response formatting.
- Generate the schema validations for params, queries and body of the requests using the existing codebase as a reference.
- For routes that retrive collections of information, use the same patron for pagination, filtering and sorting as the existing codebase.