forked from airbrake/airbrake-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (23 loc) · 847 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
const express = require('express');
const AirbrakeClient = require('airbrake-js');
const airbrakeExpress = require('airbrake-js/dist/instrumentation/express');
const app = express();
const airbrake = new AirbrakeClient({
projectId: 123,
projectKey: 'FIXME',
});
// This middleware should be used before any routes are defined.
app.use(airbrakeExpress.makeMiddleware(airbrake));
app.get('/', function hello(req, res) {
throw new Error('hello from Express');
res.send('Hello World!');
});
app.get('/hello/:name', function hello(req, res) {
res.send(`Hello ${req.params.name}`);
});
// Error handler middleware should be the last one.
// See http://expressjs.com/en/guide/error-handling.html
app.use(airbrakeExpress.makeErrorHandler(airbrake));
app.listen(3000, function() {
console.log('Example app listening on port 3000!');
});