'init'
This commit is contained in:
28
app/api/salon/check-user/route.ts
Normal file
28
app/api/salon/check-user/route.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { postSalonApi } from "@/app/lib/salonApi";
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const body = await request.json().catch(() => ({}));
|
||||
const email = String(body?.email || "").trim();
|
||||
if (!email) {
|
||||
return NextResponse.json({ ok: false, error: "请输入邮箱" }, { status: 400 });
|
||||
}
|
||||
|
||||
const { status, data } = await postSalonApi(request, "/api/salon/check-user", { email });
|
||||
const payload = typeof data === "object" && data !== null ? (data as Record<string, unknown>) : {};
|
||||
if (status >= 500) {
|
||||
return NextResponse.json(
|
||||
{ ok: false, error: (payload.error as string) || "服务暂时不可用,请稍后重试" },
|
||||
{ status: 503 }
|
||||
);
|
||||
}
|
||||
return NextResponse.json(data, { status });
|
||||
} catch (error) {
|
||||
console.error("salon check-user error:", error);
|
||||
return NextResponse.json(
|
||||
{ ok: false, error: "服务暂时不可用,请稍后重试" },
|
||||
{ status: 503 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user