1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-04-22 10:52:10 +00:00

chore: Add error reporting (#617)

* chore: Add error reporting

Signed-off-by: Avior <git@avior.me>

* fix: test issues

Signed-off-by: Avior <git@avior.me>

---------

Signed-off-by: Avior <git@avior.me>
This commit is contained in:
Florian Bouillon 2024-12-12 00:20:58 +01:00 committed by GitHub
parent 0616b98038
commit 87d9b16fb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 14 additions and 3 deletions

View File

@ -19,5 +19,5 @@ params:query {
assert {
res.status: eq 200
res.body: length 85
res.body.length: gt 85
}

View File

@ -17,5 +17,5 @@ params:query {
assert {
res.status: eq 200
res.body.length: lt 0
res.body.length: gte 6
}

2
server/.gitignore vendored
View File

@ -4,3 +4,5 @@
/public/**/graphql.gql
/public/**/api.d.ts
/public/**/openapi.yaml
.env
.env.*

Binary file not shown.

View File

@ -13,6 +13,7 @@
"@dzeio/config": "^1",
"@dzeio/object-util": "^1",
"@dzeio/queue": "^1",
"@sentry/node": "^8",
"@tcgdex/sdk": "^2",
"apicache": "^1",
"express": "^4",

View File

@ -5,6 +5,13 @@ import { Errors, sendError } from './libs/Errors'
import status from './status'
import jsonEndpoints from './V2/endpoints/jsonEndpoints'
import graphql from './V2/graphql'
import * as Sentry from "@sentry/node"
// Glitchtip will only start if the DSN is set :D
Sentry.init({
dsn: process.env.GLITCHTIP_DSN,
environment: process.env.NODE_ENV
})
if (cluster.isPrimary) {
console.log(`Primary ${process.pid} is running`)
@ -107,7 +114,8 @@ if (cluster.isPrimary) {
sendError(Errors.NOT_FOUND, res)
})
// General error handler
// Error handlers
Sentry.setupExpressErrorHandler(server)
server.use((err: Error, _1: unknown, res: Response, _2: unknown) => {
// add a full line dash to not miss it
const columns = (process?.stdout?.columns ?? 32) - 7