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.
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
# npm run semantic-release
Refer semantic-release to understand better the release process.
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.
Logs detailed info about each api request to console during development.
Logs stacktrace of error to console along with other details. You should ideally store all error messages persistently.
Get code coverage summary on executing npm run test