How to use the set function from nconf

Find comprehensive JavaScript nconf.set code examples handpicked from public code repositorys.

64
65
66
67
68
69
70
71
72
73
/*
 * Hapi server instance
 */

if (_.isUndefined(nconf.get('HOST'))) {
  nconf.set('HOST', 'localhost');
}

if (_.isUndefined(nconf.get('PORT'))) {
  nconf.set('PORT', 1330);
fork icon0
star icon7
watch icon3

+ 3 other calls in file

71
72
73
74
75
76
77
78
79
80
    nconf.clear(key);
    return module.exports;
  },
//  save
//  load
//  set: (key, value) => nconf.set(encrypt(key, true), encrypt(value)),
};

function transform(data) {
  return {
fork icon0
star icon3
watch icon2

67
68
69
70
71
72
73
74
75
76
    if (value !== undefined) {
        nconf.set(prop, ['1', 1, 'true', true].includes(value));
    }
});
nconf.stores.env.readOnly = true;
nconf.set('runJobs', nconf.get('isPrimary') && !nconf.get('jobsDisabled'));

// Ensure themes_path is a full filepath
nconf.set('themes_path', path.resolve(paths.baseDir, nconf.get('themes_path')));
nconf.set('core_templates_path', path.join(paths.baseDir, 'src/views'));
fork icon0
star icon2
watch icon5

+ 50 other calls in file

112
113
114
115
116
117
118
119
120
121
        nconf.set('isPrimary', 'true');
        nconf.set('isCluster', 'false');
}

// Ensure themes_path is a full filepath
nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path')));
nconf.set('core_templates_path', path.join(__dirname, 'src/views'));
nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-persona/templates'));

nconf.set('upload_path', path.resolve(nconf.get('base_dir'), nconf.get('upload_path')));
fork icon0
star icon2
watch icon1

+ 15 other calls in file

107
108
109
110
111
112
113
114
    .argv()  // overrides everything
    .env()   // overrides config file
    .file({ file: __dirname + '/config/settings.json' });
  nconf.set('lib', __dirname + '/app');
  nconf.set('PORT', '5000');
  nconf.set('HOST', '127.0.0.1');
  return nconf;
}
fork icon0
star icon2
watch icon7

+ 5 other calls in file

87
88
89
90
91
92
93
94
95

  // set
  try {
    nconf.set(argv.key, JSON.parse(argv.value));
  } catch (e) {
    nconf.set(argv.key, JSON.parse('"' + argv.value + '"'));
  }
  return saveConfig();
};
fork icon438
star icon0
watch icon64

+ 7 other calls in file

325
326
327
328
329
330
331
332
333
334
    'nodebb-plugin-mentions',
    'nodebb-plugin-dbsearch',
];
const inactivePlugin = 'nodebb-plugin-emoji';
beforeEach((done) => {
    nconf.set('plugins:active', activePlugins);
    done();
});
afterEach((done) => {
    nconf.set('plugins:active', undefined);
fork icon0
star icon3
watch icon5

+ 11 other calls in file

66
67
68
69
70
71
72
73
74

clear () {
  logger('clear')
  return Promise((resolve,reject)=>{
    logger('clearing')
    nconf.set(null, {})

    nconf.save((err)=>{
      if(err){ return reject(err) }
fork icon0
star icon0
watch icon2

+ 5 other calls in file

177
178
179
180
181
182
183
        } else if (file.existsSync(fallback)) {
                themePath = fallback;
        }

        nconf.set('theme_templates_path', themePath);
        nconf.set('theme_config', path.join(nconf.get('themes_path'), themeObj.id, 'theme.json'));
};
fork icon0
star icon0
watch icon13

+ 7 other calls in file