import { apiRoute } from '@/lib/api/handler'
import { getRenewableIntelligence } from '@/lib/services/forecast-service'

export const dynamic = 'force-dynamic'

export const GET = apiRoute({ permission: 'renewables.read' }, async ({ searchParams }) => {
  const horizonMin = Math.min(4320, Math.max(60, Number(searchParams.get('horizon')) || 1440))
  return getRenewableIntelligence(horizonMin)
})
