- body-parser to use json on body and responses
- chai for testing
- chai-http for http testing
- config to provide config file for api
- express because express ;)
- jsonwebtoken for generating json web token
- mocha for testing stack
- mongoose to abstract mongo manipulations
- mongoose-paginate-v2 to add pagination on all requests
- morgan to have, because log is life, and we love our Devops
- nodemon to increase the productivity
- passport for authentification
- passport-jwt for authentification WITH jwt
- swagger-ui-express to provide documentation of the api routes
To start the api, simply do a npm install and npm start.
We used Nodemon to refresh the work all time you edit files.
You can config your environment on the config/default.json file.
Deployement config following two steps:
- duplicate
config/env.json.disttoconfig/env.jsonand adapt it with the related env. configs - Uncomment
line 2onindex.jsand use the same name of the env.
e.g. if file for env is production.json, use process.env.NODE_ENV = 'production'
To start working well, keep in mind to import fixtures located on myFonciaBdd into MongoDB database:
mongorestore -d <database_name> <directory_backup>e.g. mongorestore -d myFonciaBdd ./myFonciaBdd
if you prefered to use a graphical tool, you can simply import data with MongoDB Compass
To test, use npm test. All routes are tested with Chai/Chai-http and runned under Mocha.
If you need to add more tests, use the same feature file name, in testfolder.
The api is documented with swagger, and you can access to the doc through the link http://localhost:3000/api-doc.
To edit the doc, use the swagger.json file on the root of project.
index.jsis the root project file- each routes are scoped into features, in
featuresfolder - tests are in the
testfolder - configurations for api are on
configfolder myFonciaBddfolder contain fixtures (bson & json format)schemafolder contain all Mongoose schema