import { apiRoute } from '@/lib/api/handler'
import { getWeakLinkAnalysis } from '@/lib/services/stress-service'

export const dynamic = 'force-dynamic'

/** Weakest link and the national risk radar (§30, §31, §32). */
export const GET = apiRoute({ permission: 'grid.read', limit: 60 }, async ({ searchParams }) => {
  const limit = Math.min(50, Math.max(1, Number(searchParams.get('limit')) || 20))
  return getWeakLinkAnalysis({ limit })
})
