mirror of
https://github.com/Such-Software/smirk-backend-core.git
synced 2026-10-22 09:48:41 +02:00
feat: fiat price feed with per-feed operator control (GET /api/v1/prices)
Cached crypto→fiat price feed, refreshed by a background task and served from an in-memory snapshot — no upstream call on the request path. Public and feature-flagged: when FEATURE_PRICES is off, /prices is 404 and no upstream is ever contacted. Per-feed control, as a public server needs: PRICES_ASSETS narrows which feeds an instance quotes (unset = all supported; an explicit list serves a subset; empty serves none), validated fail-closed against SUPPORTED_PRICE_ASSETS. Provider (PRICES_PROVIDER, coingecko) and currency (PRICES_CURRENCY, usd) are configurable; the refresh interval is clamped to a provider-friendly minimum. - infra/prices: PriceClient (feed whitelist → provider coin ids), bounded by the HTTP client timeout; non-finite/negative/missing quotes are skipped, not faked. A fetch failure keeps the last good snapshot. Drift guard: a test asserts the provider mapping covers exactly SUPPORTED_PRICE_ASSETS. - main: background refresh task only when enabled and at least one feed is set. - AppState.prices snapshot; handler 404s when disabled. - openapi (prices tag); unit tests + L1 test over both feature-flag states.
This commit is contained in:
@@ -6,6 +6,7 @@ pub mod health;
|
||||
pub mod middleware;
|
||||
pub mod nip05;
|
||||
pub mod openapi;
|
||||
pub mod prices;
|
||||
pub mod users;
|
||||
pub mod wallet;
|
||||
pub mod website;
|
||||
|
||||
Reference in New Issue
Block a user