/node-boilerplate

Node.js Backend API Boilerplate

Primary LanguageJavaScript

Node.js Boilerplate

Simple Node.js Boilerplate for simple Node.js Applications. Inspired by Kunal Kapadia's express-mongoose-es6-rest-api.

Build Status Commitizen friendly

A boilerplate for building applications in Node.js using ES6 with Code Coverage. Follows Airbnb's Javascript Style Guide.

Features

Feature
ES6 using Babel
Run tests using Mocha
Code linting using ESLint
Automatic syntax formatting using prettier
Auto-restart server using nodemon
Logging using debug
HTTP access control using cors
API parameter validation using express-validation
Code coverage using istanbul
HTTP status code and message http-status
Consistent commit syntax using commitizen and AngularJS's commit message convention
Precommit hook by running the linter and code coverage tool
Authentication using Passport.js and JSON Web Tokens
Password hashing using bcryptjs
Object Data Modeling (ODM) using mongoose

Installing / Getting started

Clone the repository and name it as you like.

git clone https://github.com/septa97/node-boilerplate.git <your-project-name>
cd your-project-name/
rm -rf .git/ && git init
git remote add origin https://github.com/<USERNAME>/<REPOSITORY>.git
npm run --silent create
cp .env.example .env
rm README.md
mv README.sample.md README.md
npm install

Then fill up the prompt for modifying the package.json.

You must delete the .git folder and re-initialize it using git init.

You must also create a new README.md. Open the new README.md then modify it depending on your project.

The above code installs the dependencies, creates an environment file, and modifies the package.json file.

Developing the application

To start developing with code linter,

npm run dev

Making a commit

To safely follow the standards of a commit,

npm run cm

then follow the instructions.

Tests

To run tests,

npm run test