Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

PerfectWeek/web-api

Repository files navigation

Perfect Week Web API

Build Status

QuickStart

Retrieve nodejs dependencies

npm install

Set up the data-base

From the root of the repository, run the following commands:

./scripts/database_create.sh
docker start perfectweek-db
npm run migration-up

This will create a new docker container named perfectweek-db on your system.

Notes

  • If you shut down your computer or the container, you may need to run docker start perfectweek-db again to restart the container
  • If changes are made on the databse schema, you'll need to run npm run migration-up once again to update it

Start the API

You'll first need to set the following environment variables in order to start the API:

Variable name Description Default value
DB_HOST The hostname of the database 127.0.0.1
DB_PORT The port of the database 5432
DB_PASSWD The password to connect to the database lol
JWT_ENCODE_KEY A string that will be used to encode Json Web Token. Any string is fine secret

Additionally, you can set the following variables:

Variable name Description Default value
API_HOST The host url on which the API will be accessible 127.0.0.1
FRONTEND_HOST The host url on which the Frontend will be accessible 127.0.0.1
API_PORT The port on which the API will be accessible 3000
EMAIL_ENABLED If a value is set, emails will be sent when creating user. If not, the link will be in the answer (debug only) false
MG_API_KEY Mailgun Api Key (only if EMAIL_ENABLED is set to true) null
MG_API_DOMAIN Mailgun Api Domain (only if EMAIL_ENABLED is set to true) null

Once this is done, start the API with the following command

npm start

Documentation

The API documentation can be found on the documentation page