repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git]
/
src
/
charging-station
/
ui-server
/
UIHttpServer.ts
diff --git
a/src/charging-station/ui-server/UIHttpServer.ts
b/src/charging-station/ui-server/UIHttpServer.ts
index b10d33363b4ae9cc2898eae9eb5efd426b317613..5bcae7beff6ed84fc6d0e202437361bc7f1c3725 100644
(file)
--- a/
src/charging-station/ui-server/UIHttpServer.ts
+++ b/
src/charging-station/ui-server/UIHttpServer.ts
@@
-2,11
+2,10
@@
import type { IncomingMessage, ServerResponse } from 'node:http'
import { StatusCodes } from 'http-status-codes'
import { StatusCodes } from 'http-status-codes'
-import { AbstractUIServer } from './AbstractUIServer.js'
-import { UIServerUtils } from './UIServerUtils.js'
import { BaseError } from '../../exception/index.js'
import {
ApplicationProtocolVersion,
import { BaseError } from '../../exception/index.js'
import {
ApplicationProtocolVersion,
+ MapStringifyFormat,
type ProcedureName,
type Protocol,
type ProtocolRequest,
type ProcedureName,
type Protocol,
type ProtocolRequest,
@@
-18,12
+17,14
@@
import {
} from '../../types/index.js'
import {
Constants,
} from '../../types/index.js'
import {
Constants,
- JSONStringifyWithMapSupport,
generateUUID,
isNotEmptyString,
generateUUID,
isNotEmptyString,
- logPrefix,
- logger
+ JSONStringify,
+ logger,
+ logPrefix
} from '../../utils/index.js'
} from '../../utils/index.js'
+import { AbstractUIServer } from './AbstractUIServer.js'
+import { isProtocolAndVersionSupported } from './UIServerUtils.js'
const moduleName = 'UIHttpServer'
const moduleName = 'UIHttpServer'
@@
-61,7
+62,7
@@
export class UIHttpServer extends AbstractUIServer {
.writeHead(this.responseStatusToStatusCode(payload.status), {
'Content-Type': 'application/json'
})
.writeHead(this.responseStatusToStatusCode(payload.status), {
'Content-Type': 'application/json'
})
- .end(JSONStringify
WithMapSupport(payload
))
+ .end(JSONStringify
(payload, undefined, MapStringifyFormat.object
))
} else {
logger.error(
`${this.logPrefix(moduleName, 'sendResponse')} Response for unknown request id: ${uuid}`
} else {
logger.error(
`${this.logPrefix(moduleName, 'sendResponse')} Response for unknown request id: ${uuid}`
@@
-95,7
+96,7
@@
export class UIHttpServer extends AbstractUIServer {
'WWW-Authenticate': 'Basic realm=users'
})
.end(`${StatusCodes.UNAUTHORIZED} Unauthorized`)
'WWW-Authenticate': 'Basic realm=users'
})
.end(`${StatusCodes.UNAUTHORIZED} Unauthorized`)
-
.destroy()
+
res
.destroy()
req.destroy()
}
})
req.destroy()
}
})
@@
-109,7
+110,7
@@
export class UIHttpServer extends AbstractUIServer {
this.responseHandlers.set(uuid, res)
try {
const fullProtocol = `${protocol}${version}`
this.responseHandlers.set(uuid, res)
try {
const fullProtocol = `${protocol}${version}`
- if (!
UIServerUtils.
isProtocolAndVersionSupported(fullProtocol)) {
+ if (!isProtocolAndVersionSupported(fullProtocol)) {
throw new BaseError(`Unsupported UI protocol version: '${fullProtocol}'`)
}
this.registerProtocolVersionUIService(version)
throw new BaseError(`Unsupported UI protocol version: '${fullProtocol}'`)
}
this.registerProtocolVersionUIService(version)
@@
-126,9
+127,9
@@
export class UIHttpServer extends AbstractUIServer {
bodyBuffer.push(chunk)
})
.on('end', () => {
bodyBuffer.push(chunk)
})
.on('end', () => {
- let
body
: RequestPayload | undefined
+ let
requestPayload
: RequestPayload | undefined
try {
try {
-
body
= JSON.parse(Buffer.concat(bodyBuffer).toString()) as RequestPayload
+
requestPayload
= JSON.parse(Buffer.concat(bodyBuffer).toString()) as RequestPayload
} catch (error) {
this.sendResponse(
this.buildProtocolResponse(uuid, {
} catch (error) {
this.sendResponse(
this.buildProtocolResponse(uuid, {
@@
-141,7
+142,7
@@
export class UIHttpServer extends AbstractUIServer {
}
this.uiServices
.get(version)
}
this.uiServices
.get(version)
- ?.requestHandler(this.buildProtocolRequest(uuid, procedureName,
body
))
+ ?.requestHandler(this.buildProtocolRequest(uuid, procedureName,
requestPayload
))
.then((protocolResponse?: ProtocolResponse) => {
if (protocolResponse != null) {
this.sendResponse(protocolResponse)
.then((protocolResponse?: ProtocolResponse) => {
if (protocolResponse != null) {
this.sendResponse(protocolResponse)