https://github.com/ivanprodaiko94/node-server-example
https://github.com/ivanprodaiko94/node-server-example
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ivanprodaiko94/node-server-example
- Owner: IvanProdaiko94
- Created: 2019-09-18T19:39:52.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T18:41:35.000Z (over 3 years ago)
- Last Synced: 2025-07-11T11:25:20.520Z (11 months ago)
- Language: JavaScript
- Size: 97.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node server example
## Run
In order to run the app one needs to set env variables:
```.env
SERVICE_PORT=
HEALTHCHECK_PORT=
```
start:
```bash
node index.js
```
expected format:
```json
{
"timestamp": 1493758596,
"data": [
{ "title": "Part 1", "values": [0, 3, 5, 6, 2, 9] },
{ "title": "Part 2", "values": [6, 3, 1, 3, 9, 4] }
]
}
```
compute the result:
```bash
curl -d '{
"timestamp": 1493758596,
"data": [
{ "title": "Part 1", "values": [0, 3, 5, 6, 2, 9] },
{ "title": "Part 2", "values": [6, 3, 1, 3, 9, 4] }
]
}' -H "Content-Type: application/json" -X POST http://localhost:{port}/compute/{request_id}
```
## Run app in docker
building the app:
```bash
docker build -t /node-web-app .
```
running the app:
```bash
docker run -p 8080:8080 -p 8888:8888 --env SERVICE_PORT=8080 --env HEALTHCHECK_PORT=8888 -d /node-web-app
```
compute the result:
```bash
curl -d '{
"timestamp": 1493758596,
"data": [
{ "title": "Part 1", "values": [0, 3, 5, 6, 2, 9] },
{ "title": "Part 2", "values": [6, 3, 1, 3, 9, 4] }
]
}' -H "Content-Type: application/json" -X POST http://localhost:{port}/compute/{request_id}
```
## Run tests
```bash
npm test
```