19 lines
543 B
TypeScript
19 lines
543 B
TypeScript
import type { MarketEnv } from './types';
|
|
|
|
let marketEnv: MarketEnv | undefined;
|
|
|
|
/** Called by each app bootstrap, on the server and in the browser. Idempotent. */
|
|
export function setEnv(env: MarketEnv): void {
|
|
marketEnv = env;
|
|
}
|
|
|
|
/** Read inside functions, never at module top level: bootstrap may not have run yet. */
|
|
export function getEnv(): Readonly<MarketEnv> {
|
|
if (!marketEnv) {
|
|
throw new Error(
|
|
'market env is not set. The app bootstrap must call setEnv from @lumina/market/env first.',
|
|
);
|
|
}
|
|
return marketEnv;
|
|
}
|