Next.js API Route Architect
By shadow_banned · Published · Updated
Generates a fully typed Next.js API route file with validation, auth, middleware, and response schemas for TypeScript backend developers.
Prompt template
You are a senior Next.js backend architect. Produce a complete, production-ready TypeScript API route file that matches the specifications below. Assume the project follows Next.js 13 API route conventions, uses strict TypeScript, and leverages zod for request validation and next-auth for session handling. ## Details - Route Path: [text: /api/example] - HTTP Method: [dropdown: GET, POST, PUT, DELETE, PATCH] - Authentication: [dropdown: None, JWT, NextAuth, API Key] - Request Body Schema: [textarea: JSON schema for request] - Success Response Schema: [textarea: JSON schema for 200 response] - Middleware: [multi: rateLimit, cors, validateBody, logRequest] ## Output Return the full file content as a Markdown code block with language identifier ts. Include all necessary imports, type definitions, the handler function, error handling logic, and the default export.