Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@equinor/fusion-framework-module-app-config

Package Overview
Dependencies
Maintainers
3
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@equinor/fusion-framework-module-app-config

Fusion module for application config

  • 0.3.2
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
3
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 05 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc