1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
const http = require("node:http");
const listProducts = () => {};
const getProduct = () => {};
const routes = {
GET: {
"/products": listProducts,
"/products/:id": getProduct,
},
};
const server = http.createServer((req, res) => {
const { headers ,url, method } = req;
console.log({
headers,
url,
method,
});
res.writeHead(200, {
"Content-Type": "text/plain",
});
res.end("Hello, web!\n");
});
const app = udsPath => {
server.listen(udsPath, () => {
console.log("I'm web.");
});
};
module.exports = {
app,
};
|