feat: support generating TypeScript definitions to be used with @grpc/proto-loader
This commit is contained in:
@@ -14,7 +14,8 @@ Download the [Protocol Buffers compiler](https://github.com/protocolbuffers/prot
|
||||
your platform and add `protoc` to `PATH` environment variable
|
||||
|
||||
For generating Go code, install `protoc-gen-go` (v1.27.1+):
|
||||
```bash
|
||||
|
||||
```shell
|
||||
GIT_TAG="v1.27.1"
|
||||
go get -d -u google.golang.org/protobuf/cmd/protoc-gen-go
|
||||
git -C "$(go env GOPATH)"/src/google.golang.org/protobuf checkout $GIT_TAG
|
||||
@@ -22,38 +23,46 @@ go install google.golang.org/protobuf/cmd/protoc-gen-go
|
||||
```
|
||||
|
||||
Also install `protoc-gen-go-grpc` v1.1.0+:
|
||||
```bash
|
||||
|
||||
```shell
|
||||
go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc
|
||||
```
|
||||
|
||||
Or install using [gobin](https://github.com/myitcv/gobin):
|
||||
```bash
|
||||
|
||||
```shell
|
||||
gobin google.golang.org/protobuf/cmd/protoc-gen-go
|
||||
gobin google.golang.org/grpc/cmd/protoc-gen-go-grpc
|
||||
```
|
||||
|
||||
For generating HTTP JSON APIs with [grpc-gateway](https://grpc-ecosystem.github.io/grpc-gateway/), follow the [documentation](https://github.com/grpc-ecosystem/grpc-gateway/tree/v2#installation).
|
||||
For generating HTTP JSON APIs with [grpc-gateway](https://grpc-ecosystem.github.io/grpc-gateway/), follow
|
||||
the [documentation](https://github.com/grpc-ecosystem/grpc-gateway/tree/v2#installation).
|
||||
|
||||
For generating validators install [go-proto-validators](https://github.com/mwitkow/go-proto-validators/tree/master/protoc-gen-govalidators):
|
||||
```bash
|
||||
For generating validators
|
||||
install [go-proto-validators](https://github.com/mwitkow/go-proto-validators/tree/master/protoc-gen-govalidators):
|
||||
|
||||
```shell
|
||||
go get github.com/mwitkow/go-proto-validators/protoc-gen-govalidators
|
||||
```
|
||||
|
||||
For generating Java code: From `bdledger-sdk-java` run `gradle generateProto`
|
||||
|
||||
For generating Node.js code (and TypeScript definitions), install Node.js then run:
|
||||
```bash
|
||||
For generating Node.js code and/or TypeScript definitions), install Node.js then run:
|
||||
|
||||
```shell
|
||||
npm install
|
||||
```
|
||||
|
||||
For frontend JavaScript:
|
||||
```bash
|
||||
|
||||
```shell
|
||||
git clone https://github.com/grpc/grpc-web
|
||||
cd grpc-web
|
||||
sudo make install-plugin
|
||||
```
|
||||
|
||||
References:
|
||||
|
||||
- [Go Quick Start](https://grpc.io/docs/quickstart/go.html#prerequisites)
|
||||
- [gRPC Go FAQ](https://github.com/grpc/grpc-go#faq)
|
||||
|
||||
@@ -63,16 +72,27 @@ References:
|
||||
##### Generating code
|
||||
|
||||
Run:
|
||||
```bash
|
||||
|
||||
```shell
|
||||
./scripts/gen [-a, --async] [go] [gohttp] [nodejs] [docs]
|
||||
```
|
||||
Use `-a` or `--async` to speed up generation by asynchronously and concurrently generating all code and documentation (script will exit without waiting for completion)
|
||||
|
||||
`nodejs`: For generating static Node.js code and TypeScript definitions
|
||||
|
||||
Use `-a` or `--async` to speed up generation by asynchronously and concurrently generating all code and documentation (
|
||||
script will exit without waiting for completion)
|
||||
|
||||
For generating TypeScript definitions to be used with `@grpc/proto-loader`, run:
|
||||
|
||||
```shell
|
||||
invoke gen -t types
|
||||
```
|
||||
|
||||
#### Generateing documentation
|
||||
|
||||
Install Go then run:
|
||||
|
||||
```bash
|
||||
```shell
|
||||
go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
|
||||
./scripts/gen [-a, --async] docs
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user