import { getGameDb } from '@/lib/db/client'; import { createSession } from '@/lib/auth'; // TEST-ONLY hook (v0.71.0) — mints a live session for the SEEDED admin user server-side and // returns its id, so the e2e suite can exercise the authenticated Admin panel WITHOUT the real // admin password ever appearing in test code (the spec forbids it). No body. Disabled unless // FLIGHT_TEST_HOOKS=1 (set in docker-compose.ci.yml for the CI stack only); every other // deployment 404s here, like its /api/test/* siblings. export async function POST() { if (process.env.FLIGHT_TEST_HOOKS !== '1') { return Response.json({ error: 'test hooks disabled' }, { status: 404 }); } const inst = await getGameDb(); const res = inst.raw.exec("SELECT id FROM users WHERE username = 'kamilkrzywda'"); const userId = res[0]?.values?.[0]?.[0]; if (typeof userId !== 'string') { return Response.json({ error: 'seeded admin user missing' }, { status: 500 }); } const sessionId = await createSession(inst, userId); return Response.json({ sessionId }); }