Node API Boilerplate can be used to start a new NodeJS MongoDB based backend REST API project. This is best suitable for small microservices as well as large scale monolith API
- Install NodeJS. Recommended to use NVM
- Install MongoDB for Backend DB
- Install ElasticSearch (ELK) for Logging. The recommended way to do is using docker. Follow these steps for installing on local
Use the node package manager npm to install a boilerplate.
git clone git@github.com:darshitvvora/node-api-boilerplate.git
# Create .env and add config
cp sample.env .env
npm i
npm run migrate
npm start
- Add resource and corresponding rest API using below steps
- To create API, you will have to focus only on src/api folder
- Make sure to use REST resource structure standards and add standard API
- Add route in
index.js
of resource folder - Add model as per backend table structure in
.model.js
(Use sample user resource for reference) - Use the
.controller.js
to call logical function - Add pure logical function code in
.service.js
- Add fanout service in
.hookshot.js
file - Add common function model-specific function as class methods in
.model.js
- Use the below steps to commit and push the code to your repo
- Stage the files to be committed
git add .
- Commit file, fix any errors reported, and add a proper commit message. Use
.gitmessage
file for commit message guidelinesgit commit
- Push file and create PR
git push
- Folder structure
- Express configuration
- MongoDB integration
- Mongoose ORM integration
- Helmet and other security middleware integration
- Code Quality and sanity workflow integration (editorconfig, eslint, prettier, husky, commitizen, buddy.js)
- ELK logger component integration
- Unit Testing integration (Chai + Mocha)
- JSDoc integration
- Docker integration
- Sentry intergration
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to write proper commit message and test before raising a PR