Skip to content

ddjnw1yu/12-labours-nodejs-api

 
 

Repository files navigation

12-labours-nodejs-api

Database Setup

PostgreSQL is used on our database setup, it is recommended for the developers to have some basic knowledge with PostgreSQL and psql before setting up the database.

The following commands may vary depending on the operating system and shells used.

#Setup a new 12-labours user on the PostgreSQL database
$ sudo su - postgres
$ createuser --interactive --pwprompt
$ 12-labours

#Create database with postgres account create.sql
$ psql -U postgres postgres -f ./db_setup/create.sql

#Create tables:
$ psql -U 12-labours -d 12labours -W -f ./db_setup/createTable.sql

#Setup initial data:
$ psql -U 12-labours -d 12labours -W -f ./db_setup/dataSetup.sql

Envionment variables

Here is the list of environment variables. The local sign up and login should work without GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET

#The following indicates which portal the api services should be deployed on
LOGIN_API_PORT="8080"
#An API Key to protect the server, this variable is required and
#should be the same when starting the api and app server
LOGIN_API_KEY="SomeAPIKey"
#A secret phase of your own choosing
LOGIN_SECRET_KEY="SomeSecretKey"

#Database server host
DB_HOST="localhost"
#Database server port
DB_PORT="5432"
#Database user name
DB_USER="12labours"
#Password of the DB_USER
DB_PASSWORD="SomePassword"
#Name for the database
DB_NAME="12labours"

#The following should point to the verify page on the portal
USER_VERIFY_URL="{PORTAL URL}/verify"
#Google authentication will redirect the user to the following page.
#This need to be setup on google for it to work
GOOGLE_REDIRECT_URI="{PORTAL URL}/login/callback"
PASSWORD_RESET_URL="{PORTAL URL}/password-reset"

#The following is the client id and secret from google.They are provided from the Credentials setup on Google Cloud. They are used for google login
GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""
#Sendgrid email notification keys and sender email address
SENDGRID_API_KEY=""
SENDGRID_VERIFIED_SENDER=""

Starting up the server

#Install required npm packages
$ npm install

#Start the server
$ npm run start

#Start the server in debug mode
$ npm run dev

About

12-labours API with NodeJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.8%
  • Dockerfile 0.2%