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);
    console.error("Alert check error:", msg);
    return NextResponse.json({ error: `检查失败: ${msg}` }, { status: 500 });
  }
}
