Skip to content

Instantly share code, notes, and snippets.

@sr
Created June 26, 2010 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sr/454318 to your computer and use it in GitHub Desktop.
Save sr/454318 to your computer and use it in GitHub Desktop.
Hoptoad middleware for Connect
var sys = require("sys"),
connect = require("connect"),
hoptoad = require("connectHoptoad");
module.exports = connect.createServer(
function (req, res) {
throw Error("fail")
},
hoptoad("SECRET", ["development"])
);
var Hoptoad = require("hoptoad-notifier").Hoptoad;
module.exports = function hoptoadNotifier (key, notify) {
var notify = notify || ["staging", "production"];
var env = process.connectEnv.name;
Hoptoad.key = key;
Hoptoad.environment = env
return function (err, req, res, next) {
if (notify.indexOf(env) >= 0) {
err.url = req.url;
err.action = req.method;
Hoptoad.notify(err);
}
next(err);
}
};
@tj
Copy link

tj commented Jun 26, 2010

:D sweet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment