What problem does it solve?
This Skill streamlines the creation of secure, validated, and efficient API routes within a Next.js 16 application, ensuring seamless data handling and robust error management.
Core Features & Use Cases
- RESTful Endpoint Creation: Define GET, POST, PUT, DELETE handlers for CRUD operations.
- Schema Validation: Implement data integrity using Zod for request bodies and parameters.
- Prisma Integration: Safely interact with your database, adhering strictly to the
prisma/schema.prisma definition.
- Authentication & Authorization: Protect endpoints using NextAuth.js session management.
- Error Handling: Utilize a standardized
handleError function for consistent API responses.
- Use Case: Develop a new API endpoint to create and retrieve user profiles, ensuring all incoming data is validated against a predefined schema and that only authenticated users can perform mutations.
Quick Start
Use the api-route skill to create a POST endpoint at /api/users that accepts a JSON body validated by a Zod schema and saves it to the database using Prisma.