@matejdr/react-native-grpc-bridge
v0.2.0
Published
A bridge for @improbable-eng/grpc-web using native gRPC
Downloads
4
Readme
@matejdr/react-native-grpc-bridge
A bridge for @improbable-eng/grpc-web using native gRPC
Based on react-native-grpc from Mitch528, found here.
Installation
npm install @matejdr/react-native-grpc-bridge
Node version
nvm install
or
nvm use
Install npm packages
yarn install
Usage
import { grpc } from '@improbable-eng/grpc-web';
import { NativeGRPCTransport } from '@matejdr/react-native-grpc-bridge';
grpc.setDefaultTransport(NativeGRPCTransport({ withCredentials: true }));
Running a docker Server for example app
There is an envoy proxy in front of go server.
cd server
docker-compose up --build server envoy
Running a gRPC Server manually
You can also run the grpc server manually using the following instructions.
Install protoc
- protoc : link
Install for go
go get -u google.golang.org/grpc
go get -u github.com/golang/protobuf/proto
go install github.com/golang/protobuf/protoc-gen-go@latest
export PATH=$HOME/go/bin:$PATH
Install grpc-web
GROC_WEB_PLUGIN=protoc-gen-grpc-web-1.0.6-darwin-x86_64
curl -OL https://github.com/grpc/grpc-web/releases/download/1.0.6/$GROC_WEB_PLUGIN
sudo mv $GROC_WEB_PLUGIN /usr/local/bin/protoc-gen-grpc-web
chmod +x /usr/local/bin/protoc-gen-grpc-web
Generate stubs for js and go
protoc \
--proto_path=server/proto \
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
--js_out=import_style=commonjs:example/src/api \
--ts_out=service=grpc-web:example/src/api \
echo.proto
protoc \
--proto_path=server/proto \
--go_out=plugins=grpc:server/echoserver/echo \
--go_opt=paths=source_relative \
echo.proto
Running a server
cd server/echoserver
go run main.go
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT