X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fui-server%2FUIServerFactory.ts;h=c4006b0396d96c8d5ad50e902bfedf8ea2743c65;hb=b85cef4cba7e4d2294940aef29a9f74edf800dac;hp=612054f692caee075917e873f293f14c68f2a8aa;hpb=17bc43d765c22c8d8c132484f8dc9c3edd370d91;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ui-server/UIServerFactory.ts b/src/charging-station/ui-server/UIServerFactory.ts index 612054f6..c4006b03 100644 --- a/src/charging-station/ui-server/UIServerFactory.ts +++ b/src/charging-station/ui-server/UIServerFactory.ts @@ -1,9 +1,10 @@ import chalk from 'chalk'; +import type { AbstractUIServer } from './AbstractUIServer'; +import { UIHttpServer } from './UIHttpServer'; import { UIServerUtils } from './UIServerUtils'; +import { UIWebSocketServer } from './UIWebSocketServer'; import { ApplicationProtocol, type UIServerConfiguration } from '../../types'; -import { Configuration } from '../../utils/Configuration'; -import { type AbstractUIServer, UIHttpServer, UIWebSocketServer } from '../internal'; export class UIServerFactory { private constructor() { @@ -11,20 +12,20 @@ export class UIServerFactory { } public static getUIServerImplementation( - uiServerConfiguration?: UIServerConfiguration + uiServerConfiguration: UIServerConfiguration, ): AbstractUIServer | null { - if (UIServerUtils.isLoopback(uiServerConfiguration.options?.host) === false) { + if (UIServerUtils.isLoopback(uiServerConfiguration.options!.host!) === false) { console.warn( chalk.yellow( - 'Loopback address not detected in UI server configuration. This is not recommended.' - ) + 'Loopback address not detected in UI server configuration. This is not recommended.', + ), ); } - switch (uiServerConfiguration?.type ?? Configuration.getUIServer().type) { + switch (uiServerConfiguration.type) { case ApplicationProtocol.WS: - return new UIWebSocketServer(uiServerConfiguration ?? Configuration.getUIServer()); + return new UIWebSocketServer(uiServerConfiguration); case ApplicationProtocol.HTTP: - return new UIHttpServer(uiServerConfiguration ?? Configuration.getUIServer()); + return new UIHttpServer(uiServerConfiguration); default: return null; }