2.0.0 • Published 1 year ago

@equinor/fusion-framework-module-app-config v2.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Module App Config

📦 Module for providing application with config as an service

Dependencies

Optional

  • http is not required if IHttpClient is provided
  • service-discovery is not required if IHttpClient is configure with key appConfig in 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)

  1. The module will await init of HttpModule
  2. The module will try to create a IHttpClient
  3. If no client was created in step 2, it will await init of ServiceDiscoveryModule for client
  4. The module will create an IAppConfigProvider which is provided to IAppConfigProvider;

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
1.1.1

1 year ago

1.0.2

2 years ago

1.1.0

1 year ago

1.0.1

2 years ago

1.0.16

2 years ago

1.1.9

1 year ago

1.1.8

1 year ago

1.0.9

2 years ago

1.1.7

1 year ago

1.0.8

2 years ago

1.1.6

1 year ago

1.0.7

2 years ago

1.1.5

1 year ago

1.0.6

2 years ago

1.1.4

1 year ago

1.0.5

2 years ago

1.1.3

1 year ago

1.0.4

2 years ago

1.1.2

1 year ago

1.0.3

2 years ago

1.0.0-alpha.0

2 years ago

1.1.12

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

2.0.0

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.0.1-next.1

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.1.21

1 year ago

1.1.20

1 year ago

1.0.15

2 years ago

0.3.2

2 years ago

1.0.14

2 years ago

0.3.1

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

0.3.0

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago