Week 4: REST API Layer — Nov 16 – 22, 2024
TL;DR: 20+ REST endpoints are live for customers, properties, and jobs. Request validation with Zod, consistent error handling, and pagination built in.
Highlights This Week
- Built Express route files for customers, properties, and jobs
- Implemented input validation validation on all request bodies
- Added consistent error handling middleware with structured JSON responses
API Design Philosophy
Every endpoint follows the same pattern: authenticate → validate → authorize → execute → respond. input validations validate request bodies at the route level, catching malformed data before it reaches the service layer. Error responses use a consistent { success: false, error: { code, message } } format.
Middleware Stack
The request flows through: CORS → body parser → auth → tenant resolution → route handler → error handler. Each middleware is composable and independently testable.
What’s Next
Building the React frontend to bring this API to life.