import { egovFlowStatus, PeppaError } from "@peppa/core"; import { cookies } from "next/headers"; import { NextResponse } from "next/server"; import { EGOV_COOKIE } from "@/lib/auth"; import { db } from "@/lib/db"; import { m } from "@peppa/shared/i18n"; /** Status of this browser's eGov QR flow: pending | scanned | completed | expired | rejected. */ export async function GET() { try { return NextResponse.json({ status: await egovFlowStatus(db, (await cookies()).get(EGOV_COOKIE)?.value ?? "") }); } catch (e) { return NextResponse.json({ error: e instanceof PeppaError ? e.message : m("eGov недоступен") }, { status: 424 } /* not 5xx: Cloudflare replaces those with its own page (PEP-194) */); } }