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,
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);
}
}
}
- 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) => {
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 */
});