2

Using node-config, is there anyway to do

var config = require('config');
config.ip = someIp;

I need to get my ips dynamically and use them in my config. Is there anyway to do this?

I tried just setting it but it's a read only property. I also looked at the code but could not see a way to do it. Please don't make me change my config framework :(

thanks,

R

Raif
  • 8,641
  • 13
  • 45
  • 56
  • You can store your config in a js file. Since its a js file you can change the properties dynamically. – bluesman Jul 28 '15 at 22:00
  • aha! or duh! hmm, yea, I should have thought of that! I'll try that now. Thanks. That said .... seems like I shouldn't have to do that. Why not let me modify my freakin config file programmaticly. – Raif Jul 28 '15 at 23:46

1 Answers1

3

So I guess I found the answer. If you declare

process.env['ALLOW_CONFIG_MUTATIONS']=true;

Then you can use the set method on config values. To be specific, you can set 'ALLOW_CONFIG_MUTATIONS' to anything besides null or undefined and it should work.

Raif
  • 8,641
  • 13
  • 45
  • 56