Add developer API, Prometheus metrics, and community links
This commit is contained in:
16
app/api/metrics/route.ts
Normal file
16
app/api/metrics/route.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { admin, required } from "@/lib/supabase";
|
||||
import { metricsResponse } from "@/lib/prometheus-response";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
export const dynamic = "force-dynamic";
|
||||
export const maxDuration = 30;
|
||||
export function GET(request: Request) {
|
||||
return metricsResponse(request, async (tokenHash) => {
|
||||
const result = await admin().rpc("read_prometheus_metrics", {
|
||||
p_token_hash: tokenHash,
|
||||
});
|
||||
// NULL is an invalid or disabled credential, not a missing database record.
|
||||
if (result.error) required(result);
|
||||
return result.data;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user