import { NextResponse } from "next/server"; // Liveness probe (nginx/monitoring). Public. Reports the process is up and // pings Mongo so a DB outage is visible here, not hidden behind a 200 feed. // // NOTE the double await is REQUIRED: getDb() is async (returns Promise). // `await getDb().command(...)` would call .command on the PROMISE and throw // "command is not a function" (caught in e2e 2026-09-15). export const dynamic = "force-dynamic"; export async function GET() { let mongo = "unknown"; try { const { getDb } = await import("../../../lib/db"); const db = await getDb(); await db.command({ ping: 1 }); mongo = "ok"; } catch { mongo = "down"; } return NextResponse.json({ ok: true, service: "bidaangmamamayan", mongo, time: new Date().toISOString() }); }