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.
20 lines
557 B
TypeScript
20 lines
557 B
TypeScript
import { logError } from "@/lib/logger";
|
|
import { NextResponse } from "next/server";
|
|
import { checkAlerts } from "@/lib/adminrpc/client";
|
|
|
|
export const runtime = "nodejs";
|
|
|
|
/**
|
|
* Trigger workspace billing alert check via adminrpc gRPC.
|
|
*/
|
|
export async function POST() {
|
|
try {
|
|
const data = await checkAlerts();
|
|
return NextResponse.json(data);
|
|
} catch (e) {
|
|
const msg = e instanceof Error ? e.message : String(e);
|
|
logError("Alert check error:", e);
|
|
return NextResponse.json({ error: `检查失败: ${msg}` }, { status: 500 });
|
|
}
|
|
}
|