fastify-grpc-client
v0.1.0
Published
GRPC client plugin for Fastify
Downloads
48
Maintainers
Readme
fastify-grpc-client
GRPC client plugin for Fastify
Install
Just run:
npm install fastify-grpc-client --save
Test
Clone this repository, then do:
npm install
npm test
Usage
Register as a plugin:
const grpcClient = require('fastify-grpc-client');
...
fastify.register(grpcClient, {
protoFile: path.join(__dirname, 'your_proto_file.proto'),
server: 'localhost',
port: 50051,
namespace: 'helloworld',
service: 'NameOfService'
});
You can then use your gRPC services as follows:
fastify.get('/echo', function (request, reply) {
const msg = request.query.msg;
this.grpc.helloworld.invoke('Greet', {
greeting: {
first_name: msg,
last_name: 'boh'
}
}, (err, response) => {
return reply.send(response.result);
})
})
Adding multiple clients is supported, each one will have its separate namespace.
Contributing
See CONTRIBUTING.md
License
Copyright NearForm Ltd 2019. Licensed under the Apache-2.0 license.