chore: add prettier formatting
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m56s

This commit is contained in:
zv
2026-06-14 20:26:56 +02:00
parent 8bbd9397a1
commit ee55521803
79 changed files with 2451 additions and 969 deletions

View File

@@ -18,7 +18,7 @@ export function parseForecastCoordinate(value: string | null, min: number, max:
async function readImgwPayload(response: Response | null) {
if (!response?.ok) return null;
try {
return await response.json() as RawImgwForecastResponse;
return (await response.json()) as RawImgwForecastResponse;
} catch {
return null;
}
@@ -29,7 +29,8 @@ export async function fetchServerForecast(latitude: number, longitude: number, r
latitude: String(latitude),
longitude: String(longitude),
hourly: "temperature_2m,apparent_temperature,precipitation_probability,precipitation,weather_code,wind_speed_10m",
daily: "weather_code,temperature_2m_max,temperature_2m_min,precipitation_probability_max,precipitation_sum,sunrise,sunset",
daily:
"weather_code,temperature_2m_max,temperature_2m_min,precipitation_probability_max,precipitation_sum,sunrise,sunset",
timezone: region === "PL" ? "Europe/Warsaw" : "auto",
forecast_days: "7",
wind_speed_unit: "ms",
@@ -42,14 +43,20 @@ export async function fetchServerForecast(latitude: number, longitude: number, r
});
const [openMeteoResponse, imgwResponse] = await Promise.all([
fetch(`${OPEN_METEO_FORECAST_URL}?${openMeteoParams}`, { next: { revalidate: 900 }, signal: AbortSignal.timeout(OPEN_METEO_TIMEOUT_MS) }),
fetch(`${OPEN_METEO_FORECAST_URL}?${openMeteoParams}`, {
next: { revalidate: 900 },
signal: AbortSignal.timeout(OPEN_METEO_TIMEOUT_MS),
}),
region === "PL"
? fetch(`${IMGW_FORECAST_URL}?${imgwParams}`, { next: { revalidate: 900 }, signal: AbortSignal.timeout(IMGW_TIMEOUT_MS) }).catch(() => null)
? fetch(`${IMGW_FORECAST_URL}?${imgwParams}`, {
next: { revalidate: 900 },
signal: AbortSignal.timeout(IMGW_TIMEOUT_MS),
}).catch(() => null)
: Promise.resolve(null),
]);
if (!openMeteoResponse.ok) throw new Error("Forecast service is unavailable.");
const openMeteoPayload = await openMeteoResponse.json() as RawWeatherForecast;
const openMeteoPayload = (await openMeteoResponse.json()) as RawWeatherForecast;
const imgwPayload = await readImgwPayload(imgwResponse);
return mergeForecastSources(openMeteoPayload, imgwPayload, region);
}