]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor(ui-server): unify HTTP and WebSocket payload size limits
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 12 Feb 2026 18:29:31 +0000 (19:29 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 12 Feb 2026 18:29:31 +0000 (19:29 +0100)
Merge DEFAULT_MAX_BODY_SIZE and DEFAULT_WS_MAX_PAYLOAD into single
DEFAULT_MAX_PAYLOAD_SIZE constant (1MB). Both represent the same
semantic: UI protocol payload limit over different transport layers.

Also increases WebSocket limit from 100KB to 1MB to match HTTP,
allowing ~200-300 charging stations in list responses.

src/charging-station/ui-server/UIHttpServer.ts
src/charging-station/ui-server/UIServerSecurity.ts
src/charging-station/ui-server/UIWebSocketServer.ts

index a86f72185e96b9d52adf90e606ead080de7b3d9c..ce655c2df3a2d02daeb03c3ccc599189412475a8 100644 (file)
@@ -26,7 +26,7 @@ import { AbstractUIServer } from './AbstractUIServer.js'
 import {
   createBodySizeLimiter,
   createRateLimiter,
-  DEFAULT_MAX_BODY_SIZE,
+  DEFAULT_MAX_PAYLOAD_SIZE,
   DEFAULT_RATE_LIMIT,
   DEFAULT_RATE_WINDOW,
 } from './UIServerSecurity.js'
@@ -167,7 +167,7 @@ export class UIHttpServer extends AbstractUIServer {
         }
 
         const bodyBuffer: Uint8Array[] = []
-        const checkBodySize = createBodySizeLimiter(DEFAULT_MAX_BODY_SIZE)
+        const checkBodySize = createBodySizeLimiter(DEFAULT_MAX_PAYLOAD_SIZE)
         req
           .on('data', (chunk: Uint8Array) => {
             if (!checkBodySize(chunk.length)) {
index 5cb6c7e17bf540bb2d4ec94c8317d6bf31a440b6..844537b0fff94f315ae64db14eea8d77eb68db3d 100644 (file)
@@ -5,11 +5,10 @@ interface RateLimitEntry {
   resetTime: number
 }
 
-export const DEFAULT_MAX_BODY_SIZE = 1048576
+export const DEFAULT_MAX_PAYLOAD_SIZE = 1048576
 export const DEFAULT_RATE_LIMIT = 100
 export const DEFAULT_RATE_WINDOW = 60000
 export const DEFAULT_MAX_STATIONS = 100
-export const DEFAULT_WS_MAX_PAYLOAD = 102400
 export const DEFAULT_MAX_TRACKED_IPS = 10000
 
 export const isValidCredential = (provided: string, expected: string): boolean => {
index a64f21772f3e67d1706ef77fcba1323986749a87..16675caa153d153a833bc549fb0480e15cfd5531 100644 (file)
@@ -20,7 +20,7 @@ import {
   validateUUID,
 } from '../../utils/index.js'
 import { AbstractUIServer } from './AbstractUIServer.js'
-import { DEFAULT_WS_MAX_PAYLOAD } from './UIServerSecurity.js'
+import { DEFAULT_MAX_PAYLOAD_SIZE } from './UIServerSecurity.js'
 import {
   getProtocolAndVersion,
   handleProtocols,
@@ -36,7 +36,7 @@ export class UIWebSocketServer extends AbstractUIServer {
     super(uiServerConfiguration)
     this.webSocketServer = new WebSocketServer({
       handleProtocols,
-      maxPayload: DEFAULT_WS_MAX_PAYLOAD,
+      maxPayload: DEFAULT_MAX_PAYLOAD_SIZE,
       noServer: true,
     })
   }