X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fui-server%2FUIHttpServer.ts;h=08ea7ff080137f5cce8e664a90cb00be272abfb1;hb=17bc43d765c22c8d8c132484f8dc9c3edd370d91;hp=f475b8efbac54af6d9fb900920ea32b6298d7fcf;hpb=551e477c2cc2461de8dcc2b263a35c0c50240bbf;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ui-server/UIHttpServer.ts b/src/charging-station/ui-server/UIHttpServer.ts index f475b8ef..08ea7ff0 100644 --- a/src/charging-station/ui-server/UIHttpServer.ts +++ b/src/charging-station/ui-server/UIHttpServer.ts @@ -2,10 +2,8 @@ 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 { BaseError } from '../../exception'; import { type ProcedureName, type Protocol, @@ -14,13 +12,15 @@ import { type ProtocolVersion, type RequestPayload, ResponseStatus, -} from '../../types/UIProtocol'; -import logger from '../../utils/Logger'; -import Utils from '../../utils/Utils'; + type UIServerConfiguration, +} from '../../types'; +import { logger } from '../../utils/Logger'; +import { Utils } from '../../utils/Utils'; +import { AbstractUIServer } from '../internal'; const moduleName = 'UIHttpServer'; -export default class UIHttpServer extends AbstractUIServer { +export class UIHttpServer extends AbstractUIServer { public constructor(protected readonly uiServerConfiguration: UIServerConfiguration) { super(uiServerConfiguration); } @@ -60,12 +60,14 @@ export default class UIHttpServer extends AbstractUIServer { } } - public logPrefix(modName?: string, methodName?: string, prefixSuffix?: string): string { + public logPrefix = (modName?: string, methodName?: string, prefixSuffix?: string): string => { const logMsgPrefix = prefixSuffix ? `UI HTTP Server ${prefixSuffix}` : 'UI HTTP Server'; const logMsg = - modName && methodName ? ` ${logMsgPrefix} | ${modName}.${methodName}:` : ` ${logMsgPrefix} |`; + Utils.isNotEmptyString(modName) && Utils.isNotEmptyString(methodName) + ? ` ${logMsgPrefix} | ${modName}.${methodName}:` + : ` ${logMsgPrefix} |`; return Utils.logPrefix(logMsg); - } + }; private requestListener(req: IncomingMessage, res: ServerResponse): void { this.authenticate(req, (err) => {