1.0.1 • Published 4 years ago

@blinkhealth/config-yourself v1.0.1

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
4 years ago

@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.