Complete the code to define a gRPC service method in the proto file.
service UserService {
rpc GetUser (GetUserRequest) returns ([1]);
}The gRPC method must specify the response message type. Here, GetUserResponse is the correct response message.
Complete the code to create a gRPC client stub in the service implementation.
const client = new [1](address, grpc.credentials.createInsecure());The client stub class is generated with the service name followed by 'Client'. Here, UserServiceClient is correct.
Fix the error in the server handler function signature for unary gRPC call.
function getUser([1], callback) {
// handler logic
}In gRPC server handlers, the first argument is the call object containing request data and metadata.
Fill both blanks to configure a gRPC server with TLS credentials.
const server = new grpc.Server(); const creds = grpc.ServerCredentials.[1](keyCertPairs, [2]); server.bindAsync(address, creds, () => server.start());
To enable TLS, use createSsl with key-cert pairs and set the second argument to false to disable client certificate verification.
Fill all three blanks to implement a server streaming gRPC method handler.
function listUsers([1]) { const call = [2]; users.forEach(user => call.[3](user)); call.end(); }
The handler receives a call object for streaming. Use call.write() to send each message.