-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.js
More file actions
24 lines (21 loc) · 996 Bytes
/
config.js
File metadata and controls
24 lines (21 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const config = {
myClassConfig : {
yourname : "New User",
stringsecret : "secretvalue",
numbersecret : 42
},
singlesecret : "hello"
}
unexportedsecret = "useless"; // useless if not "exported".
// to export above...
// module.exports.unexportedsecret = unexportedsecret;
// however, it's better to export a whole Object than to set individual values to export.
module.exports = config;
/* Usage from other files
let conf = require('config'); // if the config.js is not in the same folder, you need to do './child_dir/config.js'(in child dir) or
// '../config.js'(in parent dir) or '../../config.js'(in parent's parent dir), and so on.
console.log(conf.myClassConfig.stringsecret); // "secretvalue"
console.log(conf.myClassConfig.numbersecret); // 42
console.log(conf.singlesecret); // "hello"
console.log(conf.unexportedsecret); // Uncaught ReferenceError: conf.unexportedsecret is not defined
*/