Capstone · 10 min read · Intermediate
Node.js Capstone: JSON API & Validation
Combine URL routing, input validation, crypto IDs, and clean HTTP responses in a mini Node.js backend service.
What you'll learn
- Validate incoming JSON payloads before storing them
- Generate unique IDs with crypto.randomUUID()
- Prepare for the Node.js Final Exam and Certificate
In this capstone, you will build a clean, testable Task API handler that validates request bodies, assigns secure UUIDs, and returns structured HTTP status codes.
Fill-in-the-Blank Capstone
Generate Secure UUID
Assign a cryptographically strong UUID to each newly created task.
const id = crypto.();
return { status: , body: { id, title } };Capstone Code Lab (Node.js 20)
Node.jstask_api.js
Expected OutputClick “Run Live” to compile with Node.js 20
{ status: 400, body: { error: 'Title must be at least 3 chars' } }
Created status: 201 | Count: 1Check Your Understanding
Score: 0 / 1
1. What status code should a Node.js API return when a client submits invalid JSON fields?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.