1 | [![Build Status](https://travis-ci.org/garage-it/SmartHouse-backend.svg?branch=master)](https://travis-ci.org/garage-it/SmartHouse-backend)
|
2 | [![codecov.io](https://codecov.io/github/garage-it/SmartHouse-backend/coverage.svg?branch=master)](https://codecov.io/github/garage-it/SmartHouse-backend?branch=master)
|
3 | [![dependencies Status](https://david-dm.org/garage-it/SmartHouse-backend/status.svg)](https://david-dm.org/garage-it/SmartHouse-backend)
|
4 | [![devDependencies Status](https://david-dm.org/garage-it/SmartHouse-backend/dev-status.svg)](https://david-dm.org/garage-it/SmartHouse-backend?type=dev)
|
5 | [![npm version](https://badge.fury.io/js/smart-house-backend.svg)](https://badge.fury.io/js/smart-house-backend)
|
6 |
|
7 | ## Commands
|
8 |
|
9 | Install dependencies:
|
10 | ```sh
|
11 | npm install
|
12 | ```
|
13 |
|
14 | ### Start server:
|
15 | ```sh
|
16 | # set DEBUG env variable to get debug logs
|
17 | DEBUG=express-mongoose-es6-rest-api:* npm start
|
18 |
|
19 | # or without debug
|
20 | npm start
|
21 | ```
|
22 |
|
23 | ### Start server in production mode:
|
24 | ```sh
|
25 | # will run api backend
|
26 | npm run api
|
27 | ```
|
28 |
|
29 | ### Execute tests:
|
30 |
|
31 | ```sh
|
32 | # run unit and integration tests
|
33 | npm test
|
34 | ```
|
35 |
|
36 | ```sh
|
37 | # run all tests with coverage
|
38 | npm run test-coverage
|
39 | ```
|
40 |
|
41 | ```sh
|
42 | # run only unit tests
|
43 | npm run test:unit
|
44 |
|
45 | # watch mode
|
46 | npm run test-watch:unit
|
47 | ```
|
48 |
|
49 | ```sh
|
50 | # run only integration tests
|
51 | npm run test:integration
|
52 |
|
53 | # watch mode
|
54 | npm run test-watch:integration
|
55 | ```
|
56 |
|
57 |
|
58 | ### Other tasks:
|
59 | ```sh
|
60 | # Lint code with ESLint
|
61 | npm run lint
|
62 | ```
|
63 |
|
64 | ## Logging
|
65 |
|
66 | Universal logging library [winston](https://www.npmjs.com/package/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.
|
67 |
|
68 | #### API logging
|
69 | Logs detailed info about each api request to console during development.
|
70 | ![Detailed API logging](https://cloud.githubusercontent.com/assets/4172932/12563354/f0a4b558-c3cf-11e5-9d8c-66f7ca323eac.JPG)
|
71 |
|
72 | #### Error logging
|
73 | Logs stacktrace of error to console along with other details. You should ideally store all error messages persistently.
|
74 | ![Error logging](https://cloud.githubusercontent.com/assets/4172932/12563361/fb9ef108-c3cf-11e5-9a58-3c5c4936ae3e.JPG)
|
75 |
|
76 | ## Code Coverage
|
77 | Get code coverage summary on executing `npm test`
|
78 | ![Code Coverage Text Summary](https://cloud.githubusercontent.com/assets/4172932/12827832/a0531e70-cba7-11e5-9b7c-9e7f833d8f9f.JPG)
|
79 |
|
80 | `npm test` also generates HTML code coverage report in `coverage/` directory. Open `lcov-report/index.html` to view it.
|
81 | ![Code coverage HTML report](https://cloud.githubusercontent.com/assets/4172932/12625331/571a48fe-c559-11e5-8aa0-f9aacfb8c1cb.jpg)
|