🗒 Cheat Sheet← Lesson
BitWithBite
Full-Stack Worksheet

🚗 Express REST API

Chapter: Node.js & Express — Backend APIs · Level ★★★ · Time: 20 min
SCORE___ / 20
NameClassDate
After this worksheet you can
Define Express routesWrite full CRUD handlersUse middlewareChoose correct status codes
📚 Quick Recap

🎯 What you'll practice: Express routes, middleware, and CRUD with proper status codes.

🧠 Section A · Concept Check ● BEGINNER 4 × 1 = 4

1A successful create should return status:
2A successful delete with no body returns:
3express.json() is:
4req.params is used to read:

🧮 Section B · Problem Solving ● INTERMEDIATE 2 + 3×3 = 11

5A resource not found should respond with status .
6req. contains the parsed JSON body of a POST request.
7Write a GET route for "/api/courses/:id" that returns 404 if not found.
8Write a DELETE route for "/api/courses/:id" that responds with 204.
9Why is app.use(express.json()) required before routes can read req.body?

🚀 Section C · Challenge ● CHALLENGE 5

10Design full CRUD routes for a "notes" resource (in-memory array): list, get one, create, update, delete. Write all 5 routes.
💭 Reflection — the most useful thing I learned:
A ___/4   B ___/11   C ___/5   Total ___/20 Teacher's Signature Parent's Signature
✂ answer key — fold or cut before handing out

1-B   2-C   3-B   4-B  |  5 = 404   6 = body   7 = app.get('/api/courses/:id',(req,res)=>{const c=courses.find(x=>x.id===Number(req.params.id));if(!c)return res.status(404).json({error:'Not found'});res.json(c);});   8 = app.delete('/api/courses/:id',(req,res)=>{courses=courses.filter(x=>x.id!==Number(req.params.id));res.status(204).send();});   9 = Because Express doesn't parse the request body by default — express.json() middleware reads the raw incoming stream and populates req.body before any route handler runs  |  10 = GET /api/notes (list), GET /api/notes/:id (one), POST /api/notes (create, 201), PUT /api/notes/:id (update), DELETE /api/notes/:id (delete, 204) — each following the same array find/filter pattern as the course example.

📄 Need offline practice?Print this worksheet or open the one-page cheat sheet.
🗒 Cheat Sheet