node package manager


Smart House BE

Build Status dependencies Status devDependencies Status npm version


Install dependencies:

npm install

Start server:

# set DEBUG env variable to get debug logs
DEBUG=express-mongoose-es6-rest-api:* npm start

# or without debug
npm start

Start server in production mode:

# will run api backend
npm run api

Execute tests:

# run unit and integration tests
npm test
# run all tests with coverage
npm run test-coverage
# run only unit tests
npm run test:unit
# watch mode
npm run test-watch:unit 
# run only integration tests
npm run test:integration
# watch mode
npm run test-watch:integration 

Other tasks:

# Lint code with ESLint
npm run lint


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