mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-04-22 02:42:09 +00:00
chore: Add error handling directing to a Glitchtip server to log errors
Signed-off-by: Avior <github@avior.me>
This commit is contained in:
parent
0146765e7a
commit
e6a8c1dd71
@ -40,6 +40,11 @@ npm run build
|
||||
npm run start
|
||||
```
|
||||
|
||||
### Envs
|
||||
|
||||
you can add environment variables to add features to the server:
|
||||
- SENTRY_DSN: the DSN to a sentry compatible server to allow to catch errors
|
||||
|
||||
### Using Docker
|
||||
|
||||
Go to the parent directory and build the Dockerfile!
|
||||
|
BIN
server/bun.lockb
BIN
server/bun.lockb
Binary file not shown.
@ -12,6 +12,7 @@
|
||||
"dependencies": {
|
||||
"@dzeio/config": "^1",
|
||||
"@dzeio/object-util": "^1",
|
||||
"@sentry/node": "^7",
|
||||
"@tcgdex/sdk": "^2",
|
||||
"apicache": "^1",
|
||||
"express": "^4",
|
||||
|
@ -1,13 +1,24 @@
|
||||
import Sentry from '@sentry/node'
|
||||
import express from 'express'
|
||||
import jsonEndpoints from './V2/endpoints/jsonEndpoints'
|
||||
import graphql from './V2/graphql'
|
||||
import status from './status'
|
||||
|
||||
// Current API version
|
||||
const VERSION = 2
|
||||
|
||||
// Init Express server
|
||||
const server = express()
|
||||
|
||||
// allow to catch servers errors
|
||||
const sentryDSN = process.env.SENTRY_DSN
|
||||
|
||||
if (sentryDSN) {
|
||||
Sentry.init({ dsn: sentryDSN})
|
||||
|
||||
server.use(Sentry.Handlers.requestHandler())
|
||||
}
|
||||
|
||||
// Route logging / Error logging for debugging
|
||||
server.use((req, res, next) => {
|
||||
const now = new Date()
|
||||
@ -71,6 +82,10 @@ server.use(`/v${VERSION}`, jsonEndpoints)
|
||||
// Status page
|
||||
server.use('/status', status)
|
||||
|
||||
if (sentryDSN) {
|
||||
server.use(Sentry.Handlers.errorHandler())
|
||||
}
|
||||
|
||||
// Start server
|
||||
server.listen(3000)
|
||||
console.log(`🚀 Server ready at localhost:3000`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user