You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Without breaking existing usage of your module, and without requiring node-config in their own app (unless they want).
Here's how it works:
Load node-config at the top of your module like normal, and specify the SUPPRESS_NO_CONFIG_WARNINGenvironment variable so applications don't get No config files warnings if they aren't using node-config.
Then do something like this where your configurations are passed in by the app:
functionmyModuleConstructor(configs){letmyDefaultConfigs={param1: "value1",param2: 22};// Orconst{ Load }=require("config/lib/util");constloader=newLoad({configDir: Path.join(__dirname,'./config')});myDefaultConfigs=loader.scan();// Mixin configs that have been passed in, and make those my defaultsconfig.util.setModuleDefaults('MyModule',myDefaultConfigs);}
Then use the config object as usual to access configurations within your module:
This pattern gives apps using your module the choice of using node-config mechanisms for configuration, or using your existing methods (as shown at the top of this page).
For example, they can put your module configurations next to their other configurations and extend configs based on deployment type: