How to use the nconf.argv function in nconf

To help you get started, we’ve selected a few nconf 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 codius-deprecated / codius-cli / bin / codius-cli.js View on Github external
ANY  SPECIAL ,  DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    WHATSOEVER  RESULTING  FROM  LOSS  OF USE, DATA OR PROFITS, WHETHER IN AN
    ACTION  OF  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================

var winston = require('winston');
var nconf = require('nconf');
var Codius = require('../lib/codius').Codius;
var Config = require('../lib/config').Config;

winston.cli();

// Use nconf to load command line arguments and environment variables
nconf.argv()
     .env()
     .file({ file: 'HOME/.config/codius/cli.json' });
var config = new Config(nconf.get());
var command = nconf.get('_')[0];

if (config.config.debug) {
  winston.default.transports.console.level = 'debug';
}

var codius = new Codius();
codius.load(config).then(function () {
  codius.runCommand(command);
}).catch(function (err) {
  console.error(err.stack ? err.stack : err);
  process.exit(1);
}).done();
github tracking-exposed / facebook / mongodb / uncommon-tooling / datathon-1st.js View on Github external
#!/usr/bin/env node
const moment = require('moment');
const _ = require('lodash');
const mongo = require('../../lib/mongo');
const various = require('../../lib/various');
const Promise = require('bluebird');
const debug = require('debug')('datathon');

const nconf = require('nconf');
nconf.argv().env().file({ file: 'config/collector.json' })

return Promise.map(_.times(52), function(wn) {

    x = moment({year: 2018}).add(wn, 'w');
    return mongo
        .readLimit(nconf.get('schema').timelines, { startTime: { "$gt": new Date(x.format()) }}, { startTime: 1 }, 20, 0)
        .map(function(l) {
            return l.id;
        });
}, { concurrency: 1})
.map(function(entries, n) {
    const ready = { timelineId: { "$in" : entries }}
    return various.dumpJSONfile(`/tmp/week-${n+1}.json`, ready);
});

/* this input is feed to a mongoscript */
github googleapis / google-api-nodejs-client / samples / blogger / blogger.js View on Github external
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const {google} = require('googleapis');
const blogger = google.blogger('v3');
const nconf = require('nconf');
const path = require('path');

// Ex: node blogger.js --api_key "YOUR API KEY"
nconf
  .argv()
  .env()
  .file(path.join(__dirname, 'config.json'));

blogger.blogs.get(
  {
    key: nconf.get('api_key'),
    blogId: '3213900',
  },
  (err, res) => {
    if (err) {
      throw err;
    }
    console.log(res.data);
  }
);
github tracking-exposed / facebook / parsers / components / interactions.js View on Github external
#!/usr/bin/env node
var _ = require('lodash');
var cheerio = require('cheerio');
var moment = require('moment');
var debug = require('debug')('interactions');
var parse = require('./lib/parse');
var nconf = require('nconf');

nconf.argv().env();
     // .file('users', { file: "config/italy-2018.json" });

var stats = { first: null, skipped: 0, processed: 0, success: 0, failure: 0, bugs: {} };

