Files
chadebebe/app/api/public/visit/route.ts
belisards 17117ed7b2
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
feat(home): add Ver lista do Martin CTA, mints anonymous visitor guest
2026-05-03 17:13:41 -03:00

13 lines
559 B
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { db, guests } from '@/lib/db';
import { USR_COOKIE, buildCookie, isSecureCookie } from '@/lib/auth/cookies';
const ONE_YEAR = 60 * 60 * 24 * 365;
export async function POST(request: NextRequest) {
const [row] = await db.insert(guests).values({ name: 'Visitante' }).returning();
const headers = new Headers();
headers.append('Set-Cookie', buildCookie(USR_COOKIE, row.id, isSecureCookie(request), ONE_YEAR));
return NextResponse.json({ success: true, guestId: row.id }, { headers });
}