import { NextResponse, type NextRequest } from "next/server"; import { keepSessionAlive } from "@/app/lib/server/sessionKeepAlive"; import { unauthorized } from "@/app/lib/server/apiRoute"; // POST → enforce-session-timeouts check-in. Body {active: true} only when the person clicked, tapped or typed since // the last call; anything else is a timer call that may renew the token but never counts as activity. // 204 while the session lives; 401 (cookie cleared) once it has ended. export async function POST(req: NextRequest) { const body = (await req.json().catch(() => null)) as { active?: unknown } | null; const alive = await keepSessionAlive(body?.active === true); return alive ? new NextResponse(null, { status: 204 }) : unauthorized(); }