function extendStats(label) {

    var words = label.replace(/\ /g, ':').replace(/[0-9]/g, '').split(':');
    _.each(_.compact(words), function(w) {
        if( (w[0] >= '0') && (w[0] <= '9'))
            return;

        if(_.isUndefined(stats.bags[w]))
            stats.bags[w] = 1;
        else
            stats.bags[w] += 1;
    });
github tracking-exposed / facebook / bin / collector.js View on Github external
var moment = require('moment');
var bodyParser = require('body-parser');
var Promise = require('bluebird');
var debug = require('debug')('fbtrex:collector');
var nconf = require('nconf');
var cors = require('cors');

const common = require('../lib/common');
const mongo = require('../lib/mongo');
const security = require('../lib/security');

var cfgFile = "config/collector.json";
var redOn = "\033[31m";
var redOff = "\033[0m";

nconf.argv().env().file({ file: cfgFile });
console.log(redOn + "àȘ‰ nconf loaded, using " + cfgFile + redOff);

/* configuration for elasticsearch */
const echoes = require('../lib/echoes');
echoes.addEcho("elasticsearch");
echoes.setDefaultEcho("elasticsearch");

const collectorImplementations = {
    processEvents:    require('../routes/events').processEvents,
    getSelector:      require('../routes/selector').getSelector,
    userInfo:         require('../routes/selector').userInfo,
    getMirror:        require('../routes/events').getMirror,
};

function dispatchPromise(name, req, res) {
github Glavin001 / Cobra / server / index.js View on Github external
#!/usr/bin/env node

// Dependencies
var express = require('express');
var bodyParser = require('body-parser')
var mongodb = require('mongodb');
var nconf = require('nconf');
var cors = require('cors');
var path = require('path');
var EJSON = require('mongodb-extended-json');

// Configuration
var configPath = path.resolve(__dirname, '../default_config.json');
nconf.argv()
       .env()
       .file({ file: configPath });

// Create your server
var app = express();
// Configure Express
app.use(bodyParser.json())

// CORS
if (nconf.get('server:CORS')) {
    console.log("CORS enabled.");
    app.use(cors());
}
else {
    console.log("CORS disabled.");
}
github totem / discover / index.js View on Github external
function main() {

  var nconf = require('nconf');

  //
  // Setup nconf to use (in-order):
  //   1. Command-line arguments
  //   2. Environment variables
  //   2. Custom config file
  //   2. Defaults
  //
  nconf
    .argv()
    .env('_');

  // Load custom config file
  if (nconf.get('config')) {
    nconf.use('file', { file: nconf.get('config') });
  }

  // Last case scenerio, we set sane defaults
  nconf.use('file', { file: path.join(__dirname, 'config/defaults.json') });

  // Configure log destinations
  if (nconf.get('log')) {
    winston.add(winston.transports.File, { timestamp: true, filename: nconf.get('log') });
  } else {
    winston.add(winston.transports.Console);
github prosociallearnEU / cf-nodejs-client / test / lib / model / cloudcontroller / ServiceInstancesTests.js View on Github external
/*jslint node: true*/
/*global describe: true, before:true, it: true*/

var Promise = require('bluebird');
var chai = require("chai"),
    expect = require("chai").expect;
var randomWords = require('random-words');

var argv = require('optimist').demand('config').argv;
var environment = argv.config;
var nconf = require('nconf');
nconf.argv().env().file({ file: 'config.json' });

var cf_api_url = nconf.get(environment + "_" + 'CF_API_URL'),
    username = nconf.get(environment + "_" + 'username'),
    password = nconf.get(environment + "_" + 'password');

var CloudController = require("../../../../lib/model/cloudcontroller/CloudController");
var CloudFoundryUsersUAA = require("../../../../lib/model/uaa/UsersUAA");
var CloudFoundryApps = require("../../../../lib/model/cloudcontroller/Apps");
var CloudFoundrySpaces = require("../../../../lib/model/cloudcontroller/Spaces");
var CloudFoundryUserProvidedServices = require("../../../../lib/model/cloudcontroller/UserProvidedServices");
var CloudFoundryServiceInstances = require("../../../../lib/model/cloudcontroller/ServiceInstances");
var CloudFoundryServicePlans = require("../../../../lib/model/cloudcontroller/ServicePlans");
var BuildPacks = require("../../../../lib/model/cloudcontroller/BuildPacks");
CloudController = new CloudController();
CloudFoundryUsersUAA = new CloudFoundryUsersUAA();
CloudFoundryApps = new CloudFoundryApps();
github zalando-incubator / tessellate / packages / tessellate-server / src / nconf.js View on Github external
argv: function(args: Object) {
    nconf.argv(args);
    return this;
  },
  defaults: function(defaults: Object) {
github holderdeord / hdo-transcript-search / webapp / config / index.js View on Github external
var nconf = require('nconf');

var elasticsearch = 'localhost:9200';
if (process.env.BOXEN_ELASTICSEARCH_HOST && process.env.BOXEN_ELASTICSEARCH_PORT) {
    elasticsearch = [process.env.BOXEN_ELASTICSEARCH_HOST, process.env.BOXEN_ELASTICSEARCH_PORT].join(':');
}

nconf
    .argv()
    .env()
    .defaults({
        HTTP_PORT: 7575,
        NODE_ENV: 'dev',
        elasticsearch: elasticsearch
    });

module.exports = nconf;

nconf

Hierarchical node.js configuration with files, environment variables, command-line arguments, and atomic object merging.

MIT
Latest version published 1 year ago

Package Health Score

74 / 100
Full package analysis