/**
 * Proxy: GET /api/sdk/v1/agent/banner/<checkId>
 *   -> backend GET /api/compliance/agent/banner/<checkId>
 *
 * Liefert das volle banner_result (phases, structured_checks, category_tests).
 */
import { NextRequest, NextResponse } from 'next/server'

const BACKEND_URL = process.env.BACKEND_API_URL || 'http://backend-compliance:8002'

export async function GET(
  _request: NextRequest,
  { params }: { params: Promise<{ checkId: string }> },
) {
  const { checkId } = await params
  try {
    const resp = await fetch(
      `${BACKEND_URL}/api/compliance/agent/banner/${checkId}`,
      { signal: AbortSignal.timeout(15000) },
    )
    const data = await resp.json().catch(() => ({}))
    return NextResponse.json(data, { status: resp.status })
  } catch {
    return NextResponse.json(
      { error: 'Banner-Abfrage fehlgeschlagen' }, { status: 503 },
    )
  }
}
