@citrineos/base
Version:
The base module for OCPP v2.0.1 including all interfaces. This module is not intended to be used directly, but rather as a dependency for other modules.
30 lines • 1.33 kB
JavaScript
// Copyright (c) 2023 S44, LLC
// Copyright Contributors to the CitrineOS Project
//
// SPDX-License-Identifier: Apache 2.0
import { METADATA_MESSAGE_ENDPOINTS } from '.';
/**
* Decorator for use in module API class to expose methods as REST OCPP message endpoints.
*
* @param {CallAction} action - The call action.
* @param {object} bodySchema - The body schema.
* @param {Record<string, any>} optionalQuerystrings - The optional querystrings.
* @return {void} This function does not return anything.
*/
export const AsMessageEndpoint = function (action, bodySchema, optionalQuerystrings) {
return (target, propertyKey, descriptor) => {
if (!Reflect.hasMetadata(METADATA_MESSAGE_ENDPOINTS, target.constructor)) {
Reflect.defineMetadata(METADATA_MESSAGE_ENDPOINTS, new Array(), target.constructor);
}
const messageEndpoints = Reflect.getMetadata(METADATA_MESSAGE_ENDPOINTS, target.constructor);
messageEndpoints.push({
action: action,
method: descriptor.value,
methodName: propertyKey,
bodySchema: bodySchema,
optionalQuerystrings: optionalQuerystrings,
});
Reflect.defineMetadata(METADATA_MESSAGE_ENDPOINTS, messageEndpoints, target.constructor);
};
};
//# sourceMappingURL=AsMessageEndpoint.js.map