gitdataai/admin/src/app/api/platform/ai/sync/route.ts
ZhenYi 3773fdc780 feat(admin): add structured error logger for all API routes
Replace bare console.error() calls with logError() utility across all
47 API route handlers. logError() prints timestamp + context + message
+ stack trace + extra request data to stderr, and redacts sensitive
fields (password, token, secret, key, etc.) from logged objects.
2026-04-23 09:55:35 +08:00

20 lines
535 B
TypeScript

import { logError } from "@/lib/logger";
import { NextResponse } from "next/server";
import { syncModels } from "@/lib/adminrpc/client";
export const runtime = "nodejs";
/**
* Trigger AI model sync via adminrpc gRPC.
*/
export async function POST() {
try {
const data = await syncModels();
return NextResponse.json(data);
} catch (e) {
const msg = e instanceof Error ? e.message : String(e);
logError("AI sync error:", e);
return NextResponse.json({ error: `同步失败: ${msg}` }, { status: 500 });
}
}