Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to use references to sub config parts #431

Closed
stalniy opened this issue Aug 25, 2017 · 3 comments
Closed

Possibility to use references to sub config parts #431

stalniy opened this issue Aug 25, 2017 · 3 comments

Comments

@stalniy
Copy link

stalniy commented Aug 25, 2017

Expected Behavior:

I have several functions which consumes own configuration + logger configuration, so I'd like to reference logger configuration from another configuration (Such behavior exists in Ruby on Rails Yaml parser, more info)

{
  domainTracker: {
     "logger": {
        "<<":  "*logger",
     }
     "path": "/api"
  },

  "errorHandler": {
     "logger": {
        "<<":  "*logger",
     }
     "debug": true
  },

  "logger": {
     "server": "..."
  }
}

afterwards when I do config.get('domainTracker') I expect logger configuration to be included as part of domainTracker configuration:

const config = config.get('domainTracker');

/*
{
  "domainTracker": {
     "logger": { "server": "...." },
     "path": "/api"
  }
}
*/

callMe(config);

Actual Behavior:

I need manually pass different configurations into my functions:

callMe(config.get('domainTracker'), config.get('logger'));

This is a bit inconvenient in case if you want all your functions to have standardized API (e.g., single argument with options object) and configure each function independently. So, this can be called kind of "Config injection" feature :)

@markstos
Copy link
Collaborator

You can refer to other parts of the configuration when using the JavaScript file format and defer() functions as documented here: https://github.com/lorenwest/node-config/wiki/Configuration-Files#javascript-module---js

If you want to store parts of the configuration in JSON, the JavaScript config file format can read in JSON files.

Does that address your need?

@stalniy
Copy link
Author

stalniy commented Dec 29, 2017

Actually I would prefer to keep my config simple and not use JS.

It would be good at least to provide a simple way to register key processor, so I can implement this as a separate extension

@iMoses
Copy link

iMoses commented Jul 11, 2019

@markstos I think it can be closed..
The new Parser enables the ability to create such customizable parsers..

@stalniy stalniy closed this as completed Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants