Files
worldmonitor/api
Elie Habib 36be5667d5 feat(catalog): seed Dodo prices from Railway relay with proxy fallback (#2680)
* feat(catalog): seed Dodo prices from Railway relay, Vercel reads only

Dodo API rejects Vercel Edge datacenter IPs (401). Moved price
fetching to ais-relay seed loop on Railway (1h interval, 2h TTL).
Direct fetch first, PROXY_URL fallback if blocked.

Vercel /api/product-catalog now reads from Redis only (gold standard
pattern). Falls back to static prices if Redis empty.

* fix(catalog): change Dodo price seed interval to 12h (TTL 24h)

* fix(catalog): add fixed_price support, restore edge Dodo fallback on purge

P1: Seeder now reads product.price?.price ?? product.price?.fixed_price
(matches previous edge endpoint behavior).

P1: After cache purge, edge endpoint tries Dodo directly as backup
before falling back to static prices. If Dodo succeeds, re-caches.
Prevents 12h gap of fallback-only after manual purge.

* fix(catalog): don't overwrite seeded Redis key from edge, add seed-meta

P1: Edge fallback no longer writes to Redis (avoids overwriting the
Railway-seeded entry with short TTL). Returns result directly with
60s cache.

P2: Seeder now writes seed-meta:product-catalog with fetchedAt,
recordCount, and priceSource for health monitoring.

* fix(catalog): auth proxy, only write dodo-sourced prices, 6h interval

P1: Proxy path now sends Authorization header (ytFetchViaProxy doesn't
support custom headers, so manual CONNECT tunnel with auth).

P1: Only writes to Redis when ALL prices come from Dodo (priceSource=dodo).
Partial/fallback results extend existing TTL but don't overwrite.
Prevents transient outages from pinning stale prices for hours.

Interval: 6h seed, 12h TTL.

* fix(catalog): add health.js monitoring, consistent cachedUntil

P2: Added productCatalog to STANDALONE_KEYS + SEED_META in health.js
(maxStaleMin: 1080 = 3x 6h interval).

P2: Fallback response now includes cachedUntil (consistent contract).

P1: Proxy CONNECT pattern matches existing ytFetchViaProxy (USNI)
which works for Decodo TLS proxies.

* fix(catalog): respect parsed proxy TLS flag instead of forcing tls:true
2026-04-04 18:33:48 +04:00
..
2026-03-20 12:37:24 +04:00