Node API Boilerplate can be used to start a new NodeJS PostgresSQL 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 PostgresSQL 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 and properties as per backend table structure in
.model.js
and.properties.js
(Use sample user resource for reference) - Add migration if its a new folder. Migration will use
.properties.js
file - 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
- Postgres integration
- Sequelize ORM integration
- Sequelize Migration 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
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
- Angular Fullstack
- Sequelize ORM
- Node Webhooks
- Commitizen
- ESLint
- Git Commit guidelines
- buddy.js
- husky
- helmetjs
- winston
- winston-elasticsearch
- [jsdoc] (https://jsdoc.app/)
- [BDD and TDD Approach] - (https://medium.com/quick-code/using-mocha-for-test-driven-development-in-building-api-with-node-express-c9331cd6171f)