DEV Community 👩‍💻👨‍💻

Cover image for Node.js Application Template
Anshuman Chhapolia
Anshuman Chhapolia

Posted on • Updated on

Node.js Application Template

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.


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.


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.

  • mocha is used for testing and chai is used for assertion. chai-http is used to test http endpoints.


    $ 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

Dependency Usage
compression Compresses the response
express Express
morgan HTTP request logger
winston General purpose logger for the application
nyc Code Coverage tool
standard Linting and styling tool.
chai Assertion Library
chai-http Middleware for chai to test http endpoints

Top comments (4)

lineldcosta profile image

Why compression is used??? U can use nginx to achieve the same right?

achhapolia10 profile image
Anshuman Chhapolia

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.

johnmunsch profile image
John Munsch

You accidentally misspelled the URL above for the template repo. Here's the correct one:

achhapolia10 profile image
Anshuman Chhapolia

Thank you for pointing out the error.

Timeless DEV post...

How to write a kickass README

Arguably the single most important piece of documentation for any open source project is the README. A good README not only informs people what the project does and who it is for but also how they use and contribute to it.

If you write a README without sufficient explanation of what your project does or how people can use it then it pretty much defeats the purpose of being open source as other developers are less likely to engage with or contribute towards it.