1.0.0 • Published 7 years ago

base_lib_express_es6 v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

boilerplate code to start a lib with express, mocha, istanbul and codecov

travis build codecov coverage

Overview

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 KunalKapadia - Express & mongoose REST API Boilerplate in ES6 with Code Coverage.

Getting Started

Clone the repo:

git clone https://github.com/igiagante/base_lib_express_es6.git
cd base_lib_express_es6

Install dependencies:

npm install

Set environment (vars):

cp .env.base .env

Start server:

# Start server
npm run start

Tests:

# Run unit tests 
npm run test

# Run all tests (integration & unit)
npm run all_tests

# Run coverage only for unit tests
npm run cover

# Run coverage for all the tests
npm run cover:all

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

Lint:

# Lint code with ESLint
npm run lint

# Fix your code with ESLint
npm run lint:clean
Deployment
# npm run semantic-release

Refer semantic-release to understand better the release process.

Logging

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.

Error logging

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

Code Coverage

Get code coverage summary on executing npm run test