/node-express-boilerplate

A small boilerplate to help you kickstart your projects with a template engine, unit tests, integration tests, code coverage, continuous integration, code analysis and automated npm publishing.

Primary LanguageHTMLMIT LicenseMIT

node-express-boilerplate

Build Status Coverage Status GitHub version

Yet another Node.js - Express boilerplate

This time with a template engine (Swig), Preact, unit tests, integration tests, code coverage, continuous integration, code analysis, code style and a nice setup flow.

Helper modules in use:

Jest A browser JavaScript testing toolkit. Jest is used by Facebook to test all JavaScript code including React applications. One of Jest's philosophies is to provide an integrated "zero-configuration" experience.

ESLint ESLint is a code style linter for programmatically enforcing your style guide.

Istanbul A Javascript code coverage tool written in JS.

Travis Travis CI is a hosted continuous integration service. It is integrated with GitHub and offers first class support for many languages.

Coveralls.io Coveralls is a web service to help you track your code coverage over time, and ensure that all your new code is fully covered.

Retire Scanner detecting the use of JavaScript libraries with known vulnerabilities.

Getting started

Prerequisite

$ npm install -g nodemon
$ npm install -g eslint

Clone repo and start server

To run the server in development mode:

$ git clone https://github.com/5orenso/node-express-boilerplate.git
$ cd node-express-boilerplate
$ npm install
$ npm run start

Now you can browse your shiny new webpage. Open your favorite browser and navigate to one of these pages:

This will restart the server every time a file has changed.

In addition to this I recommend using Grunt to watch your files and perform code analysis and run tests every time a file changes:

$ ./run-watch.sh

Now, go ahead and add modules into the ./app/routes/web.js or add more routes to the ./app/server.js file.

HOWTO check the test coverage

$ npm test
$ open coverage/lcov-report/index.html

HOWTO fix eslint issues

$ eslint --fix lib/utilities.js

Howto update NPM module

  1. Bump version inside package.json
  2. Push all changes to Github.
  3. Push all changes to npmjs.com: $ bash ./npm-release.sh.

Howto check for vulnerabilities in modules

# Install Node Security Platform CLI
$ npm install nsp --global  

# From inside your project directory
$ nsp check  

Howto upgrade modules

$ sudo npm install -g npm-check-updates
$ ncu -u -a
$ npm install --no-optional

Versioning

For transparency and insight into the release cycle, releases will be numbered with the follow format:

..

And constructed with the following guidelines:

  • Breaking backwards compatibility bumps the major
  • New additions without breaking backwards compatibility bumps the minor
  • Bug fixes and misc changes bump the patch

For more information on semantic versioning, please visit http://semver.org/.

Contributions and feedback:

We ❤️ contributions and feedback.

If you want to contribute, please check out the CONTRIBUTING.md file.

If you have any question or suggestion create an issue.

Bug reports should always be done with a new issue.

Other Resources