Skip to content

Add support for dynamic config #100

@seanpk

Description

@seanpk

I find the BlueOak Server config handling/service to be very handy.
(See "2. Simple configuration for runtime environments" here.)

Even so, there are times where a more dynamic config is needed.
It could be because

  1. non-JSON compliant data types are needed, say a RegExp or a Function (see also Add support for CORS origins defined by regular expressions #99)
  2. where there is a desire to have the config updated in some way over the life of the application (NOTE: to take advantage of the feature for this case, user code will need to expect the config to change, and re-get it from the config service instead doing one-time setup based on it or keeping a module-level copy of it)

Discussion

Can node-config's .js file support be used to achieve these things?

I think we might be able to get it to work using "raw" support.

However, this would require users to change to use .js config files instead of the .json setup that has been used in all BOS examples.

If this works, and we're OK with that, we just need some docs and an example about it.

An Alternate Idea

Follow the approach in node-config for custom environment variables, and use a special config file name, say config/bos-dynamic-config.json to identify where dynamic config should be added in to the config object, and which file to require to get to it.

Probably we would require that file JavaScript files are in config/bos-dynamic-config/.
We'll likely have some sort of convention regarding the exported function that would be called to get the value to insert at that place in the config. Say getConfig(configEnv), where configEnv is an object whose keys are the names of the parameters that affect how node-config builds the resulting config and the values are their values, namely, instance, deployment, shortHostname, and fullHostname.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions