// BENCH-HIDDEN — эталонное решение задачи 5: курсы с кэшем на 10 минут и таймаутом 5 с. export const CURRENCIES = ["USD", "EUR", "RUB"]; const TTL_MS = 10 * 60_000; let cache = null; export class RatesUnavailable extends Error {} export async function getRates(now = Date.now()) { if (cache && now - cache.at < TTL_MS) return cache.rates; try { const r = await fetch(`${process.env.RATES_API_URL}/v1/latest?base=KZT`, { signal: AbortSignal.timeout(5000) }); if (!r.ok) throw new Error(`status ${r.status}`); const b = await r.json(); cache = { at: now, rates: b.rates }; return b.rates; } catch (e) { if (cache) return cache.rates; throw new RatesUnavailable(String(e)); } }