Based on https://github.com/vmasto/express-babel: Express.js with Babel Boilerplate.
Using TSOA Routing https://github.com/lukeautry/tsoa.
Deployed on Heroku
You could install Postgres directrly on your computer, or install Docker and then use the docker-compose
to run the container:
docker-compose up
# shutdown the container
docker-compose down
Copy .env.example
into .env
and update the variables to match your environment, or define local variable named DATABASE_URL of the form postgres://user:pass@localhost:5432/bots_db
Install locally:
-
Create Database and User:
$ psql postgres CREATE ROLE bots WITH LOGIN PASSWORD 'yourpass'; ALTER ROLE bots CREATEDB; $ psql postgres -U bots CREATE DATABASE bots_db; GRANT ALL PRIVILEGES ON DATABASE bots_db TO bots;
-
Run migrations to create tables:
npm run migrate # to revert the last migration npm run migrate:revert
enter in command line:
npm i
DATABASE_URL='postgres://user:pass@localhost:5432/bots_db'
npm run start
read swagger.yaml file.
The reports go to user_statuses
table.
And the reporters API key checks against reporters
table.
environment variables:
DATABASE_URL
DB URI.PORT
HTTP Port. (default 8080).REQUESTS_LIMIT
Maximum requests in 10 minutes window per IP. (default 1000).USERS_CACHE_TTL
Liveness of a user status cache, in seconds. (default 1 second).USERS_CACHE_CHECK_PERIOD
Interval of cache liveness check. (default 0).JWT_SECRET
JWT private stamp key. (default random).JWT_EXPIRES_IN
The JWT token liveness time duration. (default 2 days).