-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
40 lines (32 loc) · 909 Bytes
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var config = module.exports;
var storage = require('node-persist');
config.init = function(){
storage.initSync({
dir:'./config/',
stringify: JSON.stringify,
parse: JSON.parse,
encoding: 'utf8',
logging: false, // can also be custom logging function
continuous: true,
interval: false,
ttl: false, // ttl* [NEW], can be true for 24h default or a number in MILLISECONDS
})
};
config.get = function(key, cb){
storage.getItem(key, function(err, data){
if (err){
throw new Error("Unable to get value from config");
} else {
cb(data);
}
});
};
config.set = function (key, data, cb){
storage.setItem(key, data, function(err) {
if (err){
throw new Error("Unable to get value from config");
} else {
cb();
}
});
}