ADSB/AIS image proxy

This commit is contained in:
2026-07-03 18:48:20 -04:00
parent 4114a0adad
commit 1451145408
3 changed files with 52 additions and 2 deletions

View File

@@ -7,8 +7,8 @@ import {getCelestialCurrent, getCelestialForecast} from './celestial.mjs';
import {apiReference} from '@scalar/express-api-reference';
import {spec} from './spec.mjs';
import {existsSync} from 'fs';
import {getAIS} from './ais.mjs';
import {getADSB, getADSBHistory, getADSBRange, initAircraftDb} from './adsb.mjs';
import {getAIS, getAISImage} from './ais.mjs';
import {getADSBImage, getADSB, getADSBHistory, getADSBRange, initAircraftDb} from './adsb.mjs';
import {fetchIcon} from './openweather.mjs';
import {getForecast, getWeatherCondition, forecastTTL} from './forecast.mjs';
import {dailyWeather, hourlyWeather} from './openmeteo.mjs';
@@ -155,8 +155,18 @@ app.get('/api/icon/:icon', asyncHandler(async (req, res, next) => {
// ── ADSB Proxy ────────────────────────────────────────────────────────────────
app.get('/api/adsb', asyncHandler(async (req, res) => res.json(await getADSB())));
app.get('/api/adsb-image/:icao', asyncHandler(async (req, res) => {
const blob = await getADSBImage(req.params.icao);
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) => {
const blob = await getAISImage(req.params.mmsi);
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())));
// ── DOCS ──────────────────────────────────────────────────────────────────────