Consider a NestJS gRPC service with this method:
async getHello(): Promise<{ message: string }> { return { message: 'Hello from gRPC!' }; }If a client calls getHello, what will the client receive?
async getHello(): Promise<{ message: string }> { return { message: 'Hello from gRPC!' }; }
gRPC methods typically return objects matching the protobuf message structure.
The method returns an object with a 'message' property. The client receives this object serialized by gRPC.
Choose the correct code snippet to create a NestJS microservice using gRPC transport with package 'hero' and proto file 'hero.proto'.
Use connectMicroservice with Transport.GRPC for gRPC microservices.
Only option B uses connectMicroservice with the correct transport and options for gRPC.
If you configure a NestJS gRPC microservice with a wrong protoPath that does not exist, what error will you see when starting the app?
Check the file path carefully when loading proto files.
If the proto file path is wrong, Node.js throws a file not found error (ENOENT).
Given this client call:
const response = await client.send<{ message: string }>('getHello', {}).toPromise();What is the value of response.message if the server returns { message: 'Hi there!' }?
const response = await client.send<{ message: string }>('getHello', {}).toPromise();
The client receives the server's response object.
The response variable holds the object returned by the server, so response.message is 'Hi there!'.
Choose the most accurate description of how protobuf works with NestJS gRPC transport.
Think about what protobuf files describe in gRPC communication.
Protobuf files define the structure of messages and services so gRPC can serialize and deserialize data correctly.