Projects›Core· 150 min read
Project: Build a REST API
Build a complete, well-structured REST API with full CRUD, validation and error handling.
What you will learn
- Build a full CRUD API
- Add validation and error handling
- Structure the project cleanly
The brief
Build a REST API for a resource of your choice (notes, books, tasks, products). Use an array as the data store for now — MongoDB comes next.
Requirements
- All five endpoints: list all, get one, create, update, delete.
express.json()middleware and a request logger.- Input validation (reject bad/missing data with 400).
- Correct status codes (200, 201, 404, 400).
- A catch-all 404 and a central error handler.
- CORS enabled so a front-end can call it.
Tip: Test every endpoint with a tool like Postman or the Thunder Client VS Code extension. Confirm each returns the right data and status code before moving on.
Note: Keep routes tidy — as the API grows, split routes into separate files with Express Router. A clean structure pays off fast.
✍️ Practice
- Build the full CRUD API meeting all six requirements.
- Test every endpoint and confirm the status codes.
🏠 Homework
- Split your routes into a separate router file and add one more validated field.