1.0.1 • Published 2 years ago

@blinkhealth/config-yourself v1.0.1

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
2 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.

1.0.2

2 years ago

1.0.1

2 years ago

0.0.0-31ffb0a

2 years ago

0.0.0-fb5ab7d

2 years ago

0.0.0-69cf2ba

2 years ago

0.0.0-c797874

2 years ago

1.0.0

2 years ago