feat: add local auth billing and usage management
This commit is contained in:
1 parent
f642b5e71f
commit
196fdde83f
119 files changed
+15695
-2650
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { jsonError, jsonOk, readJsonBody } from "@/lib/server/api";
|
||||
import { requireSuperAdminUser } from "@/lib/server/auth/current-user";
|
||||
import { getBillingAccountConfig } from "@/lib/server/billing-service";
|
||||
import { saveApiSettings } from "@/lib/server/app-settings";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
|
||||
export async function PATCH(request: Request) {
|
||||
try {
|
||||
await requireSuperAdminUser();
|
||||
const body = await readJsonBody<Record<string, unknown>>(request);
|
||||
const values = {
|
||||
ZHINIAN_BILLING_ACCOUNT_NAME: normalize(body.accountName),
|
||||
ZHINIAN_BILLING_ACCOUNT_BANK: normalize(body.bankName),
|
||||
ZHINIAN_BILLING_ACCOUNT_NUMBER: normalize(body.accountNumber),
|
||||
ZHINIAN_BILLING_CONTACT: normalize(body.contact)
|
||||
};
|
||||
await saveApiSettings(values);
|
||||
return jsonOk({ billingAccount: getBillingAccountConfig() });
|
||||
} catch (error) {
|
||||
return jsonError(error, 500, { request, source: "api.admin.billing.account" });
|
||||
}
|
||||
}
|
||||
|
||||
function normalize(value: unknown): string {
|
||||
return typeof value === "string" ? value.trim() : "";
|
||||
}
|
||||
Reference in new issue
Block a user