weather icons

This commit is contained in:
Jake Kasper
2025-09-02 08:37:05 -05:00
parent 7897c2be58
commit 8c56914afe
3 changed files with 46 additions and 10 deletions

View File

@@ -35,7 +35,13 @@ app.use(helmet({
scriptSrc: ["'self'", "'unsafe-inline'", "https://maps.googleapis.com"],
styleSrc: ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com"],
fontSrc: ["'self'", "https://fonts.gstatic.com"],
imgSrc: ["'self'", "data:", "https://maps.googleapis.com", "https://maps.gstatic.com"],
imgSrc: [
"'self'",
"data:",
"https://maps.googleapis.com",
"https://maps.gstatic.com",
"https://openweathermap.org"
],
connectSrc: ["'self'", "https://api.openweathermap.org"]
}
}

View File

@@ -220,6 +220,7 @@ router.get('/:propertyId/forecast', async (req, res, next) => {
windSpeed: [],
precipitation: 0,
conditions: [],
icons: [],
timestamps: []
};
}
@@ -229,6 +230,7 @@ router.get('/:propertyId/forecast', async (req, res, next) => {
dailyForecast[date].windSpeed.push(item.wind?.speed || 0);
dailyForecast[date].precipitation += item.rain?.['3h'] || 0;
dailyForecast[date].conditions.push(item.weather[0].description);
dailyForecast[date].icons.push(item.weather[0].icon);
dailyForecast[date].timestamps.push(new Date(item.dt * 1000));
});
@@ -246,6 +248,7 @@ router.get('/:propertyId/forecast', async (req, res, next) => {
maxWindSpeed: Math.round(Math.max(...windSpeeds)),
totalPrecipitation: Math.round(day.precipitation * 100) / 100,
conditions: day.conditions[0], // Use first condition of the day
icon: day.icons[0],
timestamps: day.timestamps
};
}).slice(0, 5); // Limit to 5 days