96 lines
2.3 KiB
Markdown
96 lines
2.3 KiB
Markdown
## BDLedger API
|
|
|
|
### Documentation
|
|
|
|
See [API documentation](..\docs\apis.md)
|
|
|
|
### Development
|
|
|
|
#### Generating gRPC code in languages
|
|
|
|
##### Installling tools
|
|
|
|
Download the [Protocol Buffers compiler](https://github.com/protocolbuffers/protobuf/releases) (protoc-25.3-*)+ for
|
|
your platform and add `protoc` to `PATH` environment variable
|
|
|
|
For generating Go code, install `protoc-gen-go` (v1.33.0+):
|
|
|
|
```sh
|
|
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
|
```
|
|
|
|
Also install `protoc-gen-go-grpc` v1.3.0+:
|
|
|
|
```sh
|
|
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
|
```
|
|
|
|
For generating HTTP JSON APIs with [grpc-gateway](https://grpc-ecosystem.github.io/grpc-gateway/) **v2.2.0**, follow
|
|
the [documentation](https://github.com/grpc-ecosystem/grpc-gateway#installation).
|
|
|
|
For generating validators, install [go-proto-validators](https://github.com/mwitkow/go-proto-validators/tree/master/protoc-gen-govalidators) v0.3.2+:
|
|
|
|
```sh
|
|
go install github.com/mwitkow/go-proto-validators/protoc-gen-govalidators@latest
|
|
```
|
|
|
|
For generating Java code: From `bdledger-sdk-java` run `gradle generateProto`
|
|
|
|
For generating Node.js code and/or TypeScript definitions), install Node.js then run:
|
|
|
|
```sh
|
|
npm install
|
|
```
|
|
|
|
For frontend JavaScript:
|
|
|
|
```sh
|
|
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)
|
|
|
|
**TODO: Look into [protobuf.js](https://github.com/protobufjs/protobuf.js) for Nodes.js and frontend**
|
|
**TODO: Look into [Kroto+](https://github.com/marcoferrer/kroto-plus) for Kotlin**
|
|
|
|
##### Generating code
|
|
|
|
Run:
|
|
|
|
For generating TypeScript client code with `ts-proto`, run:
|
|
|
|
```sh
|
|
invoke gen -t ts
|
|
```
|
|
|
|
For generating TypeScript definitions to be used with `@grpc/proto-loader`, run:
|
|
|
|
```sh
|
|
invoke gen -t types
|
|
```
|
|
|
|
Others:
|
|
|
|
```sh
|
|
./scripts/gen [-a, --async] [go] [gohttp] [nodejs] [docs]
|
|
```
|
|
|
|
`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)
|
|
|
|
#### Generating documentation
|
|
|
|
Install Go then run:
|
|
|
|
```sh
|
|
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest
|
|
./scripts/gen [-a, --async] docs
|
|
```
|