Skip to content

telemark/micro-stats

Repository files navigation

Build Status js-standard-style

micro-stats

Stats service

Setup

You'll need a database compatible with the MongoDB API.

If you are using CosmosDB your shard key has to be "system".

API

POST /stats/:system

Post stats for given system

$ curl -v -H "Authorization: INSERT-JWT-TOKEN" --header "Content-Type: application/json" http://localhost:3000/stats/minelev -d '{"queue": "10", "done": "42"}'

GET /stats/:system

Get stats for given system

$ curl -v http://localhost:3000/stats/minelev

Response

[
  {
    "_id": "5936af1637fcfde27cf42a75",
    "system": "minelev",
    "queue": "0",
    "done": "897"
  }
]

Development

Add local .env

MONGODB_CONNECTION=mongodb-connection-string
MONGODB_COLLECTION=mongodb-collection-name
MONGODB_NAME=mngodb-name
JWT_SECRET=jwt-secret

Start development environment

$ npm run dev

Deploy to ZEIT/Now - Manual

Configure now.json

Run the deployment script

$ npm run deploy

Deploy to ZEIT/Now - Automatic

Do a tagged release

License

MIT