grpc-ts-middleware
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -50,3 +50,3 @@ import * as grpc from 'grpc'; | ||
* @param preCallHandler An array of functions to be invoked prior to the execution of the gRPC call | ||
* @param postCallHandler An array of functions to be invoked after the actual service handler, but before returning the result | ||
* @param postCallHandler An array of functions to be invoked after the gRPC call has been executed, but before returning the result | ||
*/ | ||
@@ -53,0 +53,0 @@ constructor(server: grpc.Server, preMiddleware?: PreMiddleware, postMiddleware?: PostMiddleware); |
{ | ||
"name": "grpc-ts-middleware", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "gRPC pre-call and post-call middleware", | ||
@@ -32,3 +32,3 @@ "main": "src/index.js", | ||
"@types/node": "~10.12.18", | ||
"@types/protobufjs": "^6.0.0", | ||
"@types/protobufjs": "~6.0.0", | ||
"prettier": "~1.15.3", | ||
@@ -35,0 +35,0 @@ "protobufjs": "~6.8.8", |
# gRPC Middleware | ||
A library that allows easy implementation of gRPC middleware, for both pre-call, and post-call. | ||
[![Current Version](https://img.shields.io/npm/v/grpc-ts-middleware.svg)](https://www.npmjs.com/package/grpc-ts-middleware) | ||
A library that assists with the implementation of gRPC pre-, and post-call middleware. | ||
### Installation | ||
@@ -24,4 +26,2 @@ | ||
const serviceName = 'echo.EchoManager'; | ||
function doEcho(call: grpc.ServerUnaryCall<EchoRequest>, callback: grpc.sendUnaryData<EchoReply>) { | ||
@@ -39,16 +39,19 @@ const reply = new EchoReply(); | ||
const grpcMiddleware = new GrpcMiddleware( | ||
// An instance of the gRPC server | ||
server, | ||
// An array of functions to be invoked prior to the execution of the gRPC call | ||
[ | ||
(call: GrpcCall) => AppLogger.logger.debug('Pre-call handler 1', call), | ||
(call: GrpcCall) => AppLogger.logger.debug('Pre-call handler 2', call) | ||
(call: GrpcCall) => console.log('Pre-call handler 1', call), | ||
(call: GrpcCall) => console.log('Pre-call handler 2', call) | ||
], | ||
// An array of functions to be invoked after the gRPC call has been executed, but before returning the result | ||
[ | ||
(error: grpc.ServiceError | null, call: GrpcCall) => | ||
AppLogger.logger.debug('Post-call handler 1', call, error), | ||
console.log('Post-call handler 1', call, error), | ||
(error: grpc.ServiceError | null, call: GrpcCall) => | ||
AppLogger.logger.debug('Post-call handler 2', call, error) | ||
console.log('Post-call handler 2', call, error) | ||
] | ||
); | ||
// Add gRPC services that you want the middleware to monitor | ||
grpcMiddleware.addService(EchoManagerService, { echo: this.doEcho }); | ||
grpcMiddleware.addService(EchoManagerService, { echo: doEcho }); | ||
// Enable propagation of Jaeger tracing headers | ||
@@ -55,0 +58,0 @@ grpcMiddleware.enableTracing(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9593
67