Commit | Line | Data |
---|---|---|
11856b30 JB |
1 | import { Server } from 'node:http' |
2 | ||
3 | const port = 8080 | |
4 | const server = new Server() | |
5 | ||
6 | server | |
7 | .on('request', (request, response) => { | |
8 | let body = [] | |
9 | request | |
041dc05b | 10 | .on('data', chunk => { |
11856b30 JB |
11 | body.push(chunk) |
12 | }) | |
13 | .on('end', () => { | |
14 | body = Buffer.concat(body).toString() | |
15 | ||
16 | console.info(`==== ${request.method} ${request.url} ====`) | |
17 | console.info('> Headers') | |
18 | console.log(request.headers) | |
19 | ||
20 | console.info('> Body') | |
21 | console.info(body) | |
22 | response.end() | |
23 | }) | |
24 | }) | |
25 | .listen(port) |