@olakai/sdk
Version:
This document demonstrates how to use the Olakai SDK with all its features.
24 lines • 1.46 kB
TypeScript
import type { MonitorOptions } from "./types";
import type { Middleware } from "./middleware";
/**
* Add a middleware to the global middleware registry
* @param middleware - The middleware to add. See exports from ./middleware/index.ts for available middlewares
*/
export declare function addMiddleware<TArgs extends any[], TResult>(middleware: Middleware<TArgs, TResult>): void;
/**
* Remove a middleware from the global middleware registry
* @param name - The name of the middleware to remove
*/
export declare function removeMiddleware(name: string): void;
/**
* Monitor a function and send the data to the Olakai API
* Always returns an async function, but can monitor both sync and async functions
* @param options - The options for the monitored function
* @param fn - The function to monitor (sync or async)
* @returns The monitored async function
* @throws {OlakaiBlockedError} if the function is blocked by Olakai's Control API
* @throws {Error} throw the original function's error if the function fails
*/
export declare function monitor<TArgs extends any[], TResult>(options: MonitorOptions<TArgs, TResult>): (fn: (...args: TArgs) => TResult | Promise<TResult>) => (...args: TArgs) => Promise<TResult>;
export declare function monitor<TArgs extends any[], TResult>(fn: (...args: TArgs) => TResult | Promise<TResult>, options: MonitorOptions<TArgs, TResult>): (...args: TArgs) => Promise<TResult>;
//# sourceMappingURL=monitor.d.ts.map