Skip to content

Instantly share code, notes, and snippets.

@bszwej
bszwej / echo.js
Last active July 23, 2024 19:51
Pure Node.js echo server, that logs all incoming http requests (method, path, headers, body).
const http = require('http');
const server = http.createServer();
server.on('request', (request, response) => {
let body = [];
request.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();