UNPKG

@jsonjoy.com/reactive-rpc

Version:

Reactive-RPC is a library for building reactive APIs over WebSocket, HTTP, and other RPCs.

38 lines (37 loc) 1.66 kB
import { Codecs } from '@jsonjoy.com/json-pack/lib/codecs/Codecs'; import { Router } from '@jsonjoy.com/jit-router'; import { RpcMessageBatchProcessor } from '../../common/rpc/RpcMessageBatchProcessor'; import { ConnectionContext } from '../context'; import { RpcCodecs } from '../../common/codec/RpcCodecs'; import type { Printable } from 'sonic-forest/lib/print/types'; import type * as types from './types'; import type { RouteHandler } from './types'; import type { RpcCaller } from '../../common/rpc/caller/RpcCaller'; export interface RpcAppOptions { uws: types.TemplatedApp; caller: RpcCaller<any>; maxRequestBodySize?: number; codecs?: Codecs; port?: number; host?: string; augmentContext?: (ctx: ConnectionContext) => void; logger?: types.ServerLogger; } export declare class RpcApp<Ctx extends ConnectionContext> implements Printable { protected readonly options: RpcAppOptions; readonly codecs: RpcCodecs; protected readonly app: types.TemplatedApp; protected readonly maxRequestBodySize: number; protected readonly router: Router<unknown>; protected readonly batchProcessor: RpcMessageBatchProcessor<Ctx>; constructor(options: RpcAppOptions); enableCors(): void; routeRaw(method: types.HttpMethodPermissive, path: string, handler: RouteHandler<Ctx>): void; route(method: types.HttpMethodPermissive, path: string, handler: types.JsonRouteHandler<Ctx>): void; enableHttpPing(path?: string): this; enableHttpRpc(path?: string): this; enableWsRpc(path?: string): this; startRouting(): void; startWithDefaults(): void; toString(tab?: string): string; }