- runs on node.js v10.16.3
- express 4+
- heroku
- eslint
- mongodb - docker image of mongodb
- POSTMAN chrome extension for verification
- Edit configuration in
config/default.json
and - custom environment variables names in
config/custom-environment-variables.json
, - for example it will read MONGODB_URI as url of database from heroku.
Following variables can be configured:
authSecret
the secret for authport
the port to listenlogLevel
the log leveldebug
orinfo
version
the version of apiMONGODB_URI
the mongo database. use "mongodb://0.0.0.0:27017/backend-api" when running api without docker. otherwise use "mongodb://mongo:27017/backend-api for docker api and db spin up
-
You will need to install Heroku Toolbelt for this step if you don't already have it installed.
-
In the main project folder, run the following commands:
heroku login git init git add . git commit -m "init" heroku create heroku addons:create mongolab:sandbox git push heroku master heroku logs -t heroku open
- Please make sure to configure url of database rightly in
config/default.json
or use environment variable MONGODB_URI. - mongo docker instance run : cd docker/mongo ->run docker-compose up
- set MONGODB_URI:"mongodb://0.0.0.0:27017/backend-api in default.json
- Install dependencies
npm i
- run lint check
npm run lint
- Start app
npm start
- Please make sure to configure url of database rightly in
config/default.json
or use environment variable MONGODB_URI. - mongo docker instance run : cd docker/mongo ->run docker-compose up
- set MONGODB_URI:"mongodb://mongo:27017/backend-api in default.json
- docker ps -a //to check already monogo instance is running
- docker stop containerid
- docker rm containerid
- docker-compose build --no-cache
- docker-compose up
- Load postman collection:
- endpoints: docs/api.postman_collection.json
- environment: docs/api.postman_environment.json
- use Authorization header Bearer {{user_token}}
- It will use passport and it could support social feature to login as twitter, facebook easily.
- It will use
src/app-passport.js
to load passport strategies in src/passports, you can defineauth:{name of passport strategy}
inroutes.js
of module. - You can also define
access:[role1,role2]
, the user role name is fromsrc/constants.js
. - It will check Authentication & Authorization in
src/app-routes.js
to secure the APIs.