Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50659 views
1
/*
2
* config.js: Default configuration management plugin which attachs nconf to App instances
3
*
4
* (C) 2011, Nodejitsu Inc.
5
* MIT LICENSE
6
*
7
*/
8
9
var nconf = require('nconf');
10
11
//
12
// ### Name this plugin
13
//
14
exports.name = 'config';
15
16
//
17
// ### function attach (options)
18
// #### @options {Object} Options for this plugin
19
// Extends `this` (the application) with configuration functionality
20
// from `nconf`.
21
//
22
exports.attach = function (options) {
23
options = options || {};
24
this.config = new nconf.Provider(options);
25
26
//
27
// Setup a default store
28
//
29
this.config.use('literal');
30
this.config.stores.literal.readOnly = false;
31
};
32
33
//
34
// ### function init (done)
35
// #### @done {function} Continuation to respond to when complete.
36
// Initalizes the `nconf.Provider` associated with this instance.
37
//
38
exports.init = function (done) {
39
//
40
// Remark: There should be code here for automated remote
41
// seeding and loading
42
//
43
this.config.load(function (err) {
44
return err ? done(err) : done();
45
});
46
};
47