Skip to content

A Boilerplate for developing Rest api's in Node.js using express with support for ES6,ES7,ES8 ,Mongoose,JWT for authentication,Standardjs for linting

Notifications You must be signed in to change notification settings

vibhasfl/express-mongoose-es8-rest-api

Repository files navigation

express-mongoose-es8-rest-api

Description

Nodejs boilerplate with express,Mongoose,Mysql,JWT,ES6,ES7,ES8 support to develop REST api

specification node version express mongoose jsonwebtoken mysql code style Dependencies

Features

  • ES6,ES7,ES8 supported via babel 7.*
  • Authentication via JWT with dynamic secret per user
  • Jwt middleware for authenticated routes management
  • Request validation using joi
  • async-await with single try catch throughout routes using asyncWrapper
  • Code linting using standard and pre commit git hooks using husky
  • Integration test using mocha,chai,chai-http
  • Auto server start using nodemon
  • uses yarn over npm
  • Application level errorHandler
  • Manage enviroment via dotenv
  • Code coverage with istanbul
  • uses helmet to secure api endpoints which adds necessary security headers
  • Added support for databases like mysql and mongoDB with async await
  • Flexible fileupload with disk and S3 storage using multer and multer-s3

Getting Started

  1. Clone repository
> git clone https://github.com/vibhasfl/express-mongoose-es8-rest-api.git 
> cd express-mongoose-es8-rest-api
  1. Install yarn
> npm i -g yarn 
  1. Install project dependencies
> yarn
  1. Set enviroment variables
> cp .env.sample .env
  1. Run application
> yarn dev OR npm run dev
  1. Run tests
> yarn test
  1. Generate coverage report
> yarn test:coverage

Note : Open coverage/lcov-report/index.html

Running with docker

> yarn build 
> docker-compose build
> docker-compose up

Note : Make sure docker is being installed first