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

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