Build HTTP APIs with routing, middleware, validation, controllers, and error handling.
Lessons
Mount routers under base paths to build feature modules.
Nested and Mounted Routers is easiest to learn by reading the example, changing it, and observing the result.
// routes/lessons.js
import { Router } from 'express';
const router = Router();
router.route('/')
.get((req, res) => res.json({ lessons: [] }))
.post((req, res) => res.status(201).json({ created: true }));
export default router;
// app.js
import express from 'express';
import lessons from './routes/lessons.js';
const app = express();
app.use('/api/lessons', lessons); // mount the router
app.listen(3000);Practice the Nested and Mounted Routers example in a small scratch file, then explain what changed and why.