Fixed paths

This commit is contained in:
2026-06-24 14:58:24 -04:00
parent 7dfd5e6e1f
commit 5794eca9f1
2 changed files with 5 additions and 4 deletions

View File

@@ -118,7 +118,7 @@ const DAILY_FIELDS = [
'uv_index_max', 'shortwave_radiation_sum',
].join(',')
export async function getOpenMeteo(lat, lon, start, end) {
export async function dailyWeather(lat, lon, start, end) {
const startStr = start.toISOString().slice(0, 10)
const endStr = end.toISOString().slice(0, 10)
const url = `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}` +
@@ -174,7 +174,7 @@ const HOURLY_FIELDS = [
'visibility',
].join(',')
export async function getOpenMeteoHourly(lat, lon, start, end) {
export async function hourlyWeather(lat, lon, start, end) {
const startStr = start instanceof Date ? start.toISOString().slice(0, 10) : start.slice(0, 10)
const endStr = end instanceof Date ? end.toISOString().slice(0, 10) : end.slice(0, 10)
const url = `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}` +

View File

@@ -11,6 +11,7 @@ import {existsSync} from 'fs';
import {getAirTraffic, getAirTrafficHistory, getShapes} from './airtraffic.mjs';
import {getWeatherCondition} from './openweather.mjs';
import {ensureForecast, refreshForecast} from './forecast.mjs';
import {dailyWeather, hourlyWeather} from './openmeteo.mjs';
const app = express();
const DIR = dirname(fileURLToPath(import.meta.url));
@@ -90,7 +91,7 @@ app.get('/api/hourly', async (req, res) => {
// +24h → beyond: Open-Meteo
let meteo = []
if (end > plus24) {
const [meteoResult] = await Promise.allSettled([getOpenMeteoHourly(coords.latitude, coords.longitude, plus24, end)])
const [meteoResult] = await Promise.allSettled([hourlyWeather(coords.latitude, coords.longitude, plus24, end)])
meteo = meteoResult.status === 'fulfilled' ? meteoResult.value : []
}
@@ -124,7 +125,7 @@ app.get('/api/daily', async (req, res) => {
// Future meteo (days after today)
const meteoStart = end > next ? next : null
const [meteoResult] = await Promise.allSettled([
meteoStart && end > next ? getOpenMeteo(coords.latitude, coords.longitude, next, end) : Promise.resolve([])
meteoStart && end > next ? dailyWeather(coords.latitude, coords.longitude, next, end) : Promise.resolve([])
])
const meteo = meteoResult.status === 'fulfilled' ? meteoResult.value : []