Files
sass-mohfarawati/app/api/health/route.ts
T
2026-03-06 13:53:57 +01:00

36 lines
622 B
TypeScript

import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";
export const dynamic = "force-dynamic";
export async function GET() {
const timestamp = new Date().toISOString();
try {
await prisma.$queryRaw`SELECT 1`;
return NextResponse.json(
{
status: "ok",
timestamp,
checks: {
database: "up",
},
},
{ status: 200 },
);
} catch {
return NextResponse.json(
{
status: "degraded",
timestamp,
checks: {
database: "down",
},
},
{ status: 503 },
);
}
}