import { NextResponse } from "next/server";

import { prisma } from "@/lib/prisma";

export async function GET() {
  try {
    await prisma.$queryRaw`SELECT 1`;

    return NextResponse.json({
      ok: true,
      status: "ok",
      service: "abelbirdnest-web",
      timestamp: new Date().toISOString()
    });
  } catch (error) {
    return NextResponse.json(
      {
        ok: false,
        status: "degraded",
        service: "abelbirdnest-web",
        timestamp: new Date().toISOString(),
        message: error instanceof Error ? error.message : "Database health check gagal"
      },
      { status: 503 }
    );
  }
}
