How to use configue - 3 common examples

To help you get started, we’ve selected a few configue examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AdrieanKhisbe / configue / examples / basic-with-async-hooks.js View on Github external
const Configue = require('configue');

const configueOptions = {
  async: true,
  postHooks: {
    argv: function postArgv(nconf) {
      // Perform some async operation to fetch value on mongo, etcd, api or else
      return Promise.resolve('42').then(apiValue => {
        nconf.set('hook', `async post-argv hook:${apiValue}`);
      });
    }
  }
};

Configue.withOptions(configueOptions).resolve(configue => {
  const who = configue.get('who', 'World');
  const hook = configue.get('hook', 'none');

  console.log(`Configue: {who: ${who}, hook: ${hook}}`);
});
github AdrieanKhisbe / configue / examples / async-with-protocalls.js View on Github external
const Configue = require('configue');

const configueOptions = {
  async: true,
  disable: {env: true},
  protocall: true,
  files: [{file: './config-with-protocalls.json'}]
};

Configue.withOptions(configueOptions)
  .resolve()
  .then(configue => {
    console.log(`Secret ${configue.get('salute', 'Hello')} to ${configue.get('who', 'World')}`);
  });
github AdrieanKhisbe / configue / examples / async-with-builder.js View on Github external
const Configue = require('configue');

Configue.disable({env: true})
  .files([
    {file: '../examples/config.json'},
    {
      file: '../examples/config.yaml',
      format: require('nconf-yaml')
    }
  ])
  .resolve()
  .then(configue => {
    const salute = configue.get('salute', 'Hello');
    const who = configue.get('who', 'World');

    console.log(`${salute} ${who}!`);
  });

configue

Configue is a config library to easily customize your app from argv, env, files and more.

MIT
Latest version published 1 year ago

Package Health Score

43 / 100
Full package analysis

Popular configue functions