Registry / devops / grpc-helper

grpc-helper

JSON →
library0.5.1jsnpmunverified

gRPC helper is an improved gRPC client for grpc-node, providing promised unary and client stream calls, client load balancing, service health checking, service discovery (static, DNS SRV), circuit breaker based on Brakes, retry based on async-retry, and Prometheus metrics via prom-client. Version 0.5.1 targets Node >=4, ships TypeScript types, and is released under MIT. It differentiates from raw grpc-node by offering higher-level abstractions, load balancing, and integrated resilience patterns.

npm install grpc-helper
INSTALL
IMPORT
SIG · GRPC-HELPER
G
grpc-helper
devopsjavascriptv0.5.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.

GRPCHelper
import { GRPCHelper } from 'grpc-helper'
const GRPCHelper = require('grpc-helper')
ESM named import. Use CommonJS with destructuring: const { GRPCHelper } = require('grpc-helper')
default import
import GRPCHelper from 'grpc-helper'
const GRPCHelper = require('grpc-helper').default
Default export is not available; use named import only.
GRPCHelperOptions
import { GRPCHelperOptions } from 'grpc-helper'
type GRPCHelperOptions = import('grpc-helper').GRPCHelperOptions
TypeScript type available as named export.

Creates a gRPC helper client with static service discovery, waits for connection, and makes a unary call.

import { GRPCHelper } from 'grpc-helper'; import path from 'path'; const helper = new GRPCHelper({ packageName: 'helloworld', serviceName: 'Greeter', protoPath: path.resolve(__dirname, './hello.proto'), sdUri: 'static://localhost:50051', }); async function main() { await helper.waitForReady(); const res = await helper.SayHello({ name: 'World' }); console.log(res); } main().catch(console.error);
Debug
Known issues
gotchaRequires grpc package as peer dependency; must be installed separately.
fix
Install grpc: npm install grpc
affects: >=0.0
gotchaService discovery URI format is strict; invalid URIs will cause runtime errors.
fix
Use correct format like 'static://host1:port1,host2:port2' or 'dns://_grpc._tcp.service?intervalMs=5000'
affects: >=0.0
gotchawaitForReady() must be called before making any RPC calls, otherwise calls may fail.
fix
Always await helper.waitForReady() before invoking methods.
affects: >=0.0
deprecatedNode.js >=4 engine is outdated; consider using Node >=10.
fix
Upgrade Node.js to LTS version.
affects: >=0.0
Errors
Common errors & fixes
TypeError: GRPCHelper is not a constructor
Default import instead of named import.
fix
Use: import { GRPCHelper } from 'grpc-helper'
Error: Cannot find module 'grpc'
Missing peer dependency grpc.
fix
Run: npm install grpc
Error: ENOENT: no such file or directory, open '...'
Proto path is incorrect.
fix
Use absolute path with path.resolve(__dirname, 'relative/path/to/proto')
Error: Invalid service discovery URI
sdUri format is malformed.
fix
Provide URI like 'static://host:port' or 'dns://...'
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies
grpcrequiredCore gRPC library for Node.js
brakesrequiredCircuit breaker implementation
async-retryrequiredRetry logic
prom-clientoptionalPrometheus metrics client
Agent activity
8 hits · last 30 days
node
8
Resources
grpc-helper — npm install grpc-helper · libregistry