UNPKG

@grpc.ts/nestjs-server

Version:
23 lines (22 loc) 971 B
import type { Metadata, ServerUnaryCall, TUnaryCallback } from '@grpc.ts/core'; import type { IGrpcServerProps } from '@grpc.ts/core/lib/interface'; import type { ISubscribeParams } from './interface'; type TCallback = () => void; interface ICreateServiceReturnProps { strategy: GrpcServer; } interface IMessageHandlerProps<TData = unknown, TResult = unknown> { (data: TData, metadata: Metadata, call: ServerUnaryCall<unknown, unknown>, callback: TUnaryCallback<unknown>): Promise<TResult>; } type TOptions = IGrpcServerProps | IGrpcServerProps[]; export declare class GrpcServer { #private; constructor(props: TOptions); static createService(params: TOptions): ICreateServiceReturnProps; addHandler(pattern: ISubscribeParams & { isGrpc: boolean; }, callback: IMessageHandlerProps, isEventHandler?: boolean, _extras?: Record<string, any>): void; listen(callback: TCallback): Promise<void>; close(): Promise<void>; } export {};