-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.js
56 lines (44 loc) · 1.04 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const yaml = require("node-yaml")
class Config {
static async getConfig(driveConnector) {
if (!process.env.CAM_ID) {
throw new Error('CAM_ID not configured')
}
const camName = 'cam' + process.env.CAM_ID
const configFile = `${camName}-config.yaml`
const file = await driveConnector.getConfigFile(configFile)
return new Config(yaml.parse(file).config, camName)
}
constructor(config, camName) {
this.camName = camName
this._config = Object.assign({}, config)
}
get folderName() {
return this.camName
}
get startHour() {
return this._config.startHour
}
get endHour() {
return this._config.endHour
}
get frequency() {
return this._config.frequency
}
get daysOfWeek() {
return this._config.daysOfWeek
}
get rawEnabled() {
return this._config.rawEnabled
}
get dailyEnabled() {
return this._config.dailyEnabled
}
get updateCode() {
return this._config.updateCode
}
stringify() {
return JSON.stringify(this._config)
}
}
module.exports = Config