-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathserver.js
More file actions
62 lines (50 loc) · 1.67 KB
/
server.js
File metadata and controls
62 lines (50 loc) · 1.67 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
const { loggingTransport } = require('@sentry-internal/node-integration-tests');
const Sentry = require('@sentry/node');
Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
// disable attaching headers to /test/* endpoints
tracePropagationTargets: [/^(?!.*test).*$/],
tracesSampleRate: 1.0,
transport: loggingTransport,
integrations: [
Sentry.httpIntegration({
ignoreIncomingRequestBody: url => {
if (url.includes('/test-post-ignore-body')) {
return true;
}
return false;
},
}),
],
});
// express must be required after Sentry is initialized
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const { startExpressServerAndSendPortToRunner } = require('@sentry-internal/node-integration-tests');
const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.text());
app.use(bodyParser.raw());
app.get('/test/express', (_req, res) => {
res.send({ response: 'response 1' });
});
app.get(/\/test\/regex/, (_req, res) => {
res.send({ response: 'response 2' });
});
app.get(['/test/array1', /\/test\/array[2-9]/], (_req, res) => {
res.send({ response: 'response 3' });
});
app.get(['/test/arr/:id', /\/test\/arr[0-9]*\/required(path)?(\/optionalPath)?\/(lastParam)?/], (_req, res) => {
res.send({ response: 'response 4' });
});
app.post('/test-post', function (req, res) {
res.send({ status: 'ok', body: req.body });
});
app.post('/test-post-ignore-body', function (req, res) {
res.send({ status: 'ok', body: req.body });
});
Sentry.setupExpressErrorHandler(app);
startExpressServerAndSendPortToRunner(app);