Skip to content

Repository files navigation

node-confmanager

A configuration manager.

Lines of Code Issues Pull requests

Reliability Rating Security Rating Maintainability Rating Vulnerabilities Bugs

Known Vulnerabilities

Installation

$ npm install node-confmanager

Features

  • All the features of the node-containerpattern package
  • clone data in "get" action to avoid unwanted changes
  • Saving the data in a JSON file
  • Load the data from this JSON file and/or commandline
  • access to the data with shortcuts in commandline
  • load data from ENV data
  • load data from specified env file (like ".env")
  • prio : env > console > envfile > conf file

Doc

Inheritance and behaviour

See the node-containerpattern documentation for skeletons, set / get, recursion, and validation.

Types and implementation

Examples

Full flow (save, load, typed get): test/typescript/compilation.cts

CLI usage

# if "debug" skeleton is set and defined as a boolean
node mysoft.js -d      # if "debug" shortcut is set with shortcut("debug", "d")
node mysoft.js --debug
node mysoft.js --debug "true"
node mysoft.js --debug "yes"
node mysoft.js --debug "y"
# if "arr" skeleton is defined as an array
node mysoft.js --arr test1 test2
node mysoft.js --arr "[ \"test1\", \"test2\" ]"

Programmatic snippet

const ConfManager = require("node-confmanager");
const conf = new ConfManager("./config.json", true /* pretty JSON */);

conf.skeleton("debug", "boolean").shortcut("debug", "d");

await conf.load({
  loadEnvFile: ".env",
  loadConsole: true,
  loadEnv: true,
});

await conf.set("name", "app").save();

Tests

npm run tests

License

ISC

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages