This package is based on @improbable-eng/ts-protoc-gen. Do small modification to change using grpc to @grpc/grpc-js.
Install
npm install jerry-ts-protoc-gen
or
yarn add jerry-ts-protoc-gen
node Usage
You might need to install grpc-tools first.
This plugin can generate .d.ts
files for gRPC service definitions as required by grpc-node.
To generate these declaration files from your protobuf files you must configure ts-protoc-gen to emit service definitions by passing the service=grpc-node
param to the --ts_out
flag, eg:
# Path to this plugin, Note this must be an abolsute path on Windows (see #15)
PROTOC_GEN_TS_PATH="./node_modules/.bin/protoc-gen-ts"
# Path to the grpc_node_plugin
PROTOC_GEN_GRPC_PATH="./node_modules/.bin/grpc_tools_node_protoc_plugin"
# Directory to write generated code to (.js and .d.ts files)
OUT_DIR="./generated"
protoc \
--plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
--plugin=protoc-gen-grpc=${PROTOC_GEN_GRPC_PATH} \
--js_out="import_style=commonjs,binary:${OUT_DIR}" \
--ts_out="service=grpc-node:${OUT_DIR}" \
--grpc_out="grpc_js:${OUT_DIR}" \
users.proto base.proto
Other Usage
Other usage are as same as the origin plugin.