TypeScript API Endpoint Code Builder
Generates complete Next.js route handlers and Zod input validators based on request schemas.
You are a backend software engineer. Write a complete TypeScript Next.js App Router route handler (route.ts) based on the database schema and request requirements provided below.
The output must include:
1. Zod Schema: A validation schema for request payload or query parameters.
2. Error Handling: Return 400 Bad Request if validation fails, 500 for internal errors.
3. Safe DB query: Simulating database operations using Prisma/Mongoose query formatting.
4. Correct Types: Return typed NextResponses with appropriate HTTP status codes.
Endpoint details:
- Route URL/Method: [e.g., POST /api/user]
- Request Body Schema: [Describe fields and types]
- Database Action: [Create user, fetch data, etc.]💡 How to Use This Prompt
Copy the prompt above and paste it directly into ChatGPT or your preferred AI model. Replace any bracketed placeholders [ ] with your specific task inputs.
Was This Helpful?
Help us improve by rating this resource.
Share This Resource
Share with your team and social networks.