smart-house-backend
v1.16.0
Published
Smart House BE
Downloads
94
Readme
Commands
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
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 test
npm test
also generates HTML code coverage report in coverage/
directory. Open lcov-report/index.html
to view it.