1
0
Fork 0
This repository has been archived on 2025-08-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
trz-sentry-demo-legacy/app/server.js
2023-09-26 21:43:36 +00:00

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}`)
})