One API, from raw Node to NestJS
This combined project brings Node.js and NestJS together. You'll build the café's orders backend three ways — raw node:http, then Express, then a structured NestJS app — so you see exactly what each layer does for you.
- Day 1: a server with only node:http
- Day 2: Express with middleware, pagination and error handling
- Day 3: a NestJS service with business rules
- Day 4: a guard for staff and kitchen
- Day 5: the finished orders API
Requests in, JSON out
import http from "node:http";
import { MENU } from "./lib/menu.js";
const server = http.createServer((req, res) => {
const url = new URL(req.url, "http://localhost");
const send = (status, body) => {
res.writeHead(status, { "Content-Type": "application/json" });
res.end(JSON.stringify(body));
};
if (req.method === "GET" && url.pathname === "/health") return send(200, { ok: true });
if (req.method === "GET" && url.pathname === "/menu") {
const vegOnly = url.searchParams.get("veg") === "true";
return send(200, vegOnly ? MENU.filter((d) => d.veg) : MENU);
}
send(404, { error: "Not found" });
});
server.listen(3000, () => console.log("Listening on http://localhost:3000"));