@olakai/sdk
Version:
This document demonstrates how to use the Olakai SDK with all its features.
30 lines • 1.23 kB
TypeScript
export * from "./logging";
export * from "./rateLimiter";
export * from "./timeout";
export * from "./caching";
export * from "./circuitBreaker";
export * from "./common";
export * from "./transform";
export * from "./custom";
/**
* Middleware type
* @param TArgs - The type of the arguments of the function
* @param TResult - The type of the result of the function
* @returns A middleware type definition
*/
export type Middleware<TArgs extends any[], TResult> = {
name: string;
beforeCall?: (args: TArgs) => TArgs | Promise<TArgs>;
afterCall?: (result: TResult, args: TArgs) => TResult | Promise<TResult>;
onError?: (error: any, args: TArgs) => void | Promise<void>;
};
/**
* Apply middleware to a function
* @param middlewares - The middleware to apply
* @param args - The arguments to pass to the function
* @param action - The action to perform
* @param result - The result of the function
* @param error - The error of the function
*/
export declare function applyMiddleware<TArgs extends any[], TResult>(middlewares: Middleware<TArgs, TResult>[], args: TArgs, action: "beforeCall" | "afterCall" | "error", result?: TResult, error?: any): Promise<TArgs | TResult>;
//# sourceMappingURL=index.d.ts.map