-import ConfigurationData, {
- StationTemplateUrl,
- StorageConfiguration,
+import fs from 'fs';
+import path from 'path';
+import { fileURLToPath } from 'url';
+
+import chalk from 'chalk';
+
+import {
+ type ConfigurationData,
+ type StationTemplateUrl,
+ type StorageConfiguration,
SupervisionUrlDistribution,
- UIServerConfiguration,
- WorkerConfiguration,
+ type UIServerConfiguration,
+ type WorkerConfiguration,
} from '../types/ConfigurationData';
-
-import Constants from './Constants';
-import { EmptyObject } from '../types/EmptyObject';
+import type { EmptyObject } from '../types/EmptyObject';
+import type { HandleErrorParams } from '../types/Error';
import { FileType } from '../types/FileType';
-import { HandleErrorParams } from '../types/Error';
import { StorageType } from '../types/Storage';
-import WorkerConstants from '../worker/WorkerConstants';
+import { ApplicationProtocol } from '../types/UIProtocol';
import { WorkerProcessType } from '../types/Worker';
-import chalk from 'chalk';
-import { fileURLToPath } from 'url';
-import fs from 'fs';
-import path from 'path';
+import WorkerConstants from '../worker/WorkerConstants';
+import Constants from './Constants';
export default class Configuration {
private static configurationFile = path.join(
);
}
let uiServerConfiguration: UIServerConfiguration = {
- enabled: true,
+ enabled: false,
+ type: ApplicationProtocol.WS,
options: {
- host: Constants.DEFAULT_UI_WEBSOCKET_SERVER_HOST,
- port: Constants.DEFAULT_UI_WEBSOCKET_SERVER_PORT,
+ host: Constants.DEFAULT_UI_SERVER_HOST,
+ port: Constants.DEFAULT_UI_SERVER_PORT,
},
};
if (Configuration.objectHasOwnProperty(Configuration.getConfig(), 'uiServer')) {
Configuration.getConfig().uiServer
);
}
+ if (Configuration.isCFEnvironment() === true) {
+ delete uiServerConfiguration.options.host;
+ uiServerConfiguration.options.port = parseInt(process.env.PORT);
+ }
return uiServerConfiguration;
}
}
}
+ private static isCFEnvironment(): boolean {
+ return process.env.VCAP_APPLICATION !== undefined;
+ }
+
private static getDefaultPerformanceStorageUri(storageType: StorageType) {
const SQLiteFileName = `${Constants.DEFAULT_PERFORMANCE_RECORDS_DB_NAME}.db`;
switch (storageType) {
}
private static isObject(item): boolean {
- return item && typeof item === 'object' && !Array.isArray(item);
+ return item && typeof item === 'object' && Array.isArray(item) === false;
+ }
+
+ private static objectHasOwnProperty(object: unknown, property: string): boolean {
+ return Object.prototype.hasOwnProperty.call(object, property) as boolean;
+ }
+
+ private static isUndefined(obj: unknown): boolean {
+ return typeof obj === 'undefined';
}
private static deepMerge(target: object, ...sources: object[]): object {
return Configuration.deepMerge(target, ...sources);
}
- private static objectHasOwnProperty(object: unknown, property: string): boolean {
- return Object.prototype.hasOwnProperty.call(object, property) as boolean;
- }
-
- private static isUndefined(obj: unknown): boolean {
- return typeof obj === 'undefined';
- }
-
private static handleFileException(
logPrefix: string,
fileType: FileType,