zuant_back_end v1.4.0
Zuant Backend
Installation
Installing and deploying the Zuant Backend app:
Node install
Install NodeJS v10 and install the application dependencies:
npm install
Create a .env file with the settings for the environment into which you are deploying the application. You can use the .env-sample file as a starting point:
cp .env-sample .env
Currently used ENV settings:
HOST // e.g. localhost
PORT // the port to which the Express app should bind
Start the application
To run in dev mode (i.e. with server refresh on code change):
npm run dev
Otherwise, just point node at the entrypoint:
node .
Tests
Run unit tests:
npm run test:unit
Run API integration tests:
// after starting the application:
npm run test:integration
Run all tests:
npm t
Run specific tests:
npm run test:integration -- --grep <string or pattern>
npm run test:unit -- --grep <string or pattern>
Coverage
After running tests, Unit test coverage reports will be located at ./coverage/unit
Running ngrok to expose project to the www
open a terminal window and type
ngrok http -subdomain=zuantdev https://devcloud.zuant.com:3000
Open a browser window to localhost:4040 to see the ngrok dashboard if you wish
Mailgun Webhook address for ngrok (locally running server)
https://zuantdev.ngrok.io/api/webhooks
Updating an accounts permissions for all users
check in task-breakdown file that the correct clients collection is used ensure you are running regular http in index.js (tests dont run under https)
npm run test:integration -- --grep @updatePermissions
Deploying to AWS
this command deploys the project to elastic beanstalk instance in AWS
eb deploy
Adding IP to mongo ACL
Open a Terminal window, then use the commands below: ENTER COMMAND BELOW TO GET AUTH TOKEN curl 'https://sjc-api.objectrocket.com/v2/tokens/' --user 'daveh@zuant.com'
YOU SHOULD RECEIVE SOMETHING LIKE THIS: {"data": {"token": "IjQ2NzViODExYjBmOTQ1Y2fasdfaadsfwMmJhIg.DiC4eQ.AKqDbHgaZhCaPxr9usEoUa2tk2c", "login": "dhickson", "uid": "5269406ac3fbcc655aa9c534"}}
NOW PASTE THE TOKEN AND CORRECT IP INTO THE COMMAND BELOW AND ISSUE THE COMMAND FROM TERMINAL curl --header "Content-Type: application/json" --header "X-Auth-Token: ImQwNDVhODI1M2FhMTQ0ODE4ZTI1NTQwNDViZDZlYmZlIg.EMrM6Q.N4Sm8oE2PRUuGueGhtS0rCwURCg" --request POST --data '{"cidr_mask":"143.159.164.229","description":"DB home 04Dec19"}' https://sjc-api.objectrocket.com/v2/instances/rs_production/acls/
TO GET A LIST OF THE CURRENT ACL ENTRIES FOR AN INSTANCE: curl --header "Content-Type: application/json" --header "X-Auth-Token: IjUyYzQxMWZhMzJjZDwertwertww.aJNU7iWUIaysedTIosP5I0iw_Aw" --request GET https://sjc-api.objectrocket.com/v2/instances/rs_production/acls/
4 years ago