ws-rmi
Version:
A Remote Method Invocation implementation written in JavaScript utilising the WebSocket protocol
21 lines (20 loc) • 1.04 kB
TypeScript
import { RMIRequest } from "./types/RMIRequest";
import { RMIRemoteResponse } from "./types/RMIRemoteResponse";
import { RMIManager } from "./RMIManager";
/**
* Handles an {@link RMIRequest} and produces either an {@link RMIRemoteResult} if the specified target:
* 1. Exists
* 2. Is a function
* 3. Doesn't throw an Error
*
* Otherwise, an {@link RMIRemoteError} is produced detailing that an error occurred. For security purposes, a generic
* error message is generated. If an Error is thrown, it is propagated back to {@link exposeFunctions} where a given
* error handler can handle it further (e.g. console logs, output to a log file, etc.)
*
* @param rmi The request body
* @param functions A class / object containing functions that can be invoked.
*/
export declare const handleRequest: ({ rmi }: RMIRequest, functions: {
[key: string]: (...args: unknown[]) => unknown;
}) => Promise<RMIRemoteResponse>;
export declare const exposeFunctions: ({ ws, config: { logger: log } }: RMIManager, functions: object) => void;