Thin adapter over @grpc/grpc-js for performing gRPC calls.

Dependencies (@grpc/grpc-js, @grpc/proto-loader) are loaded lazily at runtime so they remain optional peer dependencies.

const transport = new GrpcTransport({
endpoint: 'localhost:50051',
protoPath: './geyser.proto',
packageName: 'geyser',
});
transport.loadProto();
const svc = transport.getService<GeyserService>('Geyser');
const result = await transport.unary(svc, 'GetSlot', {});

1.0.0

Constructors

Methods

  • Get or create a gRPC service stub connected to the configured endpoint.

    Type Parameters

    • T = any

      The expected service stub type.

    Parameters

    • serviceName: string

      Name of the service as defined in the .proto file.

    Returns T

    A connected service stub instance.

    If the service has not been loaded via loadProto.

    1.0.0

  • Load a .proto file and register all discovered service constructors.

    Parameters

    Returns void

    If no proto path is provided or a package segment is missing.

    1.0.0

  • Execute a unary gRPC call wrapped in a promise.

    Automatically applies metadata and deadline from both the transport configuration and per-call options.

    Type Parameters

    • TReq

      Request message type.

    • TRes

      Response message type.

    Parameters

    • service: any

      The service stub obtained from getService.

    • method: string

      The RPC method name on the service.

    • request: TReq

      The request payload.

    • opts: GrpcCallOptions = {}

      Optional per-call overrides for deadline and metadata.

    Returns Promise<TRes>

    A promise that resolves with the response message.

    1.0.0