# grpc-creator **Repository Path**: feedoom/grpc-creator ## Basic Information - **Project Name**: grpc-creator - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-05-15 - **Last Updated**: 2022-05-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 封装grpc service 为源码 example 为例子 你需要安装 [protoc](https://github.com/protocolbuffers/protobuf/releases) 和 [protoc-gen-grpc-web](https://hub.fastgit.xyz/grpc/grpc-web/releases) 生成grpc代码文件, 并添加环境变量 ```shell $ sudo mv ~/Downloads/protoc-gen-grpc-web-1.3.1-darwin-x86_64 \ /usr/local/bin/protoc-gen-grpc-web $ chmod +x /usr/local/bin/protoc-gen-grpc-web ``` 生成文件命令 ```shell protoc -I ./proto所在的文件夹 --js_out=import_style=commonjs:./输出文件夹 --grpc-web_out=import_style=typescript,mode=grpcweb:./输出文件夹 hello.proto ``` 该grpc封装需要`grpc-web`库 ```shell npm install grpc-web ``` 在项目中使用 将`service` 下的 `service.ts` 的文件复制到项目中,便可使用文件里的 `GrpcCreator` 类