-
-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (29 loc) · 744 Bytes
/
index.js
File metadata and controls
33 lines (29 loc) · 744 Bytes
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
import * as Sentry from '@sentry/node'
import { App } from '@tinyhttp/app'
const app = new App({
onError: (err, req, res, next) => {
Sentry.expressErrorHandler()(err, req, res, next ? next : () => {})
res.status(500).send('Internal server error')
}
})
app.get('/', () => {
throw new Error('Oh no, an unexpected error!')
})
app.get('/page/:page/', (req, res) => {
Sentry.startSpan(
{
name: 'someCoolTask',
op: 'cool.task'
},
() => {
res.status(200).send(`
<h1>Some cool page</h1>
<h2>URL</h2>
${req.url}
<h2>Params</h2>
${JSON.stringify(req.params, null, 2)}
`)
}
)
})
app.listen(3000, () => console.log('Listening on http://localhost:3000'))