šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

grpc-host-builder

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-host-builder

Lightweight configurator for gRPC host

6.4.4
latest
Source
npm
Version published
Weekly downloads
308
24.7%
Maintainers
1
Weekly downloads
Ā 
Created
Source

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();

Keywords

gRPC

FAQs

Package last updated on 13 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts