Comments (4)
I just found setModuleDefaults. I'm not really sure of how you view the default and non host specific config files but it would be great with a clarification on what you think they're for. I think it would be great if you could load the default config from a file instead of putting it in the code and call setModuleDefaults and defaults for different environments would be great too.
from node-config.
I see the issue now. The NODE_CONFIG_DIR is designed to be used by the end application on a specific host. It's not designed for use by module developers.
If you are a module developer, you need a way to specify your own module's defaults. That's the reason for the setModuleDefaults() method. It's a method vs. a file because at runtime node-config doesn't know all installed modules (there may be several), so your module should call setModuleDefaults() upon loading.
I hope that answers your question.
from node-config.
Oh, ok, then i misunderstood the setModuleDefaults method.
It's an application that i'm writing. What I'm trying to say is that even applications needs defaults and it's practical to store them in a file instead of calling setModuleDefaults (or handling them in some other way in the code).
When we update software at work we generally make a complete new installation in a new dir like this:
/some/path/some_software/releases/new_version/...
/some/path/some_software/releases/old_version/...
/some/path/some_software/current/... (points to currently used version)
/some/path/some_software/shared/config/
With this setup we can share the configuration (and some other stuff) between releases. The non host specific configs as far as I see them at least should still be specific for a specific release (because they are defaults set by the developer) and thus shouldn't be in the shared dir but rather in a config subdir for the release. The host specific configs I think should be shared though (because they are specified by the user).
An easy way to implement this would be by making the non host specific configs ignore the NODE_CONFIG_DIR env.
from node-config.
I see now what you're after. In this case I would use the setModuleDefaults method, and set your program-specific defaults using setModuleDefaults, and your deployment-specific parameters in your shared NODE_CONFIG_DIR.
You can also add machine specific or deployment specific files to your source repository so they're distributed with your code. We do it this way at work, and works well for private installations.
Changing the behavior of NODE_CONFIG_DIR is not an option as it would break existing installs. One option could be to add another environment variable pointing to program defaults vs. deployment configurations. This would allow you to do what setModuleDefault does - only in config files.
I'd like to be convinced that the added flexibility is worth the added complexity.
from node-config.
Related Issues (20)
- custom-environment-variables.json says variable is not defined. HOT 1
- Feature Request: First class Kubernetes secret files support HOT 3
- [BUG] Cypress component testing fails with error `<CONFIG_VARIABLE> is not defined`
- Deal With Async Properties in DeferConfig HOT 1
- [BUG] Documentation is missing HOT 4
- [BUG] custom-environment-variables file does not support cjs extension HOT 2
- [BUG] Extra quotes on config file broke app HOT 5
- Cannot use defer with esbuild (fix: export defer from config) HOT 1
- Unable to use
- [BUG] Configuration files with different extensions and APP_INSTANCE not loaded in the right order HOT 2
- [BUG] Javascript getters calling during config initialization
- [BUG] Empty key in YAML sets value to null HOT 2
- [BUG] Environment variable substitution fails silently if "__format" parser is not supported HOT 1
- Project breaks after updating ts version (using .cjs config files)
- v3.3.10 is a breaking change for webpack, which does not install json5 dep HOT 18
- Disable some "defaults", like local.{ext} loading HOT 1
- [BUG] node-config package.json has not all the parsers available installed as production dependencies HOT 6
- [BUG] YAML binary type is mangled
- [BUG] Encoungering an unexpected ENOTDIR while trying to open non-existing runtime.json
- [BUG] DeprecationWarnings in node v22 DEP0055 DEP0047 DEP0044
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-config.