+import { AsyncResource } from 'async_hooks';
+
import type { JSONSchemaType } from 'ajv';
import Ajv from 'ajv-draft-04';
import ajvFormats from 'ajv-formats';
export default abstract class OCPPIncomingRequestService {
private static instance: OCPPIncomingRequestService | null = null;
- private ajv: Ajv;
+ protected asyncResource: AsyncResource;
+ private readonly ajv: Ajv;
protected constructor() {
+ this.asyncResource = new AsyncResource(moduleName);
this.ajv = new Ajv();
ajvFormats(this.ajv);
this.incomingRequestHandler.bind(this);
commandName: IncomingRequestCommand,
error: Error,
params: HandleErrorParams<T> = { throwError: true }
- ): T {
+ ): T | undefined {
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.handleIncomingRequestError: Incoming request command '${commandName}' error:`,
error
schema: JSONSchemaType<T>,
payload: T
): boolean {
- if (!chargingStation.getPayloadSchemaValidation()) {
+ if (chargingStation.getPayloadSchemaValidation() === false) {
return true;
}
const validate = this.ajv.compile(schema);