Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
13 lines
559 B
TypeScript
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 });
|
|
}
|