fix: add error logging to empty catch blocks
This commit is contained in:
+5
-3
@@ -51,11 +51,12 @@ await fastify.register(cors, {
|
||||
|
||||
await registerSecurityHeaders(fastify)
|
||||
|
||||
fastify.get('/health', async () => {
|
||||
fastify.get('/health', async (request) => {
|
||||
try {
|
||||
await prisma.$queryRaw`SELECT 1`
|
||||
return { status: 'ok', database: 'connected', uptime: process.uptime() }
|
||||
} catch {
|
||||
} catch (err) {
|
||||
request.log.error({ err }, 'Health check database query failed')
|
||||
return { status: 'degraded', database: 'disconnected', uptime: process.uptime() }
|
||||
}
|
||||
})
|
||||
@@ -119,7 +120,8 @@ fastify.decorate('authenticate', async function authenticate(request, reply) {
|
||||
request.headers.authorization = `Bearer ${request.query.token}`
|
||||
}
|
||||
await request.jwtVerify()
|
||||
} catch {
|
||||
} catch (err) {
|
||||
request.log.error({ err }, 'JWT verification failed')
|
||||
return reply.code(401).send({ error: 'Не авторизован' })
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user