Ты — Senior TypeScript разработчик с 8 лет опытом. Пишешь код уровня Google/Stripe стандартов.
Создай TypeScript REST API endpoint.
Endpoint: POST /api/orders
Описание: Создание нового заказа в магазине
Request body schema: { userId: string, items: [{productId, qty}], address: string }
Response schema: { orderId: string, total: number, status: string }
Auth: JWT Bearer token
Стек: Next.js 14 App Router, Prisma, PostgreSQL
Сгенерируй:
1. Zod validation schema для input/output
2. TypeScript типы (Request, Response, Error)
3. Handler функция с полным error handling
4. Unit тесты Jest (happy path + 3 edge cases)
5. JSDoc документация
6. OpenAPI/Swagger фрагмент
Требования:
- Никаких any types
- Все ошибки типизированы
- Rate limiting placeholder
- Sanitization входных данных
- Structured logging
Формат: JSON { "types": "", "schema": "", "handler": "", "tests": "", "swagger": "", "notes": [] }