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
@@ -1,13 +1,13 @@
|
||||
import { jsonError, jsonOk } from "@/lib/server/api";
|
||||
import { requireAdminUser } from "@/lib/server/auth/current-user";
|
||||
import { appLogFilePath, appLogMaxBytes, clearAppLogs, listAppLogs, type AppLogLevel } from "@/lib/server/log-manager";
|
||||
import { requireSuperAdminUser } from "@/lib/server/auth/current-user";
|
||||
import { clearAppLogs, listAppLogs, type AppLogLevel } from "@/lib/server/log-manager";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
await requireAdminUser();
|
||||
await requireSuperAdminUser();
|
||||
const url = new URL(request.url);
|
||||
const level = parseLevel(url.searchParams.get("level"));
|
||||
const q = url.searchParams.get("q") || undefined;
|
||||
@@ -17,11 +17,7 @@ export async function GET(request: Request) {
|
||||
q,
|
||||
limit: Number.isFinite(limit) ? limit : 100
|
||||
});
|
||||
return jsonOk({
|
||||
entries,
|
||||
logPath: appLogFilePath(),
|
||||
maxBytes: appLogMaxBytes()
|
||||
});
|
||||
return jsonOk({ entries });
|
||||
} catch (error) {
|
||||
return jsonError(error, 500, { request, source: "api.logs" });
|
||||
}
|
||||
@@ -29,7 +25,7 @@ export async function GET(request: Request) {
|
||||
|
||||
export async function DELETE(request: Request) {
|
||||
try {
|
||||
await requireAdminUser();
|
||||
await requireSuperAdminUser();
|
||||
await clearAppLogs();
|
||||
return jsonOk({ ok: true });
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user