X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fui-server%2FUIServerFactory.ts;h=bbbb66b9c2fd67b01e2deb604345ae95314a7b36;hb=92403944ed5cdbdd07faaa2da783682e1ea9a9dd;hp=1ad64014219ace91a0bdcf3c4afe24e4fb00f8ba;hpb=b153c0fd46bdc1dc8006e4dac4d4dfa739ff7707;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 1ad64014..bbbb66b9 100644 --- a/src/charging-station/ui-server/UIServerFactory.ts +++ b/src/charging-station/ui-server/UIServerFactory.ts @@ -1,7 +1,11 @@ -import { AbstractUIServer } from './AbstractUIServer'; +import chalk from 'chalk'; + +import type { ServerOptions } from '../../types/ConfigurationData'; import { ApplicationProtocol } from '../../types/UIProtocol'; import Configuration from '../../utils/Configuration'; -import { ServerOptions } from '../../types/ConfigurationData'; +import type { AbstractUIServer } from './AbstractUIServer'; +import { UIServiceUtils } from './ui-services/UIServiceUtils'; +import UIHttpServer from './UIHttpServer'; import UIWebSocketServer from './UIWebSocketServer'; export default class UIServerFactory { @@ -13,9 +17,18 @@ export default class UIServerFactory { applicationProtocol: ApplicationProtocol, options?: ServerOptions ): AbstractUIServer | null { + if (!UIServiceUtils.isLoopback(options?.host)) { + console.warn( + chalk.magenta( + 'Loopback address not detected in UI server configuration. This is not recommended.' + ) + ); + } switch (applicationProtocol) { case ApplicationProtocol.WS: return new UIWebSocketServer(options ?? Configuration.getUIServer().options); + case ApplicationProtocol.HTTP: + return new UIHttpServer(options ?? Configuration.getUIServer().options); default: return null; }