feat: bootstrap taller-turnos project

Estructura inicial con Next.js 14, PostgreSQL/Prisma 7, autenticación por
magic link (clientes) y JWT (admins), lógica de scheduling con 4 slots
paralelos y API routes completas para cliente y panel admin.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Beldor
2026-06-18 11:51:19 -03:00
parent 4fde77e3ed
commit 93ad1cb8c1
28 changed files with 2626 additions and 23 deletions
+35
View File
@@ -0,0 +1,35 @@
import { cookies } from "next/headers";
import { SignJWT, jwtVerify } from "jose";
const SECRET = new TextEncoder().encode(process.env.NEXTAUTH_SECRET || "dev-secret");
const COOKIE = "admin_session";
export async function crearSesionAdmin(adminId: string): Promise<string> {
const token = await new SignJWT({ sub: adminId, role: "admin" })
.setProtectedHeader({ alg: "HS256" })
.setExpirationTime("8h")
.sign(SECRET);
return token;
}
export async function crearSesionCliente(clienteId: string): Promise<string> {
const token = await new SignJWT({ sub: clienteId, role: "cliente" })
.setProtectedHeader({ alg: "HS256" })
.setExpirationTime("24h")
.sign(SECRET);
return token;
}
export async function verificarSesion(
cookieName: string
): Promise<{ sub: string; role: string } | null> {
const cookieStore = await cookies();
const token = cookieStore.get(cookieName)?.value;
if (!token) return null;
try {
const { payload } = await jwtVerify(token, SECRET);
return payload as { sub: string; role: string };
} catch {
return null;
}
}