feat: add local auth billing and usage management

This commit is contained in:
inman committed 2026-08-12 12:13:06 +08:00
1 parent f642b5e71f
commit 196fdde83f
119 files changed
+15695 -2650

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
import { jsonError, jsonOk } from "@/lib/server/api";
import { requireAppSession } from "@/lib/server/auth/current-user";
import { getBillingOverview } from "@/lib/server/billing-service";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export async function GET() {
try {
const session = await requireAppSession();
const organizationId = session.user.organizationId;
if (!organizationId) throw Object.assign(new Error("当前账号未绑定组织。"), { status: 422 });
const overview = await getBillingOverview({ organizationId, accountId: session.user.id });
return jsonOk({
organization: {
id: organizationId,
name: session.user.organizationName || organizationId
},
...overview
});
} catch (error) {
return jsonError(error, 500, { source: "api.billing" });
}
}