A unified build tool that generates gRPC server and client code for multiple languages from Protocol Buffer (.proto) files.
- Go: Server and client code using protoc-gen-go and protoc-gen-go-grpc
- Python: Server and client code using grpcio-tools
- TypeScript/NestJS: Both general TypeScript and NestJS-specific code using ts-proto
- Rust: Server and client code using tonic-build
├── proto/ # Protocol Buffer definitions
│ ├── hero.proto
│ └── calculator.proto
├── generated/ # Generated code output
│ ├── go/ # Go generated files
│ ├── python/ # Python generated files
│ ├── typescript/ # TypeScript generated files
│ │ └── nestjs/ # NestJS-specific files
│ └── rust/ # Rust generated files
├── codegen.js # Main build tool
└── package.json # Node.js dependencies
- Install dependencies:
npm install- The tool will automatically install language-specific dependencies when needed.
npm run build
# or
node codegen.js# Go
npm run build:go
node codegen.js --language=go
# Python
npm run build:python
node codegen.js --language=python
# TypeScript/NestJS
npm run build:typescript
node codegen.js --language=typescript
# Rust
npm run build:rust
node codegen.js --language=rustnode codegen.js --list- Add your
.protofiles to theproto/directory - Run the code generator
- The generated code will be available in the
generated/directory
syntax = "proto3";
package myservice;
option go_package = "./myservice";
message MyRequest {
string name = 1;
}
message MyResponse {
string message = 1;
}
service MyService {
rpc SayHello(MyRequest) returns (MyResponse) {}
}import "path/to/generated/go/myservice"import myservice_pb2
import myservice_pb2_grpcimport { MyServiceClient } from './generated/typescript/myservice';use grpc_generated::myservice::{MyRequest, MyResponse};- Node.js (for the build tool)
- Protocol Buffers compiler (included)
- Language-specific requirements:
- Go: Go compiler and tools
- Python: Python 3 and pip
- TypeScript: Node.js and npm
- Rust: Cargo and Rust toolchain