@equinor/fusion-framework-module-app-config v2.0.0
Module App Config
📦 Module for providing application with config as an service
Dependencies
Optional
- http is not required if
IHttpClientis provided- service-discovery is not required if
IHttpClientis configure with keyappConfigin http module
Basic
This module should be implemented by the framework and provided by the application framework.
Lifecycle
Configure
case 1: No reference modules are provided (Framework)
The IAppConfigConfigurator will not have any default IHttpClient
case 2: HttpModule and ServiceDiscoveryModule are provided (App)
Before the configurator is created, the module will check ref modules if http has configured a client,
then if not, try to resolve client from service discovery. The client will be assigned to the IAppConfigConfigurator
Initialize
case 1: No IHttpClient is provided (Framework)
- The module will await init of
HttpModule - The module will try to create a
IHttpClient - If no client was created in step 2, it will await init of
ServiceDiscoveryModulefor client - The module will create an
IAppConfigProviderwhich is provided toIAppConfigProvider;
case 2: IHttpClient is provided (App)
The module will create an IAppConfigProvider which is provided to IAppConfigProvider;
Advance Config
🤙🏻 when working within the Fusion eco system none of these configs should be necessary.
Configure your own http client
import { appConfigModuleKey } from '@equinor/fusion-framework-module-app-config'
modules.http.configureClient(
appConfigModuleKey,
{
baseUri: 'https://foo.bar',
defaultScopes: ['foobar/.default'],
},
(client) => {
client.requestHandler.setHeader('x-api-version', '1.0.0-beta.2');
client.requestHandler.add('logger', console.log);
client.responseHandler.add('logger', console.log);
}
);Configure endpoint generation
config.appConfig.generateUrl = (appKey: string, tag?: string) => {
return `/api/apps/${appKey}/config${tag ? `?tag=${tag}` : ''}`;
}Configure response selector
config.appConfig.selector = async(result: Response): Promise<AppConfig<TEnvironment>> => {
const data = await result.json();
/** custom logic for extracting and normalizing data to valid app config */
return normalizeAppConfigResponseData(data);
}Defining your custom http client
☢️ Boss mode only, really understand framework before even attempt
class MyCustomClient implements IHttpClient {} config.appConfig.httpClient = new MyCustomClient
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago