Skip to content

Commit 6bfb47e

Browse files
committed
Create README.md
1 parent 65dc559 commit 6bfb47e

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Protoc Tools gRPC Web Plugin
2+
**Protoc gRPC web generator plugin for @accility/protoc-tools ([NPM](https://npmjs.com/package/accility/protoc-tools) | [GitHub](https://github.com/accility/protoc-tools))**
3+
4+
This package downloads and utilizes the [gRPC Web](https://github.com/grpc/grpc-web) ([protoc-gen-grpc-web](https://github.com/grpc/grpc-web/releases)) plugin from the [gRPC](https://github.com/grpc) project on post-install.
5+
6+
[protoc-gen-grpc-web](https://github.com/grpc/grpc-web/releases) is a plugin and can be used with [@accility/protoc-tools](https://github.com/accility/protoc-tools) directly. But protoc-gen-grpc-web is a binary and needs to be installed for respectively operating system, which this plugin does on post-install **and** needs to be executed in PATH, which this plugin adds the binary directory to the process enviroment PATH variable.
7+
8+
## Usage
9+
10+
```javascript
11+
import * as tools from '@accility/protoc-tools'
12+
import * as gRPCWeb from '../dist/plugin'
13+
14+
// OR
15+
16+
const tools = require('@accility/protoc-tools')
17+
const gRPCWeb = require('../dist/plugin')
18+
19+
tools.protoc({
20+
...
21+
outOptions: [
22+
gRPCWeb({
23+
module: 'commonjs', // 'closure' | 'commonjs' | 'commonjs+dts' | 'typescript'
24+
// mode: 'grpcwebtext' | 'grpcweb'
25+
})
26+
]
27+
})
28+
```
29+
30+
### Module
31+
Import style (https://github.com/grpc/grpc-web#import-style)
32+
33+
- `closure` - the default generated code has Closure `goog.require()` import style.
34+
- `commonjs` - the CommonJS style `require()` is also supported.
35+
- `commonjs+dts` - (experimental) in addition to above, a .d.ts typings file will also be generated for the protobufssages and service stub.
36+
- `typescript` - (experimental) the service stub will be generat
37+
38+
### Mode
39+
Wire format mode (https://github.com/grpc/grpc-web#wire-format-mode)
40+
41+
`grpcwebtext`: The default generated code sends the payload in the grpc-web-text format.
42+
- `Content-type: application/grpc-web-text`
43+
- Payload are base64-encoded.
44+
- Both unary and server streaming calls are supported.
45+
46+
`grpcweb`: A binary protobuf format is also supported.
47+
- `Content-type: application/grpc-web+proto`
48+
- Payload are in the binary protobuf format.
49+
- Only unary calls are supported for now.

0 commit comments

Comments
 (0)