Cyclonecode
Cyclonecode

Reputation: 30001

Extend configuration with custom settings loaded from file

I am trying to extend the configuration for my application with value loaded from a custom configuration file. We are using node-config and this is what I am trying to do:

// Server entry
const config = require('config')

// Merge setting from our custom configuration
const customConfig = require('../config/custom.json')
config.extendDeep(config, customConfig)

The above works, but since we are also using caching for the generated configuration file I will also have to do the above when ever the configuration is reloaded.

I know that I for instance could create a config/<hostname>.json which will get merged, but the custom configuration file is generated from another system and I am not able to change the name of the file in this setup.

Is there a better way of adding settings from a custom configuration file using node-config?

Upvotes: 1

Views: 704

Answers (0)

Related Questions