All files / src/app/api/federated route.ts

90.9% Statements 10/11
66.66% Branches 4/6
100% Functions 1/1
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22      1x   1x     2x 2x   2x 2x 1x 1x     1x 1x      
import { NextResponse } from "next/server";
import { requireAuth, isAuthError } from "@/lib/auth-guard";
 
export const dynamic = "force-dynamic";
 
const PROXY_URL = process.env.NEO4J_PROXY_URL ?? "http://localhost:9090";
 
export async function GET() {
  const auth = await requireAuth();
  Iif (isAuthError(auth)) return auth;
 
  try {
    const resp = await fetch(`${PROXY_URL}/federated/stats`);
    const data = await resp.json();
    return NextResponse.json(data);
  } catch (err: unknown) {
    const message =
      err instanceof Error ? err.message : "Federated stats proxy error";
    return NextResponse.json({ error: message }, { status: 502 });
  }
}