24h forecasting

This commit is contained in:
2026-06-24 13:33:49 -04:00
parent 5f71bd182a
commit 04d5b44f87

View File

@@ -10,7 +10,7 @@ import {spec} from './spec.mjs';
import {existsSync} from 'fs';
import {getAirTraffic, getAirTrafficHistory, getShapes} from './airtraffic.mjs';
import {getWeatherCondition} from './openweather.mjs';
import {lastForecast, refreshForecast} from './forecast.mjs';
import {refreshForecast} from './forecast.mjs';
const app = express();
const DIR = dirname(fileURLToPath(import.meta.url));
@@ -180,22 +180,11 @@ app.get('*', (req, res) => {
});
// ── Start ─────────────────────────────────────────────────────────────────────
async function startForecast() {
let ready = false
while (!ready) {
try {
await refreshForecast()
ready = cache.slots.length > 0
} catch {}
if (!ready) await new Promise(r => setTimeout(r, 5000))
}
setInterval(refreshForecast, 10 * 60 * 1000)
}
startForecast()
const c = cfg();
refreshForecast()
setInterval(refreshForecast, 10 * 60 * 1000)
app.listen(c.PORT, () => {
console.log(`🌦 Weather API — http://localhost:${c.PORT}`)
});