-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
37 lines (28 loc) · 954 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var express = require('express');
var bodyParser = require('body-parser')
var Honeybadger = require('@honeybadger-io/js');
Honeybadger.configure({
apiKey: process.env.HONEYBADGER_API_KEY,
environment: process.env.HONEYBADGER_ENV
});
var app = express();
app.set('port', (process.env.PORT || 3000));
app.use(Honeybadger.requestHandler);
app.use(bodyParser.urlencoded({ extended: false }));
app.get('/', function (req, res) {
res.send('Looking to <a href="/fail?foo=bar&bar=baz">fail?</a>');
});
app.all('/fail', function (req, res) {
Honeybadger.setContext({
func: function() {},
date: new Date(),
user_id: '123',
user_email: '[email protected]',
user_url: 'http://www.example.com/admin/user/123'
});
throw(new Error('This is a runtime error generated by the crywolf app.'));
});
app.listen(app.get('port'), function () {
console.log('Example app listening on port 3000!');
});
app.use(Honeybadger.errorHandler);