Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gustavohenrique/grpc-web-sample
https://github.com/gustavohenrique/grpc-web-sample
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/gustavohenrique/grpc-web-sample
- Owner: gustavohenrique
- Created: 2019-07-19T20:10:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T07:56:52.000Z (almost 2 years ago)
- Last Synced: 2024-04-16T03:18:23.521Z (9 months ago)
- Language: JavaScript
- Size: 669 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
> An example using gRPC-Web client and Golang Server
## Setup
### Install gRPC tools
#### MacOS
```sh
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.9.0/protoc-3.9.0-osx-x86_64.zip
unzip protoc-3.9.0*.zip
sudo mv bin/protoc /usr/local/binwget https://github.com/grpc/grpc-web/releases/download/1.0.5/protoc-gen-grpc-web-1.0.5-darwin-x86_64
chmod +x protoc-gent-grpc-web*
sudo mv protoc-gen-grpc-web* /usr/local/bin/protoc-gen-grpc-web
```#### Linux
```sh
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.9.0/protoc-3.9.0-linux-x86_64.zip
unzip protoc-3.9.0*.zip
sudo mv bin/protoc /usr/local/binwget https://github.com/grpc/grpc-web/releases/download/1.0.5/protoc-gen-grpc-web-1.0.5-linux-x86_64
chmod +x protoc-gent-grpc-web*
sudo mv protoc-gen-grpc-web* /usr/local/bin/protoc-gen-grpc-web
```### Install Go dependencies
```sh
cd server
make setup
```### Install Javascript dependencies
```sh
cd web
npm i
```## Running
```sh
make containers # docker-compose up -d
```## Usage
You can serve and point browser to `web/index.html` or use grpcurl:
```sh
grpcurl -proto proto/ecommerce.proto -plaintext -v localhost:8080 ecommerce.ProductService/ReadAll
```## Generate self signed certificate
```sh
# Using Go
go run $GOROOT/src/crypto/tls/generate_cert.go --host mydomain.io# Using OpenSSL
openssl req -nodes -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
```