import Constants from './Constants';
import { EmptyObject } from '../types/EmptyObject';
+import { FileType } from '../types/FileType';
import { HandleErrorParams } from '../types/Error';
import { ServerOptions } from 'ws';
import { StorageType } from '../types/Storage';
import path from 'path';
export default class Configuration {
- private static configurationFilePath = path.join(
+ private static configurationFile = path.join(
path.resolve(__dirname, '../'),
'assets',
'config.json'
// Read conf
return Configuration.objectHasOwnProperty(Configuration.getConfig(), 'logStatisticsInterval')
? Configuration.getConfig().logStatisticsInterval
- : 60;
+ : Constants.DEFAULT_LOG_STATISTICS_INTERVAL;
}
static getUIWebSocketServer(): UIWebSocketServerConfiguration {
static getWorkerProcess(): WorkerProcessType {
Configuration.warnDeprecatedConfigurationKey(
- 'useWorkerPool;',
+ 'useWorkerPool',
null,
- "Use 'workerProcess' to define the type of worker process to use instead"
+ "Use 'workerProcess' to define the type of worker process model to use instead"
);
return Configuration.objectHasOwnProperty(Configuration.getConfig(), 'workerProcess')
? Configuration.getConfig().workerProcess
if (!Configuration.configuration) {
try {
Configuration.configuration = JSON.parse(
- fs.readFileSync(Configuration.configurationFilePath, 'utf8')
+ fs.readFileSync(Configuration.configurationFile, 'utf8')
) as ConfigurationData;
} catch (error) {
Configuration.handleFileException(
Configuration.logPrefix(),
- 'Configuration',
- Configuration.configurationFilePath,
+ FileType.Configuration,
+ Configuration.configurationFile,
error as NodeJS.ErrnoException
);
}
private static getConfigurationFileWatcher(): fs.FSWatcher {
try {
- return fs.watch(Configuration.configurationFilePath, (event, filename): void => {
+ return fs.watch(Configuration.configurationFile, (event, filename): void => {
if (filename && event === 'change') {
// Nullify to force configuration file reading
Configuration.configuration = null;
} catch (error) {
Configuration.handleFileException(
Configuration.logPrefix(),
- 'Configuration',
- Configuration.configurationFilePath,
- error as Error
+ FileType.Configuration,
+ Configuration.configurationFile,
+ error as NodeJS.ErrnoException
);
}
}
private static handleFileException(
logPrefix: string,
- fileType: string,
+ fileType: FileType,
filePath: string,
error: NodeJS.ErrnoException,
params: HandleErrorParams<EmptyObject> = { throwError: true }