How to use the get function from nconf

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

50
51
52
53
54
55
56
57
58
59
name: '',	// Something unique to your OAuth provider in lowercase, like "github", or "nodebb"
oauth: {
	requestTokenURL: '',
	accessTokenURL: '',
	userAuthorizationURL: '',
	consumerKey: nconf.get('oauth:key'),	// don't change this line
	consumerSecret: nconf.get('oauth:secret'),	// don't change this line
},
oauth2: {
	authorizationURL: '',
fork icon303
star icon119
watch icon0

+ 5 other calls in file

8
9
10
11
12
13
14
15
16
17
18
19
20


nconf.argv().env().file({ file: 'local.json' });


var users = 0;


var server = Hapi.createServer(nconf.get('domain'), nconf.get('port'));
server.views({
  engines: {
    jade: require('jade')
  },
fork icon67
star icon115
watch icon0

19
20
21
22
23
24
25
26
27
28
29
const VIDEO_ID = nconf.get('VIDEO_ID')
const SESSION_TOKEN = nconf.get('SESSION_TOKEN')
const CLAIMS_VIDEO_ID = nconf.get('CLAIMS_VIDEO_ID')
const PLAYLIST_ID = nconf.get('PLAYLIST_ID')
const CHANNEL_ID = nconf.get('CHANNEL_ID')
const botguardResponse = nconf.get('botguardResponse')
const challenge = nconf.get('challenge')
const LESS_THAN_10MIN_VIDEO_ID = nconf.get('LESS_THAN_10MIN_VIDEO_ID');


describe('for authenticated user', () => {
fork icon22
star icon64
watch icon0

+ 7 other calls in file

43
44
45
46
47
48
49
50
51
52
}

// Get single item, return value as is
if (typeof keys === 'string') {
    nconf.required([keys]);
    return nconf.get(keys);
}

// Multiple keys provided, return object
nconf.required(keys);
fork icon24
star icon2
watch icon21

+ 5 other calls in file

246
247
248
249
250
251
252
253
254
255
if (dispatch.route && dispatch.route.path && typeof dispatch.route.path === 'string') {
    if (!prefix && !dispatch.route.path.startsWith('/api/')) {
        return null;
    }

    if (prefix === nconf.get('relative_path')) {
        prefix = '';
    }

    return {
fork icon2
star icon0
watch icon0

+ 3 other calls in file

166
167
168
169
170
171
172
173
174
    return memo;
}, []);

const done = function (data) {
    delete req.session.registration;
    const relative_path = nconf.get('relative_path');
    if (data && data.message) {
        return res.redirect(`${relative_path}/?register=${encodeURIComponent(data.message)}`);
    }
fork icon1
star icon2
watch icon0

3
4
5
6
7
8
9
10
11
12
13
14
const url = require('url');
const nconf = require('nconf');


const activePlugins = require('./build/active_plugins.json');


let relativePath = nconf.get('relative_path');
if (relativePath === undefined) {
    nconf.file({
        file: path.resolve(__dirname, nconf.any(['config', 'CONFIG']) || 'config.json'),
    });
fork icon1
star icon2
watch icon0

+ 2 other calls in file

25
26
27
28
29
30
31
32
33
34
        MONGO_URI: "mongodb://localhost/local",
        SESSION_SECRET: "the mean stack is a very mean stack :)",
        NODE_ENV: "development",
});

mongoose.connect(nconf.get('MONGODB_URI') || nconf.get('MONGO_URI'));

mongoose.set('debug', development);

require('../util/req-dir.js')(__dirname + '/../models');
fork icon1
star icon2
watch icon0

72
73
74
75
76
77
78
79
80
81
if (_.isUndefined(nconf.get('PORT'))) {
  nconf.set('PORT', 1330);
}

_server = new Hapi.Server({
  host: nconf.get('HOST'),
  port: nconf.get('PORT')
});

// load the data package instance
fork icon0
star icon7
watch icon3

+ 7 other calls in file

12
13
14
15
16
17
18
19
20
21
setEncryptionKey: d => {
  validateEncryptionKey(d);
  ENCRYPTION_KEY = d;
  return module.exports;
},
get: key => key ? get(key) : nconf.get(),
env: options => {
  nconf.env(Object.assign({ transform }, options));
  return module.exports;
},
fork icon0
star icon3
watch icon2

16
17
18
19
20
21
22
23
24
25

// 3º
nconf.env();

nconf.required(['NODE_ENV']);
const isProduction = nconf.get('NODE_ENV') === 'production';

logger.info(`Service ${nconf.get('service:name')} started with NODE_ENV=${nconf.get('NODE_ENV')}`);

// 4º
fork icon0
star icon3
watch icon3

31
32
33
34
35
36
37
38
39
40
    formats.push(winston.format.splat());
    formats.push(winston.format.simple());
}

winston.configure({
    level: nconf.get('log-level') || (process.env.NODE_ENV === 'production' ? 'info' : 'verbose'),
    format: winston.format.combine.apply(null, formats),
    transports: [
        new winston.transports.Console({
            handleExceptions: true,
fork icon3
star icon0
watch icon0

+ 3 other calls in file

87
88
89
90
91
92
93
94
95
96
97
98
99
});


prestart.setupWinston();


// Alternate configuration file support
const configFile = path.resolve(paths.baseDir, nconf.get('config') || 'config.json');
const configExists = file.existsSync(configFile) || (nconf.get('url') && nconf.get('secret') && nconf.get('database'));


prestart.loadConfig(configFile);
prestart.versionCheck();
fork icon1
star icon0
watch icon0

146
147
148
149
150
151
152
153
154
155
installing = true;

const database = nconf.get('database') || req.body.database || 'mongo';
const setupEnvVars = {
    ...process.env,
    NODEBB_URL: nconf.get('url') || req.body.url || (`${req.protocol}://${req.get('host')}`),
    NODEBB_PORT: nconf.get('port') || 4567,
    NODEBB_ADMIN_USERNAME: nconf.get('admin:username') || req.body['admin:username'],
    NODEBB_ADMIN_PASSWORD: nconf.get('admin:password') || req.body['admin:password'],
    NODEBB_ADMIN_EMAIL: nconf.get('admin:email') || req.body['admin:email'],
fork icon1
star icon0
watch icon0

+ 13 other calls in file

35
36
37
38
39
40
41
42
43
44
var serviceStates = {
    STARTING: 0,
    ERROR: 1,
    READY: 2
};
var services = nconf.get('services');
function initServices() {
  for (var key in services) {
    services[key].store = null;
    services[key].status = serviceStates.STARTING;
fork icon0
star icon5
watch icon1

+ 23 other calls in file

110
111
112
113
114
115
116
117
118
function setupExpressApp(app) {
        const middleware = require('./middleware');
        const pingController = require('./controllers/ping');

        const relativePath = nconf.get('relative_path');
        const viewsDir = nconf.get('views_dir');

        app.engine('tpl', function (filepath, data, next) {
                filepath = filepath.replace(/\.tpl$/, '.js');
fork icon0
star icon5
watch icon2

+ 19 other calls in file

23
24
25
26
27
28
29
30
31
32
        message: 'Base URL must begin with \'http://\' or \'https://\'',
},
{
        name: 'secret',
        description: 'Please enter a NodeBB secret',
        default: nconf.get('secret') || utils.generateUUID(),
},
{
        name: 'database',
        description: 'Which database to use',
fork icon0
star icon2
watch icon4

+ 11 other calls in file

173
174
175
176
177
178
179
180
181
182
        message: '[[success:post-queued]]',
    };
};

async function parseBodyLong(cid, type, data) {
    const url = nconf.get('url');
    const [content, category, userData] = await Promise.all([
        plugins.hooks.fire('filter:parse.raw', data.content),
        categories.getCategoryFields(cid, ['name', 'slug']),
        user.getUserFields(data.uid, ['uid', 'username']),
fork icon0
star icon2
watch icon5

+ 2 other calls in file

141
142
143
144
145
146
147
148
149
150
    targets = allTargets;
} else if (!Array.isArray(targets)) {
    targets = targets.split(',');
}

let series = nconf.get('series') || options.series;
if (series === undefined) {
// Detect # of CPUs and select strategy as appropriate
    winston.verbose('[build] Querying CPU core count for build strategy');
    const cpus = os.cpus();
fork icon0
star icon2
watch icon5

+ 2 other calls in file

1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
        assert(body);
        const notif = body.notifications[0];
        assert.equal(notif.bodyShort, notifData.bodyShort);
        assert.equal(notif.bodyLong, notifData.bodyLong);
        assert.equal(notif.pid, notifData.pid);
        assert.equal(notif.path, nconf.get('relative_path') + notifData.path);
        assert.equal(notif.nid, notifData.nid);
        next();
    },
], done);
fork icon0
star icon2
watch icon5

+ 2 other calls in file