1 import chalk from
'chalk';
3 import { ServerOptions
} from
'../../types/ConfigurationData';
4 import { ApplicationProtocol
} from
'../../types/UIProtocol';
5 import Configuration from
'../../utils/Configuration';
6 import { AbstractUIServer
} from
'./AbstractUIServer';
7 import { UIServiceUtils
} from
'./ui-services/UIServiceUtils';
8 import UIHttpServer from
'./UIHttpServer';
9 import UIWebSocketServer from
'./UIWebSocketServer';
11 export default class UIServerFactory
{
12 private constructor() {
13 // This is intentional
16 public static getUIServerImplementation(
17 applicationProtocol
: ApplicationProtocol
,
18 options
?: ServerOptions
19 ): AbstractUIServer
| null {
20 if (!UIServiceUtils
.isLoopback(options
?.host
)) {
23 'Loopback address not detected in UI server configuration. This is not recommended.'
27 switch (applicationProtocol
) {
28 case ApplicationProtocol
.WS
:
29 return new UIWebSocketServer(options
?? Configuration
.getUIServer().options
);
30 case ApplicationProtocol
.HTTP
:
31 return new UIHttpServer(options
?? Configuration
.getUIServer().options
);