All files / src/app/api/nlq/backend route.ts

0% Statements 0/8
0% Branches 0/4
0% Functions 0/1
0% Lines 0/8

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 23 24 25 26                                                   
import { NextResponse } from "next/server";
 
export const dynamic = "force-dynamic";
 
const PROXY_URL = process.env.NEO4J_PROXY_URL ?? "http://localhost:9090";
 
/**
 * Phase 25f (Issue #13) — proxy for /nlq/backend.
 *
 * Returns the NLP backend detection result from neo4j-proxy so the UI can
 * render a status badge on /query. Unauthenticated on purpose — the result
 * exposes no secrets, just which providers are wired, and it lets the
 * loading page render the badge without waiting for a session.
 */
export async function GET() {
  try {
    const resp = await fetch(`${PROXY_URL}/nlq/backend`, { cache: "no-store" });
    const data = await resp.json();
    return NextResponse.json(data, { status: resp.status });
  } catch (err: unknown) {
    const message =
      err instanceof Error ? err.message : "NLQ backend proxy error";
    return NextResponse.json({ error: message }, { status: 502 });
  }
}