import { NextResponse } from "next/server";
import { readBuildInfoFromEnv } from "@/lib/build-info";

// Read per request, never prerendered — the whole point is to report what THIS
// running container is, and a baked answer would defeat that.
export const dynamic = "force-dynamic";

/**
 * The web tier's counterpart to the API's GET /version.
 *
 * Without this, the only way to see what the web container is running was to
 * scrape window.__APP_BUILD__ out of the HTML. The deploy workflow compares the
 * two tiers' gitSha to catch a half-applied release, so it needs a stable,
 * parseable answer from both sides.
 */
export function GET() {
  return NextResponse.json({ service: "web", ...readBuildInfoFromEnv() });
}
