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

export const dynamic = 'force-dynamic'

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