3

I want to use the nconf module to retriever configuration data from a file(s) according to a policy and export the properties in the JSON configuration files as a module like so:

import * as config from 'ConfigData'

console.log(config.MyProperty)

The ConfigData module is just wrapping nconf defining the policy of the naming scheme of the config files and what order to load the files.

var myconfig = new nconf.Provider({
  env: true,
  argv: true,
  stores: [
     { type: 'file', file: path.join(__dirname, 'config.json')},
     { type: 'file', file: path.join(__dirname, 'default-config.json')}
  ] 
});

How do I export the config properties in the JSON file and how does the client code use it?

Nathan
  • 835
  • 3
  • 11
  • 20

0 Answers0