import http from "node:http"; const profile = { id: 42, name: "Ada Lovelace", plan: "pro", }; const server = http.createServer((request, response) => { response.setHeader("content-type", "application/json; charset=utf-8"); if (request.method === "GET" && request.url === "/v1/profile") { response.writeHead(200); response.end(JSON.stringify(profile)); return; } response.writeHead(404); response.end(JSON.stringify({ error: "not_found" })); }); server.listen(3040, "127.0.0.1", () => { console.log("Demo API listening on http://127.0.0.1:3040"); });