@jsonjoy.com/reactive-rpc
Version:
Reactive-RPC is a library for building reactive APIs over WebSocket, HTTP, and other RPCs.
33 lines (32 loc) • 1.35 kB
TypeScript
import type { Printable } from 'sonic-forest/lib/print/types';
import { type Http1CreateServerOpts, Http1Server, type Http1ServerOpts } from './Http1Server';
import { RpcMessageBatchProcessor } from '../../common';
import type { RpcCaller } from '../../common/rpc/caller/RpcCaller';
import type { ServerLogger } from './types';
import type { ConnectionContext } from '../types';
export interface RpcServerOpts {
http1: Http1Server;
caller: RpcCaller<any>;
logger?: ServerLogger;
}
export interface RpcServerStartOpts extends Omit<RpcServerOpts, 'http1'> {
port?: number;
server?: Omit<Http1ServerOpts, 'server'>;
create?: Http1CreateServerOpts;
}
export declare class RpcServer implements Printable {
protected readonly opts: RpcServerOpts;
static readonly startWithDefaults: (opts: RpcServerStartOpts) => Promise<RpcServer>;
readonly http1: Http1Server;
protected readonly batchProcessor: RpcMessageBatchProcessor<ConnectionContext>;
constructor(opts: RpcServerOpts);
enableHttpPing(): void;
enableCors(): void;
private processHttpRpcRequest;
enableHttpRpc(path?: string): void;
enableJsonRcp2HttpRpc(path?: string): void;
enableWsRpc(path?: string): void;
enableSchema(path?: string, method?: string): void;
enableDefaults(): void;
toString(tab?: string): string;
}