Skip to content

Commit

Permalink
fix: prevent db check all the time
Browse files Browse the repository at this point in the history
  • Loading branch information
qin-guan authored Jul 19, 2023
1 parent 1092ebb commit 5de9e3b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/api/healthz.get.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const startupTime = new Date()
let prismaIsGood = false

const handler = defineEventHandler(async (event) => {
try {
await event.context.prisma.$queryRaw`SELECT 1;`
if (!prismaIsGood)
await event.context.prisma.$queryRaw`SELECT 1;`
prismaIsGood = true
}
catch (error) {
throw createError({ statusCode: 500, statusMessage: 'DB failed initialization check' })
Expand Down

0 comments on commit 5de9e3b

Please sign in to comment.