coding · GPT-4o · free
Write a production ready Express route. Method + path: [POST /api/...] Purpose: [WHAT IT DOES IN ONE SENTENCE] Auth: [PUBLIC / JWT / SESSION / API KEY] Deliver a single handler file including: Zod schema for body, query, params — parsed with .safeParse 400 with structured error shape { code, message, details[] } on validation fail 401/403 before any DB call The domain call — no business logic inline, delegated to services/[NAME].ts Idempotency key handling if it's a mutation Structured logging: one req.log.info at entry with correlation id, one at exit with duration try/catch that maps known errors to status codes; unknown → 500 with logged stack, no leaked details Rate limit middleware attached at the router level A README block comment at the top listing every response shape Node 20, Express 5, TypeScript strict.#express #nodejs #backend