# dev-echo-server

> Echo server. For development purposes only.

Latest version **0.2.1** (published 2023-12-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install dev-echo-server
pnpm add dev-echo-server
yarn add dev-echo-server
bun add dev-echo-server
```

Provides the command `dev-echo-server`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2023-12-13 |
| First published | 2023-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | FireBlink LTD |
| Maintainers | vlad-tkachenko |
| Keywords | fireblink, echo, server, development, http, http2, http/2, ws, websocket |

## Links

- npm: https://www.npmjs.com/package/dev-echo-server
- Repository: https://github.com/FireBlinkLTD/dev-echo-server
- Homepage: https://github.com/FireBlinkLTD/dev-echo-server#readme
- Issues: https://github.com/FireBlinkLTD/dev-echo-server/issues
- npm.io page: https://npm.io/package/dev-echo-server

## Dependencies (1)

- [socket.io](https://npm.io/package/socket.io.md) ^4.7.2

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2023-12-13
- 0.2.0 — 2023-12-08
- 0.1.0 — 2023-12-08

## README

# dev-echo-server

Simple echo server for development purposes.

Mainly developed to help with the testing of:
- [prxi](https://github.com/FireBlinkLTD/prxi) - zero runtime dependency HTTP, HTTP/2 proxy library
- [prxi-openid-connect](https://github.com/FireBlinkLTD/prxi-openid-connect) - OpenID Connect reverse proxy for HTTP, HTTP/2 connections

Supports:
- HTTP
- HTTPS
- HTTP/2 h2c
- HTTP/2
- WS
- WSS
  
## Usage

```bash
npm i -g dev-echo-server

# generate certificate and key
openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -keyout key.pem -out cert.pem

export PATH_CERT=cert.pem
export PATH_KEY=key.pem

dev-echo-server
```

## Ports

| Port | Protocol   | Environment Variable |
|------|------------|----------------------|
| 7001 | HTTP       | `PORT_HTTP`          | 
| 7002 | HTTPS      | `PORT_HTTPS`         |
| 7003 | HTTP/2 h2c | `PORT_HTTP2_H2C`     |
| 7004 | HTTP/2     | `PORT_HTTP2`         |


## Headers

### X-Add-Headers

`x-add-headers` Header can be used to add additional headers to the response. Value should be a JSON object.

**Example:**
```bash
curl http://localhost:7001 \
  -H 'x-add-headers: {"test": "test"}'
```

## Invocation examples

### CURL Scripts

```bash
# HTTP
curl http://localhost:7001/\?a\=b 

# HTTPS
curl https://localhost:7002/\?a\=b -k

# HTTP/2 h2c
# Upgrade for h2c is not supported by node thus `--http2-prior-knowledge` should be used
curl --http2-prior-knowledge http://localhost:7003/\?a\=b 

# HTTP/2
curl --http2 https://localhost:7004/\?a\=b -k
```

### Socket.IO CLI

```bash
npm i -g socket.io-cli

# expose env to trust self-signed certificate
export NODE_EXTRA_CA_CERTS=cert.pem 

# HTTP
socketio http://localhost:7001 

# HTTPS
socketio https://localhost:7002

# HTTP/2 h2c - NOT SUPPORTED

# HTTP/2
socketio https://localhost:7004

# Once connected just type <event> [args] and hit enter
```

---
_Source: https://npm.io/package/dev-echo-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
