first commit

This commit is contained in:
luoyangwei
2026-06-06 00:49:07 +08:00
commit 2b860d201e
134 changed files with 22773 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
import {
getAppUserLoginContextFromRequest,
loginAppUser,
} from "@/server/app/app-auth";
import { NextResponse } from "next/server";
import { z } from "zod";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
const loginSchema = z.object({
email: z.email(),
password: z.string().min(1),
});
export async function POST(request: Request) {
try {
const parsed = loginSchema.safeParse(await request.json());
if (!parsed.success) {
return NextResponse.json(
{ ok: false, error: "Invalid request body." },
{ status: 400 },
);
}
const data = await loginAppUser({
...parsed.data,
context: getAppUserLoginContextFromRequest(request),
});
return NextResponse.json({
ok: true,
data,
});
} catch (error) {
const message =
error instanceof Error ? error.message : "Unknown error.";
return NextResponse.json(
{ ok: false, error: message },
{ status: 401 },
);
}
}