Hooked up auroras
This commit is contained in:
@@ -3,7 +3,7 @@ import {isEqual} from '@ztimson/utils';
|
||||
|
||||
const HISTORY_LIMIT = 500;
|
||||
const POLL_MS = 5_000;
|
||||
const TTL_MS = 60_000;
|
||||
const TTL_MS = 3 * 60_000;
|
||||
|
||||
function parseWm(raw) {
|
||||
const f = raw.replace(/<[^>]+>/g, '').split(',').map(s => s.trim());
|
||||
|
||||
@@ -13,6 +13,8 @@ import {fetchIcon} from './openweather.mjs';
|
||||
import {getForecast, getWeatherCondition, forecastTTL} from './forecast.mjs';
|
||||
import {dailyWeather, hourlyWeather} from './openmeteo.mjs';
|
||||
import {getTinyGSData} from './sats.mjs';
|
||||
import {getSpaceWeather} from './space.mjs';
|
||||
import {Aurora} from './aurora.mjs';
|
||||
|
||||
// ── Uncaught error handlers ───────────────────────────────────────────────────
|
||||
|
||||
@@ -48,7 +50,7 @@ function filterArr(arr, fields) {
|
||||
return arr.map(row => filterFields(row, fields));
|
||||
}
|
||||
|
||||
// ── Current ───────────────────────────────────────────────────────────────────
|
||||
// ── Weather ───────────────────────────────────────────────────────────────────
|
||||
|
||||
app.get('/api/current', asyncHandler(async (req, res) => {
|
||||
const { fields } = req.query
|
||||
@@ -72,8 +74,6 @@ app.get('/api/current', asyncHandler(async (req, res) => {
|
||||
res.json(filterFields(merged, fields))
|
||||
}));
|
||||
|
||||
// ── Hourly ────────────────────────────────────────────────────────────────────
|
||||
|
||||
app.get('/api/hourly', asyncHandler(async (req, res) => {
|
||||
const { fields } = req.query
|
||||
const coords = await getCoords()
|
||||
@@ -99,8 +99,6 @@ app.get('/api/hourly', asyncHandler(async (req, res) => {
|
||||
res.json(filterArr(combined, fields))
|
||||
}))
|
||||
|
||||
// ── Daily ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
app.get('/api/daily', asyncHandler(async (req, res) => {
|
||||
const { fields } = req.query
|
||||
const coords = await getCoords()
|
||||
@@ -130,6 +128,7 @@ app.get('/api/daily', asyncHandler(async (req, res) => {
|
||||
|
||||
// ── Position ──────────────────────────────────────────────────────────────────
|
||||
|
||||
app.get('/api/range', asyncHandler(async (req, res) => res.json(await getADSBRange())));
|
||||
app.get('/api/position', asyncHandler(async (req, res) => {
|
||||
const {fields} = req.query;
|
||||
const data = await getCoords();
|
||||
@@ -147,30 +146,31 @@ app.get('/api/icon/:icon', asyncHandler(async (req, res, next) => {
|
||||
|
||||
// ── Space ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
// app.get('/api/aurora', async (req, res) => res.json(await Aurora.get()));
|
||||
// app.get('/api/space', async (req, res) => {
|
||||
// const {fields} = req.query;
|
||||
// res.json(filterFields(await getSpaceWeather(), fields));
|
||||
// });
|
||||
app.get('/api/aurora', async (req, res) => res.json(await Aurora.get()));
|
||||
app.get('/api/space', async (req, res) => {
|
||||
const {fields} = req.query;
|
||||
res.json(filterFields(await getSpaceWeather(), fields));
|
||||
});
|
||||
|
||||
// ── ADSB/AIS/SAT Proxy ────────────────────────────────────────────────────────────
|
||||
|
||||
app.get('/api/adsb', asyncHandler(async (req, res) => res.json(await getADSB())));
|
||||
app.get('/api/adsb-image/:icao', asyncHandler(async (req, res) => {
|
||||
app.get('/api/adsb/:icao/image', asyncHandler(async (req, res) => {
|
||||
const blob = await getADSBImage(req.params.icao);
|
||||
if (!blob) return res.status(404).send('No image found');
|
||||
const buffer = Buffer.from(await blob.arrayBuffer());
|
||||
res.contentType(blob.type).send(buffer);
|
||||
}));
|
||||
app.get('/api/adsb/:icao', asyncHandler(async (req, res) => res.json(await getADSBHistory(req.params.icao))));
|
||||
|
||||
app.get('/api/ais', asyncHandler(async (req, res) => res.json(await getAIS())));
|
||||
app.get('/api/ais-image/:mmsi', asyncHandler(async (req, res) => {
|
||||
app.get('/api/ais/:mmsi/image', asyncHandler(async (req, res) => {
|
||||
const blob = await getAISImage(req.params.mmsi);
|
||||
if (!blob) return res.status(404).send('No image found');
|
||||
const buffer = Buffer.from(await blob.arrayBuffer());
|
||||
res.contentType(blob.type).send(buffer);
|
||||
}));
|
||||
app.get('/api/range', asyncHandler(async (req, res) => res.json(await getADSBRange())));
|
||||
|
||||
app.get('/api/sats', (_req, res) => res.json(getTinyGSData()));
|
||||
|
||||
// ── DOCS ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user