route.ts
621 bytes
| 1 | import { NextResponse } from 'next/server'; |
|---|---|
| 2 | import { prisma } from '@/db/client'; |
| 3 | |
| 4 | export const runtime = 'nodejs'; |
| 5 | export const dynamic = 'force-dynamic'; |
| 6 | |
| 7 | /** |
| 8 | * Liveness/readiness probe. Pings the database so a load balancer or the deploy |
| 9 | * workflow can tell "process is up" from "process is up and can serve". |
| 10 | */ |
| 11 | export async function GET() { |
| 12 | const startedAt = Date.now(); |
| 13 | try { |
| 14 | await prisma.$queryRaw`SELECT 1`; |
| 15 | return NextResponse.json({ status: 'ok', db: 'up', latencyMs: Date.now() - startedAt }); |
| 16 | } catch { |
| 17 | return NextResponse.json({ status: 'degraded', db: 'down' }, { status: 503 }); |
| 18 | } |
| 19 | } |
| 20 | |