Skip to content

Commit

Permalink
Fixed code highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusLongmuir committed Feb 6, 2018
1 parent 8d291da commit b104097
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
6 changes: 3 additions & 3 deletions ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ There are three functions for making gRPC requests:
### [`grpc.unary`](docs/unary.md)
This is a convenience function for making requests that consist of a single request message and single response message. It can only be used with unary methods.

```
```protobuf
rpc GetBook(GetBookRequest) returns (Book) {}
```

### [`grpc.invoke`](docs/invoke.md)
This is a convenience function for making requests that consist of a single request message and a stream of response messages (server-streaming). It can also be used with unary methods.

```
```protobuf
rpc GetBook(GetBookRequest) returns (Book) {}
rpc QueryBooks(QueryBooksRequest) returns (stream Book) {}
```

### [`grpc.client`](docs/client.md)
`grpc.client` returns a client. Dependant upon [transport compatibility](docs/transport) this client is capable of sending multiple request messages (client-streaming) and receiving multiple response messages (server-streaming). It can be used with any type of method, but will enforce limiting the sending of messages for unary methods.

```
```protobuf
rpc GetBook(GetBookRequest) returns (Book) {}
rpc QueryBooks(QueryBooksRequest) returns (stream Book) {}
rpc LogReadPages(stream PageRead) returns (google.protobuf.Empty) {}
Expand Down
33 changes: 17 additions & 16 deletions ts/docs/code-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ To make gRPC requests the client requires generated code for the [method definit

This process is slightly different between TypeScript and JavaScript usage.

### TypeScript ([skip to JS](#JavaScript))
### TypeScript ([skip to JS](#javascript))

[`ts-protoc-gen`](https://www.github.com/improbable-eng/ts-protoc-gen) is a package that can generate the `.d.ts` files that declare the contents of the protoc-generated JavaScript files. `ts-protoc-gen` can also generate `grpc-web-client` service/method definitions with the `protoc-gen-ts` plugin and `service=true` argument.

This is an example of a complete invokation of `protoc` with `ts-protoc-gen` assuming your `.proto` files are in a directory named `my-protos` within the current working directory:

```
```bash
protoc \
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
--js_out=import_style=commonjs,binary:my-generated-code \
Expand All @@ -23,23 +23,24 @@ my-protos/*.proto

A proto file such as `book_service.proto`:

```syntax = "proto3";
```protobuf
syntax = "proto3";
package examplecom.library;
package examplecom.library;
message Book {
int64 isbn = 1;
string title = 2;
string author = 3;
}
message Book {
int64 isbn = 1;
string title = 2;
string author = 3;
}
message GetBookRequest {
int64 isbn = 1;
}
message GetBookRequest {
int64 isbn = 1;
}
service BookService {
rpc GetBook(GetBookRequest) returns (Book) {}
}
service BookService {
rpc GetBook(GetBookRequest) returns (Book) {}
}
```

Will generate `book_service_pb.js`, `book_service_pb.d.ts` and `book_service_pb_service.ts`.
Expand All @@ -53,7 +54,7 @@ The first two files contain the message classes and `book_service_pb_service.ts`

This is an example of a complete invokation of `protoc` with `ts-protoc-gen` assuming your `.proto` files are in a directory named `my-protos` within the current working directory:

```
```bash
protoc \
--plugin=protoc-gen-js_service=./node_modules/.bin/protoc-gen-js_service \
--js_out=import_style=commonjs,binary:my-generated-code \
Expand Down

0 comments on commit b104097

Please sign in to comment.