Skip to content

Standardized template for SmokeTrees node.js projects.

License

Notifications You must be signed in to change notification settings

smoke-trees/nodejs-backend-template

Repository files navigation

Template by SmokeTrees

Standard template used at SmokeTrees for REST APIs written in NodeJS.

codecov

Running the server

$ npm start

Note: This will run a server in the development environment. For information on deploying an express application to production and learn best practices, take a look here.

Logging

This directory has 2 files.

  • logger.js exports a winston object which we use for logging. You should modify logger.js to customize your logging configuration.
  • morgan.js exports a pre-configured morgan object to write logs using a stream to winston. It is used to intercept http requests 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 needs more explanation.

Additional Information

  • On Linux, UNIX and Mac, running the following command adds ./node_modules/.bin to the path.

    source ./activate

    This makes it easier to run locally installed command packages. This won't be required in many IDEs like Webstorm, but we thought it's a good idea to include it anyway.

  • standard.js has been added as the default linting and styling tool

    Use :

    npm run lint

    Formats the entire project, and logs out anything it couldn't fix.

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

    Use:

    npm test
  • nyc is used as the default coverage tool. Use:

    npm run coverage
  • The master branch ships code for a http server. Checkout the https branch for the https server. Replace the self-signed certificates in the certs with your own SSL certificates.

Dependencies

Dependency Usage
body-parser POST body parsing middleware. Adds body object to incoming request
compression Response compression middleware
express Express REST API framework
cors CORS middleware to set CORS policy
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

About

Standardized template for SmokeTrees node.js projects.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published