Add lightning strikes and wind overlay toggles to Maps tab
This commit is contained in:
1 parent
02f49e55f8
commit
e4c631f9a8
4 files changed
+1088
-92
No files matched your search
+45
-6
@@ -22,9 +22,10 @@ app.get('/api/geocode', async (req, res) => {
|
||||
|
||||
// Weather proxy
|
||||
app.get('/api/weather', async (req, res) => {
|
||||
const { lat, lon, tz } = req.query;
|
||||
const { lat, lon, tz, units } = req.query;
|
||||
if (!lat || !lon) return res.status(400).json({ error: 'Missing lat/lon' });
|
||||
const timezone = tz || 'auto';
|
||||
const useMetric = units === 'metric';
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
latitude: lat, longitude: lon, timezone,
|
||||
@@ -35,17 +36,17 @@ app.get('/api/weather', async (req, res) => {
|
||||
].join(','),
|
||||
hourly: [
|
||||
'temperature_2m','precipitation_probability','weather_code',
|
||||
'wind_speed_10m','apparent_temperature'
|
||||
'wind_speed_10m','apparent_temperature','rain','snowfall'
|
||||
].join(','),
|
||||
daily: [
|
||||
'weather_code','temperature_2m_max','temperature_2m_min',
|
||||
'precipitation_sum','precipitation_probability_max',
|
||||
'wind_speed_10m_max','sunrise','sunset','uv_index_max'
|
||||
].join(','),
|
||||
forecast_days: 7,
|
||||
wind_speed_unit: 'mph',
|
||||
temperature_unit: 'fahrenheit',
|
||||
precipitation_unit: 'inch'
|
||||
forecast_days: 16,
|
||||
wind_speed_unit: useMetric ? 'kmh' : 'mph',
|
||||
temperature_unit: useMetric ? 'celsius' : 'fahrenheit',
|
||||
precipitation_unit: useMetric ? 'mm' : 'inch'
|
||||
});
|
||||
const r = await fetch(`https://api.open-meteo.com/v1/forecast?${params}`);
|
||||
const data = await r.json();
|
||||
@@ -55,6 +56,44 @@ app.get('/api/weather', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Open-Meteo Air Quality proxy
|
||||
app.get('/api/air-quality', async (req, res) => {
|
||||
const { lat, lon, tz } = req.query;
|
||||
if (!lat || !lon) return res.status(400).json({ error: 'Missing lat/lon' });
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
latitude: lat,
|
||||
longitude: lon,
|
||||
timezone: tz || 'auto',
|
||||
current: ['us_aqi', 'pm2_5', 'alder_pollen', 'birch_pollen', 'grass_pollen', 'mugwort_pollen', 'olive_pollen', 'ragweed_pollen'].join(','),
|
||||
forecast_days: 1,
|
||||
});
|
||||
const r = await fetch(`https://air-quality-api.open-meteo.com/v1/air-quality?${params}`);
|
||||
const data = await r.json();
|
||||
res.json(data);
|
||||
} catch (e) {
|
||||
res.status(500).json({ error: 'Air quality fetch failed', detail: e.message });
|
||||
}
|
||||
});
|
||||
|
||||
// NWS alerts proxy (US only)
|
||||
app.get('/api/alerts', async (req, res) => {
|
||||
const { lat, lon } = req.query;
|
||||
if (!lat || !lon) return res.status(400).json({ error: 'Missing lat/lon' });
|
||||
try {
|
||||
const r = await fetch(`https://api.weather.gov/alerts/active?point=${lat},${lon}`, {
|
||||
headers: {
|
||||
'User-Agent': 'weather-app-v2 (nate@necloud.us)',
|
||||
Accept: 'application/geo+json',
|
||||
},
|
||||
});
|
||||
const data = await r.json();
|
||||
res.json(data);
|
||||
} catch (e) {
|
||||
res.status(500).json({ error: 'Alerts fetch failed', detail: e.message });
|
||||
}
|
||||
});
|
||||
|
||||
// RainViewer timestamps proxy
|
||||
app.get('/api/radar/times', async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user