A TypeScript library providing pre-call and post-call middleware for gRPC Node.js servers. Currently at version 1.0.11, it has zero external dependencies but requires the 'grpc' package as a peer dependency. It supports adding middleware functions that run before and after gRPC calls, and includes built-in support for Jaeger tracing header propagation. Unlike manual interception, it allows adding middleware without modifying service implementations.
npm install grpc-ts-middlewareNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a gRPC server with pre- and post-call middleware that logs calls before and after handling the echo RPC.
Always call new GrpcMiddleware(server, preHandlers, postHandlers) and then grpcMiddleware.addService(service, implementations).
Install grpc (the legacy gRPC library) alongside grpc-ts-middleware. For @grpc/grpc-js, this library does not support it.
Use pre-call handlers for logging/validation only; use post-call handlers to inspect errors or modify response metadata.
Implement custom pre/post handlers for other tracing formats.
Use 'import GrpcMiddleware from 'grpc-ts-middleware';' (without braces).
Run 'npm install grpc --save'.
Ensure the first argument to new GrpcMiddleware is a valid grpc.Server instance.