Scrum4Me/app/api/health/route.ts
Madhura68 b217949f84 feat(ST-513): add GET /api/health endpoint with optional db ping
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 21:58:52 +02:00

24 lines
528 B
TypeScript

import packageJson from '@/package.json'
import { prisma } from '@/lib/prisma'
export async function GET(request: Request) {
const url = new URL(request.url)
const checkDb = url.searchParams.get('db') === '1'
const body: Record<string, unknown> = {
status: 'ok',
version: packageJson.version,
time: new Date().toISOString(),
}
if (checkDb) {
try {
await prisma.$queryRaw`SELECT 1`
body.database = 'ok'
} catch {
body.database = 'down'
}
}
return Response.json(body)
}