Node ships a full HTTP server in `node:http`. A request handler receives `(req, res)`: `req` is a readable stream describing the incoming request, `res` is a writable stream you use to send a response.
js
import { createServer } from "node:http";
const server = createServer((req, res) => {
if (req.url === "/health") {
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify({ ok: true }));
return;
}
res.writeHead(404);
res.end("not found");
});
server.listen(3000, () => console.log("listening on :3000"));Frameworks like Express build convenience on top of this same primitive (routing, middleware, body parsing) — understanding the raw `http` module makes those abstractions much less mysterious.