A RESTful API using:
- Express
- Mongoose
- ES6
- Jest for tests and coverage
- JsonWebToken authentication
First, clone the repo then install dependencies.
$ npm install -g yarn
$ yarn
Configure local environment variables
$ cp .env.sample .env
Update .env
Install the MongoDB Binaries
$ brew install mongodb
Add the following entry to /etc/hosts file
127.0.0.1 docker.for.mac.localhost
Run MongoDB Replicaset
$ cd mongo && ./setup
inside the mongo console run this:
rs.initiate({_id:"rs0", members: [{_id:0, host:"docker.for.mac.localhost:27017", priority:100}, {_id:1, host:"docker.for.mac.localhost:27018", priority:50}]})
check the status
rs.status();
$ yarn start
To use logging
$ yarn start:debug
To log nock calls
DEBUG=nock.interceptor yarn start
To log agenda calls
DEBUG=agenda:job yarn start
To log both use a comma separated set of debug targets
Run tests along with code coverage
$ yarn test
Run tests on file change
$ yarn test:watch
Lint code with ESLint
$ yarn lint
Run lint on file change
$ yarn lint:watch
Wipe out dist and coverage directory
$ gulp clean
Install husky using yarn
$ yarn add --dev husky --force
http://host/swagger.json
Run this command to load the results from json files in /path/to/folder
$ yarn results:load --folder=/path/to/folder --username=<username> --password=<password> --basePath=<apiBasePath>
Add your aws keys as environment variables.
AWS_ACCESS_KEY_ID = [your access key id]
AWS_SECRET_ACCESS_KEY = [your secret access key]
AWS_SESSION_TOKEN (optional) = [your session token]
Some useful documents for managing the queues in a js application:
https://github.com/chilts/mongodb-queue
https://ifelse.io/2016/02/23/using-node-redis-and-kue-for-priority-job-processing/