24h forecasting
This commit is contained in:
@@ -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}`)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user