Almost direct copy from https://github.com/heroku/node-js-sample