Description
Routes use a mix of inline checks and ad-hoc validators. Centralize on Zod schemas per route, with a single validateBody(schema) middleware producing uniform error envelopes.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
src/middleware/validation.ts, src/routes/
- Migrate routes incrementally; keep one PR per route group
Suggested execution
- Fork the repo and create a branch
git checkout -b refactor/zod-body-validation
- Implement changes
- Add Zod dependency and shared error formatter
- Migrate slots and booking-intent routes first
- Document schema-per-route convention
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- Extra unknown fields are stripped, not silently accepted
- Include test output and notes
Example commit message
refactor: Zod schemas and unified body validation
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
Routes use a mix of inline checks and ad-hoc validators. Centralize on Zod schemas per route, with a single
validateBody(schema)middleware producing uniform error envelopes.Requirements and context
src/middleware/validation.ts,src/routes/Suggested execution
git checkout -b refactor/zod-body-validationTest and commit
npm testExample commit message
refactor: Zod schemas and unified body validationGuidelines