This post discuss about the template we use at SmokeTrees.
To start the server run
$ npm start
Note: This will run a server for development environment.
For information on deploying express application to production server and learn best practices refer this.
logger
This directory has 2 files.
- logger.js exports a winston object which we use for logging. You should edit logger.js to write your config for the logs.
- morgan.js exports a pre-configured morgan object to log using stream to winston object. It is used to intercept the HTTP request and log the request and response details. For more details visit the official page for morgan.
routes
Directory for defining routes. I don't think this need more explanation.
Additional Information
- If on Linux running the following command add ./node_modules/.bin to the path.
$ source ./activate
By doing so we can use the commands installed with packages using the terminal.
This won't be required in many IDEs like Webstorm but I thought it will be a good idea to include it.
- standard.js has been added as the default linting and styling tool
Use :
$ npm run lint
Fixes whatever can be fixed. Above command logs out the errors which it couldn't fix.
Use:
$ npm test
- nyc is used as the default coverage tool. Use:
$ npm run coverage
- The master contains code for an HTTP server. Checkout the branch https for the HTTP server. Replace the self-signed certificates in the certs with your SSL certificates.
Top comments (4)
Why compression is used??? U can use nginx to achieve the same right?
Yes, nginx can be used to achieve the same. But I wanted to make this template as generic as possible. So if some project is not using nginx as reverse proxy it still has compression.
You accidentally misspelled the URL above for the template repo. Here's the correct one: github.com/smoke-trees/nodejs-back...
Thank you for pointing out the error.