Install @grpc/grpc-js and @grpc/proto-loader. Define service methods in a .proto file. Bootstrap the microservice with Transport.GRPC pointing to the proto file. Decorate handler methods with @GrpcMethod('ServiceName', 'MethodName') where the names must exactly match the proto service and rpc definitions.
package in options must match the package statement in the .proto file.
@GrpcMethod('ServiceName', 'MethodName') — both names must exactly match the proto definitions.
The proto file path must resolve correctly at runtime — use __dirname and join() for portability.
Client uses getService<ServiceClient>('ServiceName') to get a typed client proxy for calling remote methods.
Share the .proto file between services via a shared npm package or a git submodule for consistency.
Walk me through the steps you'd take to add a gRPC server to a new NestJS microservice.
If you have a .proto file defining a UserService, how would you generate and use the client in a NestJS module?
What happens if the proto file and the generated TypeScript definitions get out of sync? How would you notice and fix it?
We tried to call a gRPC method from another NestJS service and got a deadline exceeded error. What could be causing this, and how would you troubleshoot?
Explain how you would configure NestJS to support both gRPC and HTTP transports for the same service, and why you might want to.
When adding versioning to your gRPC APIs, what changes are needed in the NestJS setup and the proto definitions?
Describe how you would implement server‑side streaming for a large data export in NestJS using gRPC, and what performance considerations you’d keep in mind.
How would you secure gRPC communication between NestJS microservices in a production environment?
If you need to add request/response logging and error handling across all gRPC calls, where would you place interceptors in NestJS, and what trade‑offs exist?
Our platform currently uses REST for inter‑service communication, but we want to migrate to gRPC for performance. How would you plan the migration across multiple NestJS teams while minimizing disruption?
Discuss the pros and cons of using a service mesh (e.g., Istio) with NestJS gRPC microservices versus handling load balancing and retries in the application layer.
How would you design a versioning strategy for gRPC APIs that need to evolve over years, ensuring backward compatibility and smooth rollout across many services?