Registry / devops / grpc-mod

grpc-mod

JSON →
library1.1.1jsnpmunverified

A gRPC client wrapper that enhances the standard grpc-js client with promise and observable support, response transformation capabilities, and built-in mods to eliminate default proto values, remove null/undefined properties, and convert int64 to number. Version 1.1.1 requires peer dependency grpc ^1.8.0. Key differentiator: allows declarative response manipulation and modern async patterns without manually wrapping callbacks. Suitable for Node.js applications using gRPC that want to avoid callback hell and sanitize responses.

npm install grpc-mod
INSTALL
IMPORT
SIG · GRPC-MOD
G
grpc-mod
devopsjavascriptv1.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GRPCModClient
import { GRPCModClient } from 'grpc-mod'
const GRPCModClient = require('grpc-mod').GRPCModClient
ESM or CJS. Default export not available.
mod
import { mod } from 'grpc-mod'
import mod from 'grpc-mod'
Named import, not default. Used to enhance existing gRPC client instances.
noDefaults
import { noDefaults } from 'grpc-mod'
import { noDefaults } from 'grpc-mod/mods'
Built-in mods are exported from the main package, not a subpath.

Shows how to create a gRPC-mod client and use promises/observables for unary and stream calls, plus enhancing an existing gRPC client.

const path = require('path'); const { credentials } = require('grpc'); const { GRPCModClient, mod } = require('grpc-mod'); // Create a new client with GRPCModClient const client = new GRPCModClient({ protoPath: path.resolve(__dirname, './test.proto'), packageName: 'test', serviceName: 'TestService', serverAddress: 'localhost:8080', credentials: credentials.createInsecure(), }); // Make a unary call that returns a Promise client.getTodo({ id: '1' }) .then(response => console.log(response)) .catch(err => console.error(err)); // Or use with a stream, returns an Observable client.getAllTodos({}) .subscribe( todo => console.log('Todo:', todo), err => console.error('Error:', err), () => console.log('Stream complete') ); // Enhance existing client with mods const grpcClient = new grpc.Client('localhost:8080', credentials.createInsecure()); mod(grpcClient, { noDefaults: true, enforceNumber: true }); grpcClient.getTodo({ id: '2' }) .then(response => console.log(response));
Debug
Known issues
gotchaPeer dependency grpc is required but not automatically installed. You must install grpc separately.
fix
Run 'npm install grpc' alongside grpc-mod.
affects: >=1.0.0
deprecatedThe grpc package is deprecated in favor of @grpc/grpc-js. grpc-mod may not be compatible with @grpc/grpc-js.
fix
Consider migrating to @grpc/grpc-js and using native promise support or a different wrapper.
affects: >=1.0.0
gotchaStream calls return observables that require rxjs to be installed if you want to use operators.
fix
Install rxjs with 'npm install rxjs' if you need to compose observables.
affects: >=1.0.0
gotchaThe mod function mutates the client object by adding promise/observable methods. This may interfere with other wrappers.
fix
Use GRPCModClient constructor for a clean wrapper, or apply mod only once.
affects: >=1.0.0
gotchaOptions noDefaults, noNilProps, enforceNumber only affect responses if set at client creation/enhancement time. They cannot be changed per call.
fix
Set desired options when instantiating or enhancing the client.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'grpc'
Missing peer dependency grpc.
fix
Install grpc: npm install grpc
TypeError: client.getTodo is not a function
The gRPC client was not properly enhanced with mod() or GRPCModClient was configured incorrectly.
fix
Ensure the proto file path, package name, and service name are correct. Use mod(client) after creating a grpc.Client.
Observable returned instead of Promise for unary call
The method signature matches a stream pattern in the proto, or the method is actually a server-stream.
fix
Verify the proto file's RPC type. Use .toPromise() on the observable if you need a promise, or subscribe.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
grpcrequiredPeer dependency: provides core gRPC functionality
Agent activity
8 hits · last 30 days
node
8
Resources
grpc-mod — npm install grpc-mod · libregistry