# Protoc

install `protoc` and required plugins.

## Prerequisites

1. node, npm
2. buf
3. prototool
4. clang-format
5. proto
6. protoc-gen-go
7. protoc-gen-validate
8. protoc-gen-grpc-gateway
9. protoc-gen-grpc-web
10. protoc-gen-swagger

### Installation

```bash
# basics
brew install node

# plugins
npm install -g grpc-tools
brew install protoc-gen-grpc-web
```

```bash
# linter/generator and tool for proto files
GO111MODULE=on go get github.com/uber/prototool/cmd/prototool@dev
# linter tool for proto files
GO111MODULE=on go get github.com/bufbuild/buf/cmd/buf
# VS Code plugin `vscode-proto3` need clang-format
brew install clang-format
# fetch protoc plugins into $GOPATH
GO111MODULE=on go get google.golang.org/protobuf/cmd/protoc-gen-go
GO111MODULE=on go get google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.0

GO111MODULE=on go get github.com/grpc-ecosystem/grpc-gateway/{protoc-gen-grpc-gateway,protoc-gen-swagger}

# Installing PGV can currently only be done from source:
go get -d github.com/envoyproxy/protoc-gen-validate
cd ~/go/src/github.com/envoyproxy/protoc-gen-validate
git pull
make build
```

## Reference

* <https://github.com/grpc/grpc-web/tree/master/packages/grpc-web>
* <https://github.com/stephenh/ts-proto>
* [gRPC on Node.js with Buf and TypeScript](https://slavovojacek.medium.com/grpc-on-node-js-with-buf-and-typescript-part-1-5aad61bab03b)
