express-mongoose-es6-rest-api 0,1,8,2,4,0 codeclimate editorconfig eslint travis-ci npm

:collision: A boilerplate application for building RESTful APIs Microservice in Node.js using express and mongoose in ES6 with code coverage and JsonWebToken Authentication

Express & mongoose REST API Boilerplate in ES6 with Code Coverage Awesome

Build Status Coverage Status Code Climate bitHound Overall Score bitHound Dependencies Commitizen friendly MIT License PRs Welcome

Express ES6 REST API Starter


This is a boilerplate application for building REST APIs in Node.js using ES6 and Express with Code Coverage and JWT Authentication. Helps you stay productive by following best practices. Follows Airbnb’s Javascript style guide.

Heavily inspired from - How to Write an Open Source JavaScript Library.


Feature Summary
ES6 via Babel ES6 support using Babel.
Authentication via JsonWebToken Supports authentication using jsonwebtoken.
Code Linting JavaScript code linting is done using ESLint - a pluggable linter tool for identifying and reporting on patterns in JavaScript. Uses ESLint with eslint-config-airbnb, which tries to follow the Airbnb JavaScript style guide.
Auto server restart Restart the server using nodemon in real-time anytime an edit is made, with babel compilation and eslint.
ES6 Code Coverage via istanbul Supports code coverage of ES6 code using istanbul and mocha. Code coverage reports are saved in coverage/ directory post npm test execution. Open coverage/lcov-report/index.html to view coverage report. npm test also displays code coverage summary on console. Code coverage can also be enforced overall and per file as well, configured via .istanbul.yml
Debugging via debug Instead of inserting and deleting console.log you can replace it with the debug function and just leave it there. You can then selectively debug portions of your code by setting DEBUG env variable. If DEBUG env variable is not set, nothing is displayed to the console.
Promisified Code via bluebird We love promise, don’t we ? All our code is promisified and even so our tests via supertest-as-promised.
API parameter validation via express-validation Validate body, params, query, headers and cookies of a request (via middleware) and return a response with errors; if any of the configured validation rules fail. You won’t anymore need to make your route handler dirty with such validations.
Pre-commit hooks Runs lint and tests before any commit is made locally, making sure that only tested and quality code is committed
Secure app via helmet Helmet helps secure Express apps by setting various HTTP headers.
  • CORS support via cors
  • Uses http-status to set http status code. It is recommended to use httpStatus.INTERNAL_SERVER_ERROR instead of directly using 500 when setting status code.
  • Has .editorconfig which helps developers define and maintain consistent coding styles between different editors and IDEs.

Getting Started

Clone the repo:

git clone [email protected]:KunalKapadia/express-mongoose-es6-rest-api.git
cd express-mongoose-es6-rest-api

Install dependencies:

npm install

Start server:

# set DEBUG env variable to get debug logs
DEBUG=express-mongoose-es6-rest-api:* npm start
# OR
# requires gulp to be installed globally
npm i -g gulp
gulp serve

Execute tests:

# Run tests written in ES6 along with code coverage
npm test

# Run tests on file change
npm run test:watch

# Run tests enforcing code coverage (configured via .istanbul.yml)
npm run test:check-coverage

Other gulp tasks:

# Wipe out dist and coverage directory
gulp clean

# Lint code with ESLint
npm run lint
npm run lint:watch

# Default task: Wipes out dist and coverage directory. Compiles using babel.
# compile to ES5
1. npm run build or gulp

# upload dist/ to your server
2. scp -rp dist/ [email protected]:/path

# install production dependencies only
3. npm i --production

# Use any process manager to start your services
4. pm2 start dist/index.js

In production you need to make sure your server is always up so you should ideally use any of the process manager recommended here. We recommend pm2 as it has several useful features like it can be configured to auto-start your services if system is rebooted.


Universal logging library winston is used for logging. It has support for multiple transports. A transport is essentially a storage device for your logs. Each instance of a winston logger can have multiple transports configured at different levels. For example, one may want error logs to be stored in a persistent remote location (like a database), but all logs output to the console or a local file. We just log to the console for simplicity, you can configure more transports as per your requirement.

API logging

Logs detailed info about each api request to console during development. Detailed API logging

Error logging

Logs stacktrace of error to console along with other details. You should ideally store all error messages persistently. Error logging

Code Coverage

Get code coverage summary on executing npm test Code Coverage Text Summary

npm test also generates HTML code coverage report in coverage/ directory. Open lcov-report/index.html to view it. Code coverage HTML report

A Boilerplate-only Option

If you would prefer not to use any of our tooling, delete the following files from the project: package.json, gulpfile.babel.js, .eslintrc and .travis.yml. You can now safely use the boilerplate with an alternative build-system or no build-system at all if you choose.

Docs and Recipes

  • Gulp recipes - the official Gulp recipes directory includes a comprehensive list of guides for different workflows you can add to your project.


Contributions, questions and comments are all welcome and encouraged. For code contributions submit a pull request with unit test.


Kunal Kapadia – @kunalkapadia12[email protected]

Related Repositories



:collision: A boilerplate application for building RESTful APIs Microservice in Node.js using express and mongoose in ES6 with code coverage and JsonWebToken Authentication ...



A Node.js RESTful API built with Babel, Express and Mongoose ...



Boilerplate for Node, ES6, Express, Mongoose and Passport ...



Rest api boilerplate with express mongoose and ES6 ...

Top Contributors

KunalKapadia greenkeeperio-bot ReadmeCritic rafaelhz maxsbelt laumair


package version
dev babel-cli 6.18.0
babel-core 6.18.0
babel-plugin-add-module-exports 0.2.1
babel-preset-es2015 6.16.0
babel-preset-stage-2 6.18.0
chai ^3.4.1
commitizen ^2.9.2
coveralls ^2.11.6
cross-env 3.1.3
cz-conventional-changelog 1.2.0
del ^2.2.0
eslint 3.16.1
eslint-config-airbnb-base 7.1.0
eslint-plugin-import 1.16.0
eslint-watch 2.1.14
gulp 3.9.1
gulp-babel 6.1.2
gulp-load-plugins ^1.2.0
gulp-newer ^1.1.0
gulp-nodemon ^2.0.6
gulp-sourcemaps ^1.6.0
gulp-util ^3.0.7
husky ^0.13.1
istanbul 1.1.0-alpha.1
mocha 3.2.0
run-sequence ^1.1.5
supertest 2.0.1
supertest-as-promised 4.0.2
validate-commit-msg ^2.6.1
bluebird 3.4.6
body-parser 1.15.2
compression 1.6.2
cookie-parser 1.4.3
cors 2.8.1
debug ^2.4.5
dotenv ^4.0.0
express 4.14.0
express-jwt 5.1.0
express-validation 1.0.1
express-winston 2.1.2
helmet 3.1.0
http-status ^0.2.0
joi 10.0.6
jsonwebtoken 7.1.9
method-override ^2.3.5
mongoose 4.7.4
morgan 1.7.0
winston 2.3.0


-   v2.0.0 zip tar
-   v1.2.0 zip tar
-   v1.1.0 zip tar
-   v1.0.1 zip tar
-   v1.0.0 zip tar
-   v0.8.0 zip tar
-   v0.7.0 zip tar
-   v0.6.0 zip tar
-   v0.2.0 zip tar