mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 03:14:00 +00:00
refactor: separate regional briefing and weather sources
This commit is contained in:
1 parent
213edd80ce
commit
318d37ad8d
11 files changed
+475
-348
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { fetchRegionalJson } from './http.js';
|
||||
import { normalizeRegionalWeather } from '../../../src/data/regionalBrief.js';
|
||||
|
||||
const WEATHER_EFFECTS_MAX_RESPONSE_BYTES = 512 * 1024;
|
||||
|
||||
async function fetchRegionalWeather(point) {
|
||||
const params = new URLSearchParams({
|
||||
latitude: point.latitude.toFixed(5),
|
||||
longitude: point.longitude.toFixed(5),
|
||||
current: 'temperature_2m,apparent_temperature,precipitation,weather_code,cloud_cover,wind_speed_10m,wind_direction_10m,visibility',
|
||||
timezone: 'UTC',
|
||||
});
|
||||
try {
|
||||
const payload = await fetchRegionalJson(`https://api.open-meteo.com/v1/forecast?${params}`, {
|
||||
maxBytes: WEATHER_EFFECTS_MAX_RESPONSE_BYTES,
|
||||
});
|
||||
return normalizeRegionalWeather(payload);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export { fetchRegionalWeather };
|
||||
Reference in new issue
Block a user