Node.js Application Template
Anshuman Chhapolia
Posted on April 9, 2020
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.
Dependency information
💖 💪 🙅 🚩
Anshuman Chhapolia
Posted on April 9, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.