1.0.2 • Published 6 months ago

nestjs-grpc-server v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

compatible options of Nestjs ServerGrpc

support add service generate by protobuf-ts

NestServerGrpc transport use Transport.Grpc

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  app.connectMicroservice<MicroserviceOptions>({
    strategy: new NestServerGrpc({
      protoPath: [],
      package: [],
      serviceDefinitions: [
        {
          name: "GreetService",
          service: greetServiceDefinition,
        }
      ]
    })
  });

  await app.startAllMicroservices();

  await app.listen(3000);
}
bootstrap();
  @GrpcMethod("GreetService", "Hello")
  async hello(req: GreetRequest, metadata: any): Promise<GreetResponse>{

    return {
      from: "bill",
      reply: `hello ${req.to}`
    }
  }
syntax = "proto3";

package greet.v1;

service GreetService {
  rpc Hello(GreetRequest) returns (GreetResponse) {}
}

message GreetRequest {
  string to = 1;
  string content = 2;
}

message GreetResponse {
  string from = 1;
  string reply = 2;
}
1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago