nestjs-grpc-server
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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;
}

Readme

Keywords

none

Package Sidebar

Install

npm i nestjs-grpc-server

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

208 kB

Total Files

9

Last publish

Collaborators

  • acuper