refactor(simulator): introduce HTTP methods enum
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 20 Feb 2023 21:47:35 +0000 (22:47 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 20 Feb 2023 21:47:35 +0000 (22:47 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ui-server/UIHttpServer.ts

index b52df5721bafad4a4b9810ad68791d7b9ca8b68c..186669ef83e96d42c2c2fed420f2153ba4a1bfff 100644 (file)
@@ -18,6 +18,13 @@ import { AbstractUIServer, UIServerUtils } from '../internal';
 
 const moduleName = 'UIHttpServer';
 
+enum HttpMethods {
+  GET = 'GET',
+  PUT = 'PUT',
+  POST = 'POST',
+  PATCH = 'PATCH',
+}
+
 export class UIHttpServer extends AbstractUIServer {
   public constructor(protected readonly uiServerConfiguration: UIServerConfiguration) {
     super(uiServerConfiguration);
@@ -100,7 +107,7 @@ export class UIHttpServer extends AbstractUIServer {
           error
         );
       });
-      if (req.method === 'POST') {
+      if (req.method === HttpMethods.POST) {
         const bodyBuffer = [];
         req
           .on('data', (chunk) => {