Skip to content

Commit 2957c10

Browse files
Update grpc.md
1 parent 7213214 commit 2957c10

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

content/microservices/grpc.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,6 @@ In the `nest-cli.json` file, we add the `assets` property that allows us to dist
5050
}
5151
```
5252

53-
#### gRPC Reflection
54-
55-
The [gRPC Server Reflection Specification](https://grpc.io/docs/guides/reflection/#overview) is a standard which allows gRPC clients to request details about the API that the server exposes, akin to exposing an OpenAPI document for a REST API. This can make working with developer debugging tools such as grpc-ui or postman significantly easier.
56-
57-
To add gRPC reflection support to your server, first install the required implementation package:
58-
59-
```bash
60-
$ npm i --save @grpc/reflection
61-
```
62-
63-
Then it can be hooked into the gRPC server using the `onLoadPackageDefinition` hook in your gRPC server options, as follows:
64-
65-
```typescript
66-
@@filename(main)
67-
import { ReflectionService } from '@grpc/reflection';
68-
69-
const app = await NestFactory.createMicroservice<MicroserviceOptions>(AppModule, {
70-
options: {
71-
onLoadPackageDefinition: (pkg, server) => {
72-
new ReflectionService(pkg).addToServer(server);
73-
},
74-
},
75-
});
76-
```
77-
78-
Now your server will respond to messages requesting API details using the reflection specification.
79-
8053
#### Options
8154

8255
The <strong>gRPC</strong> transporter options object exposes the properties described below.
@@ -366,6 +339,33 @@ Please note that this would require updating the `HeroesService` interface that
366339

367340
A working example is available [here](https://github.com/nestjs/nest/tree/master/sample/04-grpc).
368341

342+
#### gRPC Reflection
343+
344+
The [gRPC Server Reflection Specification](https://grpc.io/docs/guides/reflection/#overview) is a standard which allows gRPC clients to request details about the API that the server exposes, akin to exposing an OpenAPI document for a REST API. This can make working with developer debugging tools such as grpc-ui or postman significantly easier.
345+
346+
To add gRPC reflection support to your server, first install the required implementation package:
347+
348+
```bash
349+
$ npm i --save @grpc/reflection
350+
```
351+
352+
Then it can be hooked into the gRPC server using the `onLoadPackageDefinition` hook in your gRPC server options, as follows:
353+
354+
```typescript
355+
@@filename(main)
356+
import { ReflectionService } from '@grpc/reflection';
357+
358+
const app = await NestFactory.createMicroservice<MicroserviceOptions>(AppModule, {
359+
options: {
360+
onLoadPackageDefinition: (pkg, server) => {
361+
new ReflectionService(pkg).addToServer(server);
362+
},
363+
},
364+
});
365+
```
366+
367+
Now your server will respond to messages requesting API details using the reflection specification.
368+
369369
#### gRPC Streaming
370370

371371
gRPC on its own supports long-term live connections, conventionally known as `streams`. Streams are useful for cases such as Chatting, Observations or Chunk-data transfers. Find more details in the official documentation [here](https://grpc.io/docs/guides/concepts/).

0 commit comments

Comments
 (0)