/**
 * Proxy: GET /api/sdk/v1/agent/migration/<checkId>/summary
 *   -> backend GET /api/compliance/agent/migration/<checkId>/summary
 */
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 url = `${BACKEND_URL}/api/compliance/agent/migration/${(await params).checkId}/summary`
  try {
    const resp = await fetch(url, { signal: AbortSignal.timeout(15000) })
    const data = await resp.json()
    return NextResponse.json(data, { status: resp.status })
  } catch {
    return NextResponse.json(
      { error: 'Migrations-Summary fehlgeschlagen' },
      { status: 503 },
    )
  }
}
