1.1.0 • Published 3 months ago

@xplora-uk/grpc-client v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

grpc-client

gRPC client based on @grpc/grpc-js and @grpc/proto-loader

It does not support streams.

requirements for dev

  • Node v18.x

install

npm i

Source code is inside lib

test

npm run test

requirements to use

  • Node v18.x

install library

npm i @xplora-uk/grpc-client

usage

You can check tests and examples.

const { join, resolve } = require('path');
const newGrpcClient = require('@xplora-uk/grpc-client');

// simplest example
const baseProtoFile = resolve(join(__dirname, '..', 'grpc.base.v1.proto'));
const echoProtoFile = resolve(join(__dirname, '..', 'grpc.echo.v1.proto'));
const echoService = newGrpcClient({
  protoFiles: [
    baseProtoFile,
    echoProtoFile,
  ],
  packageName: 'grpc.echo.v1',
  serviceName: 'EchoService',
  host,
});

const echoReply = await echoService.Echo({ data: 'hello ' });