Skip to content

Ready to use NodeJS Restful API boilerplate with mongoDB and mongoose ORM integration

License

Notifications You must be signed in to change notification settings

darshitvvora/node-api-mongo-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS REST API BoilerPlate

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

Technologies Used

Pre Requisite

  • 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

Installation

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

Usage

  • 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 guidelines
      git commit
  • Push file and create PR
      git push

Roadmap

  • 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

Coding Guidelines

Contributing

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

References

License

MIT