Skip to content

Creates a service from a given gRPC server, allowing you to configure interceptors for its methods.

Notifications You must be signed in to change notification settings

markotom/grpc-service-interceptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gRPC Service Interceptor

Creates a service from a given gRPC server, allowing you to configure interceptors for its methods.

Installation

$ npm install grpc-service-interceptor --save

Usage

const GrpcServiceInterceptor = require('grpc-service-interceptor');

const service = new GrpcServiceInterceptor({
  grpcServer,
  grpcServiceDefinition,
});

const firstInterceptor = async (ctx, next) => {
  // ctx.call, ctx.callback
  next();
};

const secondInterceptor = async (ctx, next) => {
  next();
};

const firstHandler = async (ctx) => {
  // handle response
};

const secondHandler = async (ctx) => {
  // handle response
};

service.addMethod('methodName', firstInterceptor, secondInterceptor, firstHandler);
service.addMethod('anotherMethodName', firstInterceptor, secondInterceptor, secondHandler);

service.configure();

About

Creates a service from a given gRPC server, allowing you to configure interceptors for its methods.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published