node-server-example

Stars
0
Committers
1

Node server example

Run

In order to run the app one needs to set env variables:

SERVICE_PORT=
HEALTHCHECK_PORT=

start:

node index.js

expected format:

{
    "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:

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:

docker build -t <your username>/node-web-app .

running the app:

docker run -p 8080:8080 -p 8888:8888 --env SERVICE_PORT=8080 --env HEALTHCHECK_PORT=8888 -d <your username>/node-web-app

compute the result:

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

npm test