this module work with grpc server side module 'gprc-server-ts'.
look here to see server side example : https://github.com/xuezier/grpc-server-ts
Installation
npm install grpc-client-ts --save
protobuf
hello.proto
syntax = "proto3"; option java_multiple_files = true;option java_package = "io.grpc.service.test";option objc_class_prefix ="RTG"; package hello; service Hello { rpc say(stream Empty) returns (stream Word) {};} message Empty { } message Word { string word = 1;}
define a client
HelloRpc.ts
;
registry client grpc
; ClientRpc.start;
settings
port: "3333" // listen port host: "localhost" // listen host ca: "runtime/rpc/ca.crt" // ca file path client_cert: "runtime/rpc/server.crt" // client_cert file path client_key: "runtime/rpc/server.key" // client_key file path
Full example with 'mvc-ts'
controller
; ;;
index.ts
; ; ; ;Application.start5566; ClientRpc.start;
open browser visite http://localhost:5566/example/hello get result