Skip to content

Commit

Permalink
feat: health check
Browse files Browse the repository at this point in the history
  • Loading branch information
qin-guan committed Sep 16, 2023
1 parent 8c12301 commit 01cfc48
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions server/api/healthz.get.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
export default defineEventHandler((event) => {
return 1
})
import { sql } from 'drizzle-orm'

export default defineLazyEventHandler(() => eventHandler(async (event) => {
try {
await event.context.database.run(sql`SELECT 1;`)
return { ok: true, now: new Date() }
}
catch (err) {
throw createError({
statusCode: 500,
statusMessage: 'Internal Server Error',
})
}
}))

0 comments on commit 01cfc48

Please # to comment.