mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 03:10:54 +00:00
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
/** Injection token carrying the resolved {@link ExchangeOptions}. */
|
|
export const EXCHANGE_OPTIONS = Symbol("EXCHANGE_OPTIONS");
|
|
|
|
/** Configuration for the {@link ExchangeService} and its CBE provider. */
|
|
export interface ExchangeOptions {
|
|
/**
|
|
* ethio.forex CBET page scraped for USD buying/selling rates.
|
|
* @default 'https://ethio.forex/bank/CBET'
|
|
*/
|
|
scrapeUrl?: string;
|
|
|
|
/**
|
|
* Base USD→ETB rate used when scraping fails and no previously cached rate
|
|
* exists. The ETB→USD direction is derived as its inverse.
|
|
* @default 130
|
|
*/
|
|
fallbackRate?: number;
|
|
|
|
/**
|
|
* How long a successfully fetched rate is cached, in milliseconds.
|
|
* @default 3_600_000 (1 hour)
|
|
*/
|
|
cacheTtlMs?: number;
|
|
|
|
/**
|
|
* Timeout for the scrape HTTP request, in milliseconds.
|
|
* @default 8_000
|
|
*/
|
|
requestTimeoutMs?: number;
|
|
}
|
|
|
|
/** Defaults applied to any unset {@link ExchangeOptions} field. */
|
|
export const EXCHANGE_DEFAULTS: Required<ExchangeOptions> = {
|
|
scrapeUrl: "https://ethio.forex/bank/CBET",
|
|
fallbackRate: 130,
|
|
cacheTtlMs: 3_600_000,
|
|
requestTimeoutMs: 8_000,
|
|
};
|
|
|
|
/** Factory contract for {@link ExchangeModule.forRootAsync}. */
|
|
export interface ExchangeAsyncOptions {
|
|
/** Providers to inject into {@link useFactory} (e.g. `[ConfigService]`). */
|
|
inject?: unknown[];
|
|
/** Returns the options, possibly async. */
|
|
useFactory: (...args: never[]) => ExchangeOptions | Promise<ExchangeOptions>;
|
|
}
|