38 lines
841 B
JavaScript
38 lines
841 B
JavaScript
const express = require('express')
|
|
const sentry = require('@sentry/node')
|
|
const tracing = require('@sentry/tracing')
|
|
const app = express()
|
|
|
|
const PORT = process.env.PORT || 3000
|
|
const SENTRY_DSN = process.env.SENTRY_DSN
|
|
|
|
sentry.init({
|
|
dsn: SENTRY_DSN,
|
|
tracesSampleRate: 1.0,
|
|
})
|
|
|
|
app.get('/hello', (req, res) => {
|
|
res.send('World')
|
|
})
|
|
|
|
app.get('/exception', (req, res) => {
|
|
try {
|
|
throw new Error('Something flew out of a window')
|
|
} catch(e) {
|
|
sentry.captureException(e)
|
|
res.status(500).end()
|
|
}
|
|
})
|
|
|
|
app.get('/uncaught-exception', (req, res) => {
|
|
throw new Error('Something flew out of a window')
|
|
})
|
|
|
|
app.get('/error-message', (req, res) => {
|
|
sentry.captureMessage('Something went wrong')
|
|
req.status(500).end()
|
|
})
|
|
|
|
app.listen(PORT, '0.0.0.0', () => {
|
|
console.log(`Server listening on http://0.0.0.0:${PORT}`)
|
|
})
|