node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



Boilerplate for an express web application

Build Status


  • Use clusters and domains to handle async errors in a configurable manner
  • Ensure uptime by automatically killing and restarting worker processes upon encountering an error
  • Allow full customization of logging and response sending
  • Minimal number of dependencies


  1. Add h2o as a dependency to your project’s package.json
  2. Run npm install

Usage Examples

See examples/ for express web applications built using h2o.


    .setAppDefiner(function(app) {...})
    .setErrorHandler(function(err, req, res, nextNotUsed) {...})

setAppDefiner (required)
Must be called with a function that defines the application. The provided function will be called with app provided.

setLogger (required)
Must be called with a logger object that implements info(message), warn(message), error(message), and fatal(message).

setErrorHandler (required)
Must be called with a function that handles any errors that occur. The provided function will be called with (err, req, res, nextNotUsed).

setPort (optional)
Can be called to port that the web application listens on. Defaults to 80.

setClusterUse (optional)
Can be called to set whether a cluster is used or not to. Using a cluster enables a worker process to restart if an error occurs. Defaults to true.

setNumWorkersInCluster (optional)
Can be called to set the number of workers to fork in the cluster. Defaults to the number of CPUs/cores.