Skip to content

Commit

Permalink
Logging providers & Documentation (Ealenn#61)
Browse files Browse the repository at this point in the history
* Logs with Seq
* Update documentation
  • Loading branch information
Ealenn authored Jan 20, 2021
1 parent e23280f commit 0ae2d43
Show file tree
Hide file tree
Showing 49 changed files with 1,127 additions and 611 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
.gitignore
docs
*.md
Dockerfile
Dockerfile.local
docker-compose.yml

# Logs
logs
Expand Down
15 changes: 15 additions & 0 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:lts-alpine3.9

WORKDIR /build
COPY package.json .
COPY package-lock.json .
RUN npm install

COPY . .
RUN npm run build

WORKDIR /app
RUN cp /build/src/global.json .
RUN cp /build/dist/webserver.js .

ENTRYPOINT [ "node", "webserver" ]
172 changes: 112 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# Echo-Server / Docker / Kubernetes / Helm

[![Codecov](https://img.shields.io/codecov/c/github/ealenn/echo-server?style=for-the-badge&logo=codecov)](https://codecov.io/gh/Ealenn/Echo-Server)
[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/ealenn/echo-server?style=for-the-badge)](https://www.codefactor.io/repository/github/ealenn/echo-server)
[![GitHub stars](https://img.shields.io/github/stars/Ealenn/Echo-Server?style=for-the-badge&logo=github)](https://github.com/Ealenn/Echo-Server/stargazers)
[![GitHub issues](https://img.shields.io/github/issues/Ealenn/Echo-Server?style=for-the-badge&logo=github)](https://github.com/Ealenn/Echo-Server/issues)
[![DockerHub](https://img.shields.io/docker/pulls/ealen/echo-server.svg?style=for-the-badge&logo=docker)](https://hub.docker.com/repository/docker/ealen/echo-server)
[![DockerHub](https://img.shields.io/badge/SIZE-%3C%2030%20MB-1488C6?style=for-the-badge&logo=docker)](https://hub.docker.com/repository/docker/ealen/echo-server)

> Read the docs : [https://ealenn.github.io/Echo-Server](https://ealenn.github.io/Echo-Server) - Read the [release notes](https://github.com/Ealenn/Echo-Server/releases)
> Read the docs : [https://ealenn.github.io/Echo-Server](https://ealenn.github.io/Echo-Server)
An echo server is a server that replicates the request sent by the client and sends it back.

Available:

![](https://img.shields.io/badge/linux-amd64-blue?style=flat-square&logo=docker)
![](https://img.shields.io/badge/linux-arm/v6-blue?style=flat-square&logo=docker)
![](https://img.shields.io/badge/linux-arm/v7-blue?style=flat-square&logo=docker)
![](https://img.shields.io/badge/linux-arm64/v8-blue?style=flat-square&logo=docker)
![](https://img.shields.io/badge/linux-ppc64le-blue?style=flat-square&logo=docker)
![](https://img.shields.io/badge/linux-s390x-blue?style=flat-square&logo=docker)

- GET / POST / PUT / PATCH / DELETE
- Request (Query, Body, IPs, Host, Urls...)
- Request Headers / Response Headers
- Environment variables
- Control via Headers/Query
- Folders and Files

Docker OS/ARCH :

- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64/v8
- linux/ppc64le
- linux/s390x
- Monitoring

![docker](https://ealenn.github.io/Echo-Server/assets/images/docker.png)

Expand All @@ -45,18 +45,20 @@ Docker OS/ARCH :
* [File/Folder explorer](#FileFolderexplorer)
* [Combine custom actions](#Combinecustomactions)
* [Change default Queries/Request commands](#ChangedefaultQueriesRequestcommands)
* [Loggers](#Loggers)
* [Seq](#Seq)
* [Setting up](#Settingup)
* [Docker](#Docker)
* [Docker-Compose](#Docker-Compose)
* [Kubernetes](#Kubernetes)
* [Kubernetes with Helm](#KuberneteswithHelm)
* [NodeJS](#NodeJS)
* [Contributing](#Contributing)
* [Versioning](#Versioning)
* [License](#License)
* [Local development](#Localdevelopment)
* [Run Echo-Server](#RunEcho-Server)
* [Run documentation server](#Rundocumentationserver)
* [Run tests](#Runtests)
* [Development](#Development)
* [Documentation](#Documentation)
* [Tests](#Tests)
* [Release notes](#Releasenotes)
* [Update Helm Chart](#UpdateHelmChart)

Expand Down Expand Up @@ -99,18 +101,16 @@ I use [jq](https://stedolan.github.io/jq) for nice `curl` results ;)

#### <a name='CustomHTTPStatusCode'></a>Custom HTTP Status Code

ECHO_HOST = `localhost:3000` or `echoserver.cluster.local` for Kubernetes by default.

```bash
➜ curl -I --header 'X-ECHO-CODE: 404' $ECHO_HOST
➜ curl $ECHO_HOST/?echo_code=404
➜ curl -I --header 'X-ECHO-CODE: 404' localhost:8080
➜ curl -I localhost:8080/?echo_code=404

HTTP/1.1 404 Not Found
```

```bash
➜ curl -I --header 'X-ECHO-CODE: 404-300' $ECHO_HOST
➜ curl $ECHO_HOST/?echo_code=404-300
➜ curl -I --header 'X-ECHO-CODE: 404-300' localhost:8080
➜ curl -I localhost:8080/?echo_code=404-300

HTTP/1.1 404 Not Found
HTTP/1.1 300 Multiple Choices
Expand All @@ -119,7 +119,7 @@ HTTP/1.1 300 Multiple Choices
```bash
for i in {1..10}
do
➜ curl -I $ECHO_HOST/?echo_code=200-400-500
➜ curl -I localhost:8080/?echo_code=200-400-500
done

HTTP/1.1 500 Internal Server Error
Expand All @@ -133,25 +133,25 @@ HTTP/1.1 500 Internal Server Error
#### <a name='CustomBody'></a>Custom Body

```bash
➜ curl --header 'X-ECHO-BODY: amazing' $ECHO_HOST
➜ curl $ECHO_HOST/?echo_body=amazing
➜ curl --header 'X-ECHO-BODY: amazing' localhost:8080
➜ curl localhost:8080/?echo_body=amazing

"amazing"
```

#### <a name='CustomBodywithEnvironmentvariablevalue'></a>Custom Body with Environment variable value

```bash
➜ curl --header 'X-ECHO-ENV-BODY: HOSTNAME' $ECHO_HOST
➜ curl $ECHO_HOST/?echo_env_body=HOSTNAME
➜ curl --header 'X-ECHO-ENV-BODY: HOSTNAME' localhost:8080
➜ curl localhost:8080/?echo_env_body=HOSTNAME

"c53a9ed79fa2"
```

```bash
for i in {1..10}
do
➜ curl $ECHO_HOST/?echo_env_body=HOSTNAME
➜ curl localhost:8080/?echo_env_body=HOSTNAME
done

"c53a9ed79fa2"
Expand All @@ -164,16 +164,16 @@ HTTP/1.1 500 Internal Server Error
#### <a name='CustomHeaders'></a>Custom Headers

```bash
➜ curl --header 'X-ECHO-HEADER: One:1' $ECHO_HOST
➜ curl $ECHO_HOST/?echo_header=One:1
➜ curl --header 'X-ECHO-HEADER: One:1' localhost:8080
➜ curl localhost:8080/?echo_header=One:1

HTTP/1.1 200 OK
One: 1
```

```bash
➜ curl --header 'X-ECHO-HEADER: One:1, Two:2' $ECHO_HOST
➜ curl "$ECHO_HOST/?echo_header=One:1,%20Two:2"
➜ curl --header 'X-ECHO-HEADER: One:1, Two:2' localhost:8080
➜ curl "localhost:8080/?echo_header=One:1,%20Two:2"

HTTP/1.1 200 OK
One: 1
Expand All @@ -183,8 +183,8 @@ Two: 2
#### <a name='Customresponselatency'></a>Custom response latency

```bash
➜ curl --header 'X-ECHO-TIME: 5000' $ECHO_HOST
➜ curl "$ECHO_HOST/?echo_time=5000"
➜ curl --header 'X-ECHO-TIME: 5000' localhost:8080
➜ curl "localhost:8080/?echo_time=5000"

⏳... 5000 ms
```
Expand All @@ -201,24 +201,26 @@ You can change default validations with
#### <a name='FileFolderexplorer'></a>File/Folder explorer

```bash
➜ curl --header 'X-ECHO-FILE: /' $ECHO_HOST
➜ curl "$ECHO_HOST/?echo_file=/"
➜ curl --header 'X-ECHO-FILE: /' localhost:8080
➜ curl "localhost:8080/?echo_file=/"

["app", "bin", "etc", "usr", "var"]
```

#### <a name='Combinecustomactions'></a>Combine custom actions

```bash
➜ curl --header 'X-ECHO-CODE: 401' --header 'X-ECHO-BODY: Oups' $ECHO_HOST
➜ curl "$ECHO_HOST/?echo_body=Oups&echo_code=401"
➜ curl --header 'X-ECHO-CODE: 401' --header 'X-ECHO-BODY: Oups' localhost:8080
➜ curl "localhost:8080/?echo_body=Oups&echo_code=401"

HTTP/1.1 401 Unauthorized
"Oups"
```

## <a name='ChangedefaultQueriesRequestcommands'></a>Change default Queries/Request commands

[Read the docs](https://ealenn.github.io/Echo-Server/pages/configuration/commands.html)

| Environment | CLI | Default |
|------------------------------------|------------------------------------|--------------------|
| COMMANDS__HTTPBODY__QUERY | --commands:httpBody:query | `echo_body` |
Expand All @@ -234,49 +236,105 @@ HTTP/1.1 401 Unauthorized
| COMMANDS__FILE__QUERY | --commands:file:query | `echo_file` |
| COMMANDS__FILE__HEADER | --commands:file:header | `x-echo-file` |

## <a name='Loggers'></a>Loggers

[Read the docs](https://ealenn.github.io/Echo-Server/pages/configuration/loggers.html)

| Environment | CLI | Default |
|------------------------------------|------------------------------------|--------------------|
| LOGS__APP | --logs:app | `echo-server` |
| LOGS__LEVEL | --logs:level | `debug` |

### <a name='Seq'></a>Seq

![seq](https://ealenn.github.io/Echo-Server/assets/images/seq.png)

| Environment | CLI | Default |
|------------------------------------|------------------------------------|--------------------|
| LOGS__SEQ__ENABLED | --logs:seq:enabled | `false` |
| LOGS__SEQ__SERVER | --logs:seq:server | ` ` |
| LOGS__SEQ__KEY | --logs:seq:key | ` ` |
| LOGS__SEQ__LEVEL | --logs:seq:level | `info` |

## <a name='Settingup'></a>Setting up

### <a name='Docker'></a>Docker

[Read the docs](https://ealenn.github.io/Echo-Server/pages/docker.html)
[Read the docs](https://ealenn.github.io/Echo-Server/pages/quick-start/docker.html)

```bash
docker run -p 3000:80 ealen/echo-server
docker run -p 8080:80 ealen/echo-server
```

### <a name='Docker-Compose'></a>Docker-Compose

[Read the docs](https://ealenn.github.io/Echo-Server/pages/docker-compose.html)
[Read the docs](https://ealenn.github.io/Echo-Server/pages/quick-start/docker-compose.html)

**Sample**

```yaml
version: '3'
version: "3"
services:
echo-server:
image: ealen/echo-server:latest
environment:
- ENABLE__ENVIRONMENT=false
image: ealen/echo-server
ports:
- 8080:80
```
**With Seq**
```yaml
version: "3"

services:
echo:
image: ealen/echo-server
environment:
PORT: 80
LOGS__SEQ__ENABLED: "true"
LOGS__SEQ__SERVER: "http://seq:5341"
ports:
- 8080:80

seq:
image: datalust/seq
environment:
ACCEPT_EULA: "Y"
ports:
- 3000:80
- 3010:80
```
### <a name='Kubernetes'></a>Kubernetes
[Read the docs](https://ealenn.github.io/Echo-Server/pages/kubernetes.html)
[Read the docs](https://ealenn.github.io/Echo-Server/pages/quick-start/kubernetes.html)
```bash
curl -sL https://raw.githubusercontent.com/Ealenn/Echo-Server/master/docs/examples/echo.kube.yaml | kubectl apply -f -
```

### <a name='KuberneteswithHelm'></a>Kubernetes with Helm

[Read the docs](https://ealenn.github.io/Echo-Server/pages/helm.html) - [Helm Hub](https://hub.helm.sh/charts/ealenn/echo-server)
[Read the docs](https://ealenn.github.io/Echo-Server/pages/quick-start/helm.html) - [Helm Hub](https://hub.helm.sh/charts/ealenn/echo-server)

```bash
helm repo add ealenn https://ealenn.github.io/charts
helm repo update
helm install --set ingress.enable=true --name echoserver ealenn/echo-server
```

### <a name='NodeJS'></a>NodeJS

[Read the docs](https://ealenn.github.io/Echo-Server/pages/quick-start/nodejs)

```bash
# Dependencies
npm install
# Run with node
node ./src/webserver --port 8080
# Run with npm script
PORT=8080 npm run start
```

---

## <a name='Contributing'></a>Contributing
Expand All @@ -290,29 +348,23 @@ For the versions available, see the [tags on this repository](https://github.com

## <a name='License'></a>License

This project is licensed under the GNU Lesser General Public License - see the [LICENSE.md](LICENSE.md) file for details.
This project is licensed under the GNU Lesser General Public License - see the [LICENSE.txt](https://github.com/Ealenn/Echo-Server/blob/master/LICENSE.txt) file for details.

---

## <a name='Localdevelopment'></a>Local development

### <a name='RunEcho-Server'></a>Run Echo-Server
## <a name='Development'></a>Development

```bash
npm install
node ./src/webserver --port 3000
# OR
PORT=3000 npm run start
```
### <a name='Documentation'></a>Documentation

### <a name='Rundocumentationserver'></a>Run documentation server
Docker-Compose is available on `./docs` folder.

```bash
cd ./docs
docker compose up
docker compose up -d
```

### <a name='Runtests'></a>Run tests
The documentation is here [localhost:4000](http://localhost:4000)

### <a name='Tests'></a>Tests

```bash
npm install
Expand Down
Loading

0 comments on commit 0ae2d43

Please sign in to comment.