-
Notifications
You must be signed in to change notification settings - Fork 139
/
app.js
30 lines (23 loc) · 902 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');
const airbrakeExpress = require('airbrake/dist/instrumentation/express');
const app = express();
const airbrake = new AirbrakeClient({
projectId: process.env.PORT.AIBRAKE_PROJECT_ID,
projectKey: process.env.PORT.AIBRAKE_PROJECT_KEY,
});
// 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!');
});