node_safe_config

1.0.1 • Public • Published

Node Safe Config

About

The idea was to make a way of configuring things in node as easy as using a typesafe config. There will be sensible defaults as a part of the repo. This will default to {process CWD}/config. This can be overwritten by the following with the first load. After the first time loading you no longer have to specify the conf_dir.

require("nodeSafeConfig")({conf_dir:"..."})

Usage

###Default config file in ./config/mongo.json

  {
    host: "127.0.0.1",
    db: "MyApp"
  }

###Override Config in /server_configs/mongo.json This config will contain environment properties. The nodeSafeConfig lib will replace anything in the default config with what is in the override config. When there are multiple override configurations the last folder provided is the top level config.

  {
    host: "production.mongo.myapp.com"
  }

###App Code in app.js

  var configs = require("nodeSafeConfig")()
  var mongoHost = configs.getVal("mongo", "host")

###CMD

node app.js --override_dirs="/server_configs,/myApp/moreconfigs"

###CMD With commandline overrides. This makes since for quick testing or pointing things somewhere else real quick without modifing configs. Any command line args will be taken over anything else in any config file

node app.js --override_dirs="..." --mongo.host="production.mongo.region2.myapp.com"

Package Sidebar

Install

npm i node_safe_config

Weekly Downloads

1

Version

1.0.1

License

(MIT OR Apache-2.0)

Last publish

Collaborators

  • benjar12