npm.io
1.0.5 • Published 4 years ago

@turnkeyid/configurator-sdk

Licence
MIT
Version
1.0.5
Deps
8
Size
104 kB
Vulns
1
Weekly
0

Welcome to TurnkeyID Configurator SDK!

License: MIT Author: @fatihaziz Community: TurnkeyID Devs

Ready to use vault config loader with session

Goal

  • Services can have centralized config, but local config still has control over
  • Ability to fail-over and prioritize sources : (SESSION(Non-Expired) -> VAULT -> LOCAL -> SESSION)

How to use

  1. Install this package
    npm install --save @turnkeyid/configurator-sdk
    # or
    yarn add @turnkeyid/configurator-sdk
  2. Create your own logger function:
       // ./configs/my_service_config.ts
       export const MyServiceConfigurator = ConfiguratorSDK.create<MyServiceConfig>({
          configuratorAppRootDir: process.cwd(),  // *required, where root dir of the program lies
          configMapper: config => config,
          configName: 'MY_SERVICE_CONFIGURATOR',
          configPath: 'my_service_config',
          configuratorSettingOverride: {
             sessionStorageDir: "sessions", // path / dir relative to configuratorAppRootDir!
             localRootDir: "local_configs", // path / dir relative to configuratorAppRootDir!
          },
        })
  3. Import it anywhere:
    
       // ./index.ts
       import { MyServiceConfigurator } from './configs/my_service_config.ts'
    
       // remember you need to wrap await with async function
       // get all configs
       const configs = await MyServiceConfigurator.get()
       // result : MyServiceConfig[]
    
       // get by config id
       const configId1 = await MyServiceConfigurator.getByID(1) 
       // result : MyServiceConfig | undefined
Change Logs
  • v1.0.3:
    • Fixes:
      • Fix sessionHistory setting don't work
      • Fix history files pilled up uncontrollable.
  • v1.0.2:
    • Introduce README
    • BREAKING change, ConfiguratorSettingsType -> ConfiguratorSetting
    • BREAKING change, configuratorAppRootDir is required on create configurator!
    • Ability to save session version history, sessionHistory (default: true)
    • Ability to set priority config source VAULT or LOCAL (default: VAULT)
    • Performance improvement
  • v1.0.1:
    • Project initialized
Author

TurnkeyID Developers - Fatihaziz

Question

if you have any question, please contact here:

Show your support

Give a ️ if this project helped you!

Keywords