Created
June 26, 2010 20:43
-
-
Save sr/454318 to your computer and use it in GitHub Desktop.
Hoptoad middleware for Connect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require("sys"), | |
connect = require("connect"), | |
hoptoad = require("connectHoptoad"); | |
module.exports = connect.createServer( | |
function (req, res) { | |
throw Error("fail") | |
}, | |
hoptoad("SECRET", ["development"]) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:D sweet