From 909dcf2dda1acb9556a5ec21c252bcca2992ec1c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 22 Feb 2022 20:01:26 +0100 Subject: [PATCH] Cleanup OCPP service module name usage MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts | 4 +++- src/charging-station/ocpp/1.6/OCPP16RequestService.ts | 4 +++- src/charging-station/ocpp/1.6/OCPP16ResponseService.ts | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 6cf07805..5b7ac480 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -25,11 +25,13 @@ import logger from '../../../utils/Logger'; import path from 'path'; import tar from 'tar'; +const moduleName = 'OCPPIncomingRequestService'; + export default class OCPP16IncomingRequestService extends OCPPIncomingRequestService { private incomingRequestHandlers: Map; public constructor(chargingStation: ChargingStation) { - if (new.target?.name === 'OCPP16IncomingRequestService') { + if (new.target?.name === moduleName) { throw new TypeError(`Cannot construct ${new.target?.name} instances directly`); } super(chargingStation); diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 3b671d6b..7ec4b019 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -23,9 +23,11 @@ import { SendParams } from '../../../types/ocpp/Requests'; import Utils from '../../../utils/Utils'; import logger from '../../../utils/Logger'; +const moduleName = 'OCPP16RequestService'; + export default class OCPP16RequestService extends OCPPRequestService { public constructor(chargingStation: ChargingStation, ocppResponseService: OCPPResponseService) { - if (new.target?.name === 'OCPP16RequestService') { + if (new.target?.name === moduleName) { throw new TypeError(`Cannot construct ${new.target?.name} instances directly`); } super(chargingStation, ocppResponseService); diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 54815bd6..7f1217fa 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -17,11 +17,13 @@ import { ResponseHandler } from '../../../types/ocpp/Responses'; import Utils from '../../../utils/Utils'; import logger from '../../../utils/Logger'; +const moduleName = 'OCPP16ResponseService'; + export default class OCPP16ResponseService extends OCPPResponseService { private responseHandlers: Map; public constructor(chargingStation: ChargingStation) { - if (new.target?.name === 'OCPP16ResponseService') { + if (new.target?.name === moduleName) { throw new TypeError(`Cannot construct ${new.target?.name} instances directly`); } super(chargingStation); -- 2.34.1