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