A simple config module
Why Occam's Config?
- Encourages Build Once Run Anywhere Node.js App Containers
- No opinion of config file name or location
- Load additional config files to merge properties
- Load configs from https endpoints
previous versions
first things's first...
$ npm i occams-conf
Usage
load main config via occams settings
const config = ; console;
load another config merged with main
const config = ;config; console;console;
load config from https url with loaderConfig
// example loaderConfig:// {// "path": "https://raw.githubusercontent.com/lxghtless/occams-conf/v2.0.1/config.js"// }const config = ; async { await config; console;};
load config from https url with loadConfig method
const config = ; async { await config; console;};
occams-conf
settings file (aka locatorConfig)
- name (config file name) [String]
- path (config path) [String]
Any of these will work and will resolve the first one found in this order.
occams.conf.json
occams.conf.js
const conf = name: 'config.js' path: 'src'; moduleexports = conf;
package.json
default
- name:
config.js
- path:
$HOME directory if globally installed || cwd
config.js
Example moduleexports = port: processenvTEST_PORT || 8011 name: processenvTEST_NAME || 'starlord' resourceUrl: processenvTEST_URL || 'https://reqres.in/api/mixtapes';
Windows Users
If an error resembling the following occurs, please check out the link below it.
PS C:\src\{projectfolder}> npm start > file-sage@1.0.0 start C:\src\{projectfolder}> node src/index.js Error: ENOENT: no such file or directory, lstat 'C:\Users\{username}\AppData\Roaming\npm\node_modules' at Object.realpathSync at Object.<anonymous> at Module._compile at Object.Module._extensions..js at Module.load at Function.Module._load at Module.require at require at isGloballyInstalled at getLocatorConfigPath