Files
buzz-sheet/app/api/presence/visitors/route.ts
T
gunshiz 5aa0ae80c1
CI / Verify (push) Successful in 1m28s
CI / Build immutable images and deploy (push) Successful in 2m5s
feat : update
2026-09-05 18:15:06 +07:00

27 lines
804 B
TypeScript

import { connection } from "next/server";
import * as z from "zod";
import { updateVisitorPresence } from "@/lib/presence";
const inputSchema = z.strictObject({
tabId: z.string().uuid(),
guideId: z.string().uuid().nullable(),
active: z.boolean().default(true),
});
export async function POST(request: Request) {
await connection();
const parsed = inputSchema.safeParse(await request.json().catch(() => null));
if (!parsed.success) return Response.json({ error: "invalid-presence" }, { status: 400 });
try {
return Response.json(await updateVisitorPresence(parsed.data), {
headers: { "Cache-Control": "no-store" },
});
} catch {
return Response.json({ error: "presence-unavailable" }, {
status: 503,
headers: { "Cache-Control": "no-store" },
});
}
}