6.4.4 • Published 1 year ago

grpc-host-builder v6.4.4

Weekly downloads
3
License
MIT
Repository
github
Last release
1 year ago

grpc-host-builder

npm version npm downloads

Lightweight configurator for gRPC host

Install

npm i grpc-host-builder

Usage

const { GrpcHostBuilder } = require("grpc-host-builder");

/*...*/

class InterceptorForTom {
  constructor(serverContext) {
    this._logger = serverContext.createLogger();
  }

  async invoke(call, methodDefinition, next) {
    /*...*/

    if (call.request.name === "Tom") return { message: "Hello again, Tom!" };
    return await next(call);
  }
}

/*...*/

const server = await new GrpcHostBuilder()
  .useLoggersFactory(loggersFactory)
  .addInterceptor(InterceptorForTom)
  .addInterceptor(async (call, methodDefinition, next) => {
    if (call.request.name === "Jane") return { message: "Hello dear, Jane!" };
    return await next(call);
  })
  .addService(packageObject.v1.Greeter.service, {
    sayHello: (call) => {
      const request = new HelloRequest(call.request);
      return new HelloResponse({ message: `Hello, ${request.name}!` });
    },
  })
  .bind(grpcBind)
  .buildAsync();
6.4.4

1 year ago

5.4.3

2 years ago

5.3.3

3 years ago

5.3.2

3 years ago

4.3.2

4 years ago

4.2.2

4 years ago

3.2.2

4 years ago

3.1.2

5 years ago

3.1.1

5 years ago

2.1.1

5 years ago

1.1.1

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago