echo-srv
v1.0.0
Published
Minimalistic HTTP echo server
Readme
echo-srv
Tiny, zero-dependencies HTTP echo server for Node.js 20+. Available as CLI tool or Docker container.
Run via npx (no installation)
npx echo-srv [options]Installation
Via npm (global)
npm install -g echo-srvFrom source
git clone <repository-url>
cd echo-srv
npm linkUsage
echo-srv [options]Or with npx:
npx echo-srv [options]Options
-port <number>- Server port (default: 3000)-headers- Log all HTTP headers-headers '<header1>,<header2>,...'- Log only specific headers (case-insensitive)-body- Log request body-cors- Enable CORS (Access-Control-Allow-* headers set to *)-help, --help- Show help message
Examples
Basic server on port 3000:
npx echo-srvCustom port with headers and body logging:
npx echo-srv -port 8080 -headers -bodyLog only specific headers:
npx echo-srv -headers 'Content-Type,Authorization'Enable CORS:
npx echo-srv -corsOutput Format
The server logs each request in a structured format:
>>> [ 2025-10-13T12:34:56.789Z ]
GET /api/test?foo=bar
Query: {
"foo": "bar"
}With -headers flag:
>>> [ 2025-10-13T12:34:56.789Z ]
GET /api/test
Query: none
Headers: {
"content-type": "application/json",
"authorization": "Bearer token"
}With -body flag:
>>> [ 2025-10-13T12:34:56.789Z ]
POST /api/data
Query: none
Body: {"key":"value"}Response
All requests receive HTTP 200 OK with no body.
Docker
Build and run with defaults (all logging enabled + CORS)
docker build -t echo-srv .
docker run -p 3000:3000 echo-srvBuild with custom parameters
docker build \
--build-arg PORT=8080 \
--build-arg LOG_HEADERS=true \
--build-arg LOG_BODY=true \
--build-arg ENABLE_CORS=true \
-t echo-srv .Run on different port
docker run -p 8080:3000 echo-srvAvailable build arguments
PORT- Server port (default: 3000)LOG_HEADERS- Log all headers (default: true)LOG_BODY- Log request body (default: true)ENABLE_CORS- Enable CORS (default: true)
