import { loginAccount } from "@/lib/claw-auth";

export async function POST(req: Request) {
	try {
		const payload = (await req.json()) as {
			username?: string;
			password?: string;
		};
		const account = await loginAccount(
			payload.username ?? "",
			payload.password ?? "",
		);
		return Response.json({ account });
	} catch (err) {
		return Response.json(
			{ error: err instanceof Error ? err.message : "登录失败" },
			{ status: 400 },
		);
	}
}
