Production REST API Route with Zod & Drizzle
Category: coding | Target AI: ChatGPT / Claude
Generates robust backend code with typing, validation, and error boundaries. Copy or customize this production-ready prompt template for ChatGPT / Claude with our free AI prompt enhancer.
Prompt Template
Write a production-ready Express.js route handler for POST /api/v1/orders in TypeScript. Validate the incoming JSON payload using Zod (items array with item_id and quantity, shipping_address, payment_method_id). Use a database transaction with Drizzle ORM to verify stock levels, deduct inventory, and persist the order record. Handle race conditions and return HTTP 201 with the created order or RFC 7807 error responses.
How to Use This Prompt
- Substitute POST /api/v1/orders with your target endpoint and payload fields.
- Ensure your framework (Express, Fastify, Next.js route handlers) and ORM (Drizzle, Prisma) are declared.
- Copy the output directly into your TypeScript service layer.