import { NextResponse } from "next/server";

/**
 * Liveness Probe Endpoint
 *
 * Indicates whether the application process is alive and running
 * Used by orchestrators to detect hung processes or deadlocks
 *
 * This is the simplest health check - if it responds, the app is alive
 * It does NOT check dependencies (that's what /ready is for)
 *
 * Response Codes:
 * - 200: Process is alive
 * - (No response or timeout = process is dead, restart required)
 */
export async function GET() {
  return NextResponse.json(
    {
      alive: true,
      timestamp: new Date().toISOString(),
      uptime: process.uptime(),
    },
    {
      status: 200,
      headers: {
        "Cache-Control": "no-cache, no-store, must-revalidate",
      },
    },
  );
}

/**
 * HEAD request for minimal liveness check
 */
export async function HEAD() {
  return new Response(null, { status: 200 });
}
