Code Monkey home page Code Monkey logo

Comments (4)

vonbirdie avatar vonbirdie commented on May 19, 2024

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.

lorenwest avatar lorenwest commented on May 19, 2024

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.

vonbirdie avatar vonbirdie commented on May 19, 2024

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.

lorenwest avatar lorenwest commented on May 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.