V1 bingo
Deploy / build-and-deploy (push) Failing after 2m53s

This commit is contained in:
2026-06-14 21:29:43 +03:00
commit 05677924b5
55 changed files with 10816 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import { NextRequest, NextResponse } from "next/server";
import { loginUser, deleteSession, getServerSession, SESSION_COOKIE } from "@/lib/auth";
import { cookies } from "next/headers";
export async function POST(req: NextRequest) {
try {
const { nickname, password } = await req.json();
if (!nickname || !password) {
return NextResponse.json({ error: "Nickname and password required" }, { status: 400 });
}
const result = await loginUser(nickname, password);
if ("error" in result) {
return NextResponse.json(result, { status: 401 });
}
const res = NextResponse.json(result.user);
res.cookies.set(SESSION_COOKIE, result.sessionId, {
httpOnly: true,
secure: false,
sameSite: "lax",
path: "/",
maxAge: 7 * 86400,
});
return res;
} catch {
return NextResponse.json({ error: "Login failed" }, { status: 500 });
}
}
export async function DELETE() {
const session = await getServerSession();
if (session) {
const cookieStore = await cookies();
const token = cookieStore.get(SESSION_COOKIE)?.value;
if (token) await deleteSession(token);
}
const res = NextResponse.json({ ok: true });
res.cookies.set(SESSION_COOKIE, "", { httpOnly: true, path: "/", maxAge: 0 });
return res;
}
+10
View File
@@ -0,0 +1,10 @@
import { NextResponse } from "next/server";
import { getServerSession } from "@/lib/auth";
export async function GET() {
const session = await getServerSession();
if (!session) {
return NextResponse.json({ user: null });
}
return NextResponse.json({ user: { id: session.id, nickname: session.nickname, isAdmin: session.isAdmin } });
}
+24
View File
@@ -0,0 +1,24 @@
import { NextRequest, NextResponse } from "next/server";
import { registerUser } from "@/lib/auth";
export async function POST(req: NextRequest) {
try {
const { nickname, password } = await req.json();
if (!nickname || !password) {
return NextResponse.json({ error: "Nickname and password required" }, { status: 400 });
}
if (nickname.length < 2 || nickname.length > 20) {
return NextResponse.json({ error: "Nickname 2-20 characters" }, { status: 400 });
}
if (password.length < 4) {
return NextResponse.json({ error: "Password min 4 characters" }, { status: 400 });
}
const result = await registerUser(nickname, password);
if ("error" in result) {
return NextResponse.json(result, { status: 409 });
}
return NextResponse.json(result);
} catch {
return NextResponse.json({ error: "Registration failed" }, { status: 500 });
}
}