Merge remote-tracking branch 'upstream/main' into fix/adsbdb-cache-and-rate-limit

main now reads adsbdb bodies through readResponseJsonCapped. That capped
payload feeds this branch's bounded store via remember(), so both the size cap
and the entry cap apply.
This commit is contained in:
daikaginza committed 2026-10-16 09:26:47 +07:00
commit c20af07adb
581 files changed
+91707 -2550

No files matched your search

+12 -4
View File
@@ -1,6 +1,10 @@
import path from 'node:path';
import { promises as fsp } from 'node:fs';
import { makeRateLimiter, clientKey } from '../common/rate-limit.js';
import { readResponseJsonCapped } from '../common/http.js';
/** Route and aircraft lookups are a few hundred bytes; 1 MiB is a hard bound. */
const ADSBDB_MAX_RESPONSE_BYTES = 1024 * 1024;
/**
* adsbdb.com enrichment proxy: callsign → route (airline + origin/destination
* airports) and hex → aircraft type/registration. Free community API — cached
@@ -168,12 +172,16 @@ export function adsbdbProxy(options = {}) {
kind === 'route'
? `https://api.adsbdb.com/v0/callsign/${encodeURIComponent(key)}`
: `https://api.adsbdb.com/v0/aircraft/${encodeURIComponent(key)}`;
const res = await fetch(url, { signal: AbortSignal.timeout(8000) });
const signal = AbortSignal.timeout(8000);
const res = await fetch(url, { signal });
if (res.ok) {
const payload = await readResponseJsonCapped(
res,
ADSBDB_MAX_RESPONSE_BYTES,
signal,
);
const data =
kind === 'route'
? parseRoute(await res.json())
: parseAircraft(await res.json());
kind === 'route' ? parseRoute(payload) : parseAircraft(payload);
// data may be null — negative cache
remember(store, key, { at: Date.now(), data });
return data;