diff --git a/packages/backend-common/src/config.ts b/packages/backend-common/src/config.ts index 9b0eb8dcd0..5b09d66608 100644 --- a/packages/backend-common/src/config.ts +++ b/packages/backend-common/src/config.ts @@ -84,51 +84,66 @@ export class ObservableConfigProxy implements Config { has(key: string): boolean { return this.select(false)?.has(key) ?? false; } + keys(): string[] { return this.select(false)?.keys() ?? []; } + get(key?: string): T { return this.select(true).get(key); } + getOptional(key?: string): T | undefined { return this.select(false)?.getOptional(key); } + getConfig(key: string): Config { return new ObservableConfigProxy(this.logger, this, key); } + getOptionalConfig(key: string): Config | undefined { if (this.select(false)?.has(key)) { return new ObservableConfigProxy(this.logger, this, key); } return undefined; } + getConfigArray(key: string): Config[] { return this.select(true).getConfigArray(key); } + getOptionalConfigArray(key: string): Config[] | undefined { return this.select(false)?.getOptionalConfigArray(key); } + getNumber(key: string): number { return this.select(true).getNumber(key); } + getOptionalNumber(key: string): number | undefined { return this.select(false)?.getOptionalNumber(key); } + getBoolean(key: string): boolean { return this.select(true).getBoolean(key); } + getOptionalBoolean(key: string): boolean | undefined { return this.select(false)?.getOptionalBoolean(key); } + getString(key: string): string { return this.select(true).getString(key); } + getOptionalString(key: string): string | undefined { return this.select(false)?.getOptionalString(key); } + getStringArray(key: string): string[] { return this.select(true).getStringArray(key); } + getOptionalStringArray(key: string): string[] | undefined { return this.select(false)?.getOptionalStringArray(key); } @@ -184,6 +199,7 @@ export async function loadBackendConfig(options: { } }), }, + remote: { reloadIntervalSeconds: 10 }, }); options.logger.info( diff --git a/packages/config-loader/src/loader.ts b/packages/config-loader/src/loader.ts index 338f199132..b8fab12917 100644 --- a/packages/config-loader/src/loader.ts +++ b/packages/config-loader/src/loader.ts @@ -24,7 +24,6 @@ import { applyConfigTransforms, createIncludeTransform, createSubstitutionTransform, - EnvFunc, isValidUrl, readEnvConfig, } from './lib'; @@ -51,29 +50,6 @@ export type LoadConfigOptionsRemote = { reloadIntervalSeconds: number; }; -/** @public */ -export type RemoteConfigProp = { - /** - * URL of the remote config - */ - url: string; - - /** - * Contents of the remote config - */ - content: string | null; - - /** - * An optional new ETag header value. Used when checking for updated config. - */ - newETag?: string; - - /** - * An optional old ETag header value. Used when checking for updated config - */ - oldETag?: string; -}; - /** * Options that control the loading of configuration files in the backend. * @@ -229,7 +205,10 @@ export async function loadConfig( try { remoteConfigs = await loadRemoteConfigFiles(); } catch (error) { - throw new ForwardedError(`Failed to read remote configuration file, ${error}`); + throw new ForwardedError( + `Failed to read remote configuration file`, + error, + ); } }