import { login } from "@/lib/auth";
import { fail, ok, readJson } from "@/lib/api";

export async function POST(req: Request) {
  const body = await readJson<{ password?: string }>(req);
  if (!body.password) return fail("missing_password", 400);
  const success = await login(body.password);
  if (!success) return fail("invalid_credentials", 401);
  return ok({ ok: true });
}
