Add Ground View screen for server edition, powered by the Windy API https://api.windy.com/
This commit is contained in:
parent
8958ef4d38
commit
598a60c7f5
11 changed files with 349 additions and 1 deletions
32
index.mjs
32
index.mjs
|
|
@ -20,6 +20,7 @@ import OVERRIDES from './src/overrides.mjs';
|
|||
import cache from './proxy/cache.mjs';
|
||||
import devTools from './src/com.chrome.devtools.mjs';
|
||||
import { discoverThemes } from './src/theme-discovery.mjs';
|
||||
import { findNearestWindyWebcam, loadWindyApiKey } from './src/windy-webcams.mjs';
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
|
|
@ -252,6 +253,37 @@ if (!process.env?.STATIC) {
|
|||
}
|
||||
});
|
||||
|
||||
app.get('/api/ground-view', async (req, res) => {
|
||||
try {
|
||||
const lat = parseFloat(req.query.lat);
|
||||
const lon = parseFloat(req.query.lon);
|
||||
const city = String(req.query.city ?? '').trim();
|
||||
|
||||
if (Number.isNaN(lat) || Number.isNaN(lon) || !city) {
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
webcam: null,
|
||||
error: 'Missing or invalid lat/lon/city',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const apiKey = await loadWindyApiKey();
|
||||
const webcam = await findNearestWindyWebcam(lat, lon, city, apiKey);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
webcam,
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
webcam: null,
|
||||
error: error.message,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.use('/api/', weatherProxy);
|
||||
|
||||
// Cache management DELETE endpoint to allow "uncaching" specific URLs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue