Commit | Line | Data |
---|---|---|
83ee6a86 | 1 | const fs = require('fs'); |
1d7ca20c | 2 | const Utils = require('./Utils'); |
7dde0b73 JB |
3 | |
4 | class Configuration { | |
868cb6d1 | 5 | static configuration; |
83ee6a86 | 6 | |
7dde0b73 JB |
7 | // Read the config file |
8 | static getConfig() { | |
868cb6d1 JB |
9 | if (!Configuration.configuration) { |
10 | Configuration.configuration = JSON.parse(fs.readFileSync('./src/assets/config.json', 'utf8')); | |
83ee6a86 | 11 | } |
868cb6d1 | 12 | return Configuration.configuration; |
7dde0b73 JB |
13 | } |
14 | ||
15 | static getStatisticsDisplayInterval() { | |
16 | // Read conf | |
2e6f5966 | 17 | return Utils.objectHasOwnProperty(Configuration.getConfig(), 'statisticsDisplayInterval') ? Configuration.getConfig().statisticsDisplayInterval : 60; |
7dde0b73 JB |
18 | } |
19 | ||
20 | static getAutoReconnectTimeout() { | |
21 | // Read conf | |
1d7ca20c | 22 | return Utils.objectHasOwnProperty(Configuration.getConfig(), 'autoReconnectTimeout') ? Configuration.getConfig().autoReconnectTimeout : 10; |
7dde0b73 JB |
23 | } |
24 | ||
25 | static getAutoReconnectMaxRetries() { | |
26 | // Read conf | |
1d7ca20c | 27 | return Utils.objectHasOwnProperty(Configuration.getConfig(), 'autoReconnectMaxRetries') ? Configuration.getConfig().autoReconnectMaxRetries : -1; |
7dde0b73 JB |
28 | } |
29 | ||
2e6f5966 | 30 | static getStationTemplateURLs() { |
7dde0b73 JB |
31 | // Read conf |
32 | return Configuration.getConfig().stationTemplateURLs; | |
33 | } | |
34 | ||
7dde0b73 JB |
35 | static useWorkerPool() { |
36 | return Configuration.getConfig().useWorkerPool; | |
37 | } | |
38 | ||
39 | static getWorkerPoolSize() { | |
40 | return Configuration.getConfig().workerPoolSize; | |
41 | } | |
42 | ||
43 | static getConsoleLog() { | |
1d7ca20c | 44 | return Utils.objectHasOwnProperty(Configuration.getConfig(), 'consoleLog') ? Configuration.getConfig().consoleLog : false; |
7dde0b73 JB |
45 | } |
46 | ||
027b409a JB |
47 | static getLogFormat() { |
48 | return Utils.objectHasOwnProperty(Configuration.getConfig(), 'logFormat') ? Configuration.getConfig().logFormat : 'simple'; | |
49 | } | |
50 | ||
2e6f5966 JB |
51 | static getLogLevel() { |
52 | return Utils.objectHasOwnProperty(Configuration.getConfig(), 'logLevel') ? Configuration.getConfig().logLevel : 'info'; | |
53 | } | |
54 | ||
7dde0b73 | 55 | static getLogFile() { |
1d7ca20c | 56 | return Utils.objectHasOwnProperty(Configuration.getConfig(), 'logFile') ? Configuration.getConfig().logFile : 'combined.log'; |
7dde0b73 JB |
57 | } |
58 | ||
59 | static getErrorFile() { | |
1d7ca20c | 60 | return Utils.objectHasOwnProperty(Configuration.getConfig(), 'errorFile') ? Configuration.getConfig().errorFile : 'error.log'; |
7dde0b73 JB |
61 | } |
62 | ||
7dde0b73 JB |
63 | static getSupervisionURLs() { |
64 | // Read conf | |
65 | return Configuration.getConfig().supervisionURLs; | |
66 | } | |
67 | ||
2e6f5966 JB |
68 | static getDistributeStationToTenantEqually() { |
69 | return Utils.objectHasOwnProperty(Configuration.getConfig(), 'distributeStationToTenantEqually') ? Configuration.getConfig().distributeStationToTenantEqually : true; | |
7dde0b73 JB |
70 | } |
71 | } | |
72 | ||
73 | module.exports = Configuration; |