-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathserver.js
49 lines (37 loc) · 1.03 KB
/
server.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
38
39
40
41
42
43
44
45
46
47
48
49
const { loggingTransport } = require('@sentry-internal/node-integration-tests');
const Sentry = require('@sentry/node');
Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
transport: loggingTransport,
debug: true,
});
// express must be required after Sentry is initialized
const express = require('express');
const cors = require('cors');
const { startExpressServerAndSendPortToRunner } = require('@sentry-internal/node-integration-tests');
const app = express();
app.use(cors());
app.use((req, _res, next) => {
// We simulate this, which would in other cases be done by some middleware
req.user = {
id: '1',
email: '[email protected]',
};
next();
});
app.get('/test1', (_req, _res) => {
throw new Error('error_1');
});
app.use((_req, _res, next) => {
Sentry.setUser({
id: '2',
email: '[email protected]',
});
next();
});
app.get('/test2', (_req, _res) => {
throw new Error('error_2');
});
Sentry.setupExpressErrorHandler(app);
startExpressServerAndSendPortToRunner(app);