Skip to content
This repository was archived by the owner on May 16, 2022. It is now read-only.

Commit 43888cc

Browse files
committed
Add sentry error collection
1 parent 68f7acf commit 43888cc

File tree

3 files changed

+142
-4
lines changed

3 files changed

+142
-4
lines changed

package-lock.json

+132
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Switchblade API",
55
"main": "src/index.js",
66
"dependencies": {
7+
"@sentry/node": "^5.15.4",
78
"cors": "^2.8.5",
89
"express": "^4.17.1",
910
"morgan": "^1.10.0",

src/index.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
const express = require('express')
22
const cors = require('cors')
3+
const Sentry = require('@sentry/node')
4+
5+
Sentry.init({ dsn: process.env.SENTRY_DSN })
36

47
const app = express()
58

69
const PORT = process.env.PORT || 80
710

8-
// Routes
9-
const contributorsRoute = require('./routes/contributors')
11+
app.use(Sentry.Handlers.requestHandler())
1012

11-
// TODO: configure cors
13+
// TODO: Set up CORS
1214
app.use(cors())
1315

16+
const contributorsRoute = require('./routes/contributors')
1417
app.use(contributorsRoute())
15-
// TODO: morgan log
18+
// TODO: Add morgan logging
1619

1720
app.get('/', (req, res) => {
1821
res.json({ message: "Hello World" })
1922
})
2023

24+
app.use(Sentry.Handlers.errorHandler())
25+
2126
app.listen(PORT, () => {
2227
console.log(`Listening on port ${PORT}`)
2328
})

0 commit comments

Comments
 (0)