GODSIGH/js/config.js
jing bb09bcfae7 harden ADSBx quota guard: 5-min → 10-min single-flight cache
The $10 ADSBx BASIC tier has NO hard limit and bills $0.0015/request over
10k/month, so the cache TTL must guarantee we stay under. Widened the cache
window 5→10 min: since proxy_cache_lock coalesces all requests into ONE upstream
call per window, this caps upstream at ~144 calls/day (~4.4k/month, <half the
10k cap) regardless of visitors or poll rate. Prod nginx also got
proxy_cache_lock_timeout/age for a hard single-flight guarantee even under a slow
upstream. Dev serve.py ADSBX_CACHE_SEC 300→600 to match. Frontend poll stays
5 min for display freshness (cheap cache hits; the server cache governs quota).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 23:51:57 +10:00

142 lines
5.5 KiB
JavaScript

// GODSIGH configuration — every URL, interval, and tunable in one place.
// All feed paths are RELATIVE so the app works identically at "/" (dev) and
// "/godsigh/" (prod). Never introduce a leading-slash path.
export const CONFIG = {
// Same-origin proxy endpoints (serve.py in dev; nginx location blocks in prod).
proxy: {
opensky: 'proxy/opensky',
celestrak: 'proxy/celestrak',
},
basemaps: {
// Data Mode — dark high-contrast raster.
dark: {
url: 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c', 'd'],
credit: '© OpenStreetMap contributors © CARTO',
maximumLevel: 19,
},
// Photo Mode — Sentinel-2 cloudless mosaic (no key).
photo: {
url: 'https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless-2023_3857/default/g/{z}/{y}/{x}.jpg',
credit: 'Sentinel-2 cloudless by EOX — modified Copernicus Sentinel data 2023',
maximumLevel: 14,
},
},
// Timeline spans now ± windowHours.
windowHours: 6,
// Live-only layers (aircraft, live AIS) pause when the clock is scrubbed
// further than this from wall-clock now.
liveThresholdSec: 600,
// Camera opens on the Persian Gulf theater.
camera: { lon: 53.0, lat: 25.5, height: 2_800_000 },
satellites: {
sampleStepSec: 60, // one SGP4 sample per minute across the window
cap: 120, // hard ceiling on tracked satellites
// Each source is one Celestrak query. `filter` = keep only names containing
// one of these tokens; `keepOnly` = keep only these exact names; `max` =
// cap this source's contribution so one big constellation can't crowd out
// the rest. Rare/high-value sources are listed first so the global cap
// never starves them.
sources: [
{ q: 'GROUP=stations&FORMAT=tle', keepOnly: ['ISS (ZARYA)', 'CSS (TIANHE)'] },
{ q: 'NAME=COSMOS%202486&FORMAT=tle' }, // Russian Persona-class recon
{ q: 'NAME=COSMOS%202506&FORMAT=tle' },
{
q: 'GROUP=resource&FORMAT=tle',
filter: ['WORLDVIEW', 'LEGION', 'PLEIADES', 'CAPELLA', 'GAOFEN', 'SKYSAT',
'ICEYE', 'UMBRA', 'LANDSAT', 'SENTINEL-1', 'SENTINEL-2',
'GEOEYE', 'KOMPSAT', 'CARTOSAT', 'RESURS'],
},
{ q: 'NAME=GAOFEN&FORMAT=tle', max: 30 }, // large Chinese EO fleet — cap it
],
},
aircraft: {
// null bbox = global (a global states/all call costs the same 4 credits as
// any large bbox). Or set {lamin, lomin, lamax, lomax}.
bbox: null,
pollMs: 90_000,
// Callsign prefixes flagged as military (highlighted + optionally filtered).
// Trimmed OpenSky callsigns are matched by prefix. Curated list of common
// NATO/allied air-transport & tanker call words; extend freely.
militaryPrefixes: ['RCH', 'REACH', 'LAGR', 'DUKE', 'POLO', 'CNV', 'RRR',
'ASCOT', 'GAF', 'BAF', 'IAM', 'PLF', 'HKY', 'NATO',
'CFC', 'MC', 'SAM', 'EVAC'],
},
// Earthquakes — USGS GeoJSON. Direct browser fetch (ACAO:*), no proxy needed.
// Full https URL by design (cross-origin feed, not a same-origin path).
quakes: {
url: 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson',
refreshMs: 300_000, // 5 min
cap: 400, // hard ceiling on rendered quakes (drop smallest mag first)
labelMinMag: 4.5, // only label quakes at/above this magnitude (declutter)
magRamp: [2, 6], // color/size lerp domain
},
// Wildfires — NASA EONET. Direct fetch (ACAO:*). NOTE: EONET mislabels its
// Content-Type as application/rss+xml, but the body is JSON — never gate on
// the header; res.json() works regardless.
fires: {
url: 'https://eonet.gsfc.nasa.gov/api/v3/events?category=wildfires&status=open&limit=500',
refreshMs: 900_000, // 15 min
cap: 500,
},
// Military aircraft — ADS-B Exchange /v2/mil/ (REAL unfiltered military, the
// OSINT prize OpenSky hides). Paid RapidAPI feed with OVERAGE billing over
// 10k/month (no hard block), so the same-origin proxy injects the key
// server-side AND single-flight-caches /v2/mil/ for 10 min: the *cache TTL*
// (not this poll) governs the upstream quota → max ~144 calls/day (~4.4k/mo,
// <half the cap). The browser polls faster only for display freshness (cheap
// cache hits).
adsbx: {
proxyMil: 'proxy/adsbx-mil', // RELATIVE — works at "/" and "/godsigh/"
pollMs: 300_000, // 5 min display refresh (server 10-min cache is the quota guard)
},
// Optional live AIS. Leave blank to use the demo fleet only (roadmap feature).
AISSTREAM_API_KEY: '',
colors: {
// satellites (by name token)
GAOFEN: '#ff4d4d',
COSMOS: '#ff9f40',
WORLDVIEW: '#4dd2ff',
LEGION: '#4dd2ff',
CAPELLA: '#9d7bff',
PLEIADES: '#7bff9d',
SENTINEL: '#ffd24d',
ISS: '#ffffff',
CSS: '#ffffff',
satDefault: '#66ffcc',
// aircraft (by altitude band)
aircraftLow: '#ffb347',
aircraftMid: '#ffe74d',
aircraftHigh: '#4dd2ff',
aircraftMil: '#ff5964', // military-callsign tint (overrides altitude band)
militaryReal: '#ff453a', // REAL military (ADS-B Exchange feed)
militaryEmerg: '#ff2d95', // military squawking 7500/7600/7700 or emergency
// earthquakes (magnitude ramp: amber → red)
quakeMin: '#ffcf50',
quakeMax: '#ff3b30',
// wildfires
fire: '#ff7a1a',
// ships
shipNormal: '#7bff9d',
shipToll: '#ffe74d',
shipDark: '#ff4d4d',
shipIdle: '#8a97a3',
// infra
chokepoint: '#ff003c',
pipeline: '#ffbf40',
facility: '#35e0ff',
event: '#ff4d4d',
},
};