The documentation was generated using Postman and is divided into collections at the following URLs:
# Clone this repo to your local machine using
git clone https://github.com/cyntaria/UniPal-Backend
# Get into the directory
cd UniPal-Backend
# Make it your own
rm -rf .git && git init (For Linux/MacOS)
rm .git -r -fo; git init (For Windows PowerShell)
# Copy example.env and create your own .env file in envs folder
cp .env.example envs/.env
# Move into the envs dir
cd envs
# Edit .env file and add your mysql username, password and db name, host,
# port, jwt_secret
vscode .env
# Create different .env.{NODE_ENV} file for each environment and override only your
# required variables. The missing ones will be loaded from .env by default.
# For example if you want dev, production and test environments:
cp .env .env.dev
cp .env.dev .env.production
cp .evn.dev .env.test
# When the NODE_ENV variable is set while running, the correct .env loads automatically.
# e.g. Setting NODE_ENV=production is going to load the .env.production file
# Add a gitignore to ignore node_modules and your .env file
echo -e 'node_modules \n envs \n' >> .gitignore
# Install dependencies
npm install
# Run the server locally with default .env file
npm start
# Run the server in dev mode with nodemon with .env.dev file
npm run dev
# While deploying to production with .env.production file
npm run production
If you want to run the github testing and PR labelling workflows in the CI then:
Create the following repository secrets:
- DB_HOST: your_db_host (If using CI mysql service set to 127.0.0.1)
- DB_USER: your_db_user (If using CI mysql service set this to 'root')
- DB_PASS: your_db_password (If using CI mysql service set this to 'root')
- DB_TEST_DATABASE: your_test_database_name
- SENDGRID_API_KEY: value should be your .env file variable => sendgrid_api_key
- SENDGRID_SENDER: value should be your .env file variable => from_email
- SECRET_JWT: value should be your .env file variable => your_secret
- PRODUCTION_ENV: contents of the base
.env + .env.production
files - HEROKU_API_KEY: value for the heroku api key
- AZURE_PUBLISH_PROFILE: the contents of the downloaded publish profile from Azure
- WEBAPP_NAME: name of the deployed webapp, should match heroku/azure project name
- The
healthcheck
endpoint is to ensure the status of the API from the CI so we can be sure we are deploying a working API only. - If you add/remove/change the names of any folders/file extensions make sure to update the labeler.yml
Enjoy :)
Take the following steps to ensure security of configurations
# 1. Convert the envs folder to zip file
# 2. Encrypt it using gpg passphrase
gpg --output encrypted_envs.gpg --symmetric envs.rar
# 3. Decrypt it using gpg passphrase
gpg --output envs.rar --decrypt encrypted_envs.gpg
This example uses a number of open source projects to work properly:
- node.js
- express
- bcryptjs
- cors
- cross-env
- deep-email-validator
- dotenv-flow
- express-validator
- jsonwebtoken
- mysql2
- @babel/eslint-parser
- @babel/core
- mocha
- chai
- supertest
- sinon
- decache
- eslint-config-strongloop
- @sendgrid/mail
- otp-generator
UniPal-Backend Β© 2021 by Abdur Rafay Saleem is licensed under CC BY 4.0