confmgr

confmgr is (yet another) configuration manager for your NodeJS apps. It is written in Typescript and thus supports Typescript as well as Javascript.

Why another one?

confmgr brings interesting features that are not available in libs. While focusing on ease of use, it brings features that no longer need to be part of your app such as:

Features at a glance
  • type conversion (variables from ENV are always strings, confmgr converts them for you)

  • mandatory values: If you miss a value, confmgr will tell you before your app explodes…​

  • default values: confmrg handles default values for you

  • regular expressions: confmgr allows you defining a regexp that will allow checking the validity of the loaded config

  • masked variables: handy for your secrets, read below

Helper functions

After getting your config object with GetConfig(), you can simple use it with config['MYAPP_MYMODULE_VAR1'] or use some of the helper methods attached to your config.

confmgr brings a set of handy methods such as Print() that will display the content of your config while ensuring that your secrets do NOT show up in any log or output.

Printing your config may use colors or not. Here is an example with color coming from running config.Print():

===> TS_SAMPLE_MODULE_01 ENV:
✅ PARAM1: some param1
    value: 12
✅ PARAM2: some param2
    value: 44
✅ SECRET: some secret
    value: *****                                <---- Notice how this value has been masked
✅ REGEXP: some regexp
    regexp: ^\d{2}_\d{2}
    value: 68_77
✅ MANDAT_WITH_DEF: some optional param
    value: 42
❌ MANDAT_NO_DEF: some optional param           <----- It looks like we forgot to pass a value
    value: undefined
Note
If you are using a custom logger, you may also pass it to the Print() method so the output gets nicely integrated to your logs while NOT revealing any of your secrets.

You can read more about it at https://gitlab.com/chevdor/confmgr

Avatar
Wilfried Kopp
Building Blockchains & Decentralized Solutions

I am building decentralized solutions and tooling to support them. I am developing Smart Contracts on Ethereum and Substrate while aspiring at being more proficient in Rust. GPG Fingerprint 15AF C574 D3F9 F1C3 CCDD E31E 2DCE C4DC 506E 6475