@blinkhealth/config-yourself
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@blinkhealth/config-yourself

Coverage Statusnpm version

A typescrypt + javascript runtime for decrypting go-config-yourself files.

It takes a bunch of config objects, deep merges them and then decrypt the resulting values (if any) in an async fashion.

Usage

import Config, { parse } from '@blinkhealth/config-yourself';

// Remember any environment variables are ALWAYS strings
process.env.CONFIG.overrideThisValue = 'true';

encrypted = new Config(
    // Config will load your config files
    parse.file('./config/defaults.yaml'),
    parse.file(`./config/${process.env['NODE_ENV']}.yaml`),
    // And will parse environment variables to override these configs
    parse.env()
)

async function run():void {
  cfg = await encrypted.decrypt({ password: "password" })
  // At this point, this value is not secret anymore!
  console.log(`secret: ${cfg.secret}`)
  // Note this value got casted to a boolean after being overriden from the environment
  console.log(cfg.overrideThisValue)
}

/*
Outputs:
> secret: hello dev world
> true
*/

See the example for more.

Readme

Keywords

none

Package Sidebar

Install

npm i @blinkhealth/config-yourself

Weekly Downloads

2

Version

1.0.1

License

Apache-2.0

Unpacked Size

67.4 kB

Total Files

53

Last publish

Collaborators

  • derrick.pace
  • blinkhealth-npm-admin
  • unrob