@olakai/sdk
Version:
This document demonstrates how to use the Olakai SDK with all its features.
32 lines • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTransformMiddleware = createTransformMiddleware;
/**
* Create a transform middleware
* This middleware transforms the arguments and result of a function call.
* @param options - The options for the middleware
* @param options.transformArgs - The function to transform the arguments
* @param options.transformResult - The function to transform the result
* @returns A middleware function
* Important point: this Middleware is applied after the Control call to OLakai API.
* So this middleware will only modify the way that data is ent to fthe function and to the monitoring part of this API.
*/
function createTransformMiddleware(options) {
const { transformArgs, transformResult } = options;
return {
name: "transform",
beforeCall: async (args) => {
if (transformArgs) {
return await transformArgs(args);
}
return args;
},
afterCall: async (result, _args) => {
if (transformResult) {
return await transformResult(result);
}
return result;
},
};
}
//# sourceMappingURL=transform.js.map