Alokai

ConfigSwitcherExtensionParams

Extension methods defined in the middleware config-switcher configuration.

interface ConfigSwitcherExtensionParams<TIntegrationConfig extends IntegrationConfig = IntegrationConfig> {
	cacheTTL?: number;
	configuration: (() => Promise<Record<ConfigId, DeepPartial<TIntegrationConfig>>>) | Record<ConfigId, DeepPartial<TIntegrationConfig>>;
	defaultHeaderValue?: string;
	switchStrategy?: {
    resolveConfigId: ConfigIdResolver;
  } | BuiltInStategyName;
}

Properties

NameRequiredTypeDescription
cacheTTLOptionalnumberConfiguration cache TTL in seconds. Determines how long the configuration data is cached in memory. This helps in optimizing performance by reducing the need to fetch configuration data on every request. 10
configurationRequired(() => Promise<Record<ConfigId, DeepPartial<TIntegrationConfig>>>) | Record<ConfigId, DeepPartial<TIntegrationConfig>>Configuration map or function returning configuration map. The configuration can be provided directly as an object or as an async function. This allows for dynamic fetching of configuration data, such as from an API.
defaultHeaderValueOptionalstringDefault header value to use when the x-alokai-middleware-config-id header is not present. This is only used when the switchStrategy is set to 'header'. 'default'
switchStrategyOptional{ resolveConfigId: ConfigIdResolver; } | BuiltInStategyNameStrategy for resolving configuration key. Can be either a built-in strategy name or a custom resolver object. 'header'

Referenced Types

On this page