Skip to content

Latest commit

 

History

History
94 lines (80 loc) · 3.76 KB

README.md

File metadata and controls

94 lines (80 loc) · 3.76 KB

NodeJS REST API BoilerPlate

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

Technologies Used

Pre Requisite

  • 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

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

Roadmap

  • 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

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