import { getConfig } from '../db.js' export async function fcFetch(path) { const apiKey = await getConfig('forecasting_api_key') const baseUrl = (await getConfig('forecasting_url')) || 'http://10.10.10.113:3080' if (!apiKey) throw new Error('Forecasting API key not configured — add it in Settings') const res = await fetch(`${baseUrl}/forecasting/api/public${path}`, { headers: { 'X-API-Key': apiKey }, signal: AbortSignal.timeout(15000), }) if (!res.ok) throw new Error(`Forecasting API ${res.status} — ${path}`) return res.json() }