Fix isEmptyString() semantic
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / UIHttpServer.ts
index 7b777b86040c3cba972d886da3df9a11dbab999a..f475b8efbac54af6d9fb900920ea32b6298d7fcf 100644 (file)
@@ -2,21 +2,21 @@ import type { IncomingMessage, RequestListener, ServerResponse } from 'http';
 
 import { StatusCodes } from 'http-status-codes';
 
+import { AbstractUIServer } from './AbstractUIServer';
+import { UIServerUtils } from './UIServerUtils';
 import BaseError from '../../exception/BaseError';
 import type { UIServerConfiguration } from '../../types/ConfigurationData';
 import {
-  ProcedureName,
-  Protocol,
-  ProtocolRequest,
-  ProtocolResponse,
-  ProtocolVersion,
-  RequestPayload,
+  type ProcedureName,
+  type Protocol,
+  type ProtocolRequest,
+  type ProtocolResponse,
+  type ProtocolVersion,
+  type RequestPayload,
   ResponseStatus,
 } from '../../types/UIProtocol';
 import logger from '../../utils/Logger';
 import Utils from '../../utils/Utils';
-import { AbstractUIServer } from './AbstractUIServer';
-import { UIServiceUtils } from './ui-services/UIServiceUtils';
 
 const moduleName = 'UIHttpServer';
 
@@ -90,7 +90,7 @@ export default class UIHttpServer extends AbstractUIServer {
     this.responseHandlers.set(uuid, res);
     try {
       const fullProtocol = `${protocol}${version}`;
-      if (UIServiceUtils.isProtocolAndVersionSupported(fullProtocol) === false) {
+      if (UIServerUtils.isProtocolAndVersionSupported(fullProtocol) === false) {
         throw new BaseError(`Unsupported UI protocol version: '${fullProtocol}'`);
       }
       this.registerProtocolVersionUIService(version);
@@ -110,7 +110,7 @@ export default class UIHttpServer extends AbstractUIServer {
             const body = JSON.parse(Buffer.concat(bodyBuffer).toString()) as RequestPayload;
             this.uiServices
               .get(version)
-              .requestHandler(this.buildProtocolRequest(uuid, procedureName, body ?? {}))
+              ?.requestHandler(this.buildProtocolRequest(uuid, procedureName, body ?? {}))
               .catch(() => {
                 /* Error caught by AbstractUIService */
               });