Socket
Socket
Sign inDemoInstall

grpc-host-builder

Package Overview
Dependencies
42
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    grpc-host-builder

Lightweight configurator for gRPC host


Version published
Weekly downloads
19
increased by280%
Maintainers
1
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 13 Mar 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc