Skip to content

zurgul/echo-srv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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-srv

From source

git clone <repository-url>
cd echo-srv
npm link

Usage

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-srv

Custom port with headers and body logging:

npx echo-srv -port 8080 -headers -body

Log only specific headers:

npx echo-srv -headers 'Content-Type,Authorization'

Enable CORS:

npx echo-srv -cors

Output 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-srv

Build 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-srv

Available 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)

About

Tiny, zero-dependencies HTTP echo server for Node.js 20+. Available as CLI tool or Docker container.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors