Registry / communication / simple-grpc-connector

simple-grpc-connector

JSON →
library1.0.7jsnpmunverified

Simple gRPC Connector v1.0.7 is a lightweight JavaScript library that wraps @grpc/grpc-js to allow publishing arbitrary JavaScript functions, objects, and services as gRPC endpoints with minimal configuration. It provides automatic serialization/deserialization, optional SSL/TLS, and a promise-based client for calling remote functions by name. Unlike full-featured gRPC frameworks (e.g., NestJS, gRPC-Web), this library prioritizes zero-boilerplate integration for small-to-medium services. It is maintained on GitHub and follows an ad-hoc release cadence.

npm install simple-grpc-connector
INSTALL
IMPORT
SIG · SIMPLE-GRPC-CONNEC
S
simple-grpc-connector
communicationjavascriptv1.0.7
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.

GRPCConnector
import { GRPCConnector } from 'simple-grpc-connector'
import GRPCConnector from 'simple-grpc-connector'
Only named export is available; default import is not supported.
GRPCConnector (CommonJS)
const { GRPCConnector } = require('simple-grpc-connector')
const GRPCConnector = require('simple-grpc-connector')
CommonJS destructured require is needed; package uses named exports.
GRPCConnector class
new GRPCConnector({ host: 'localhost', port: 50051 })
new GRPCConnector('localhost', 50051)
Constructor expects a configuration object with host and port keys.

Demonstrates creating a server that publishes a service object with two functions, then creating a client that calls the add function remotely.

import { GRPCConnector } from 'simple-grpc-connector'; // Server: publish a service object const server = new GRPCConnector({ host: 'localhost', port: 50051 }); const service = { add: (a, b) => a + b, greet: (name) => `Hello, ${name}!`, }; server.publish(service); console.log('gRPC server running on localhost:50051'); // Client: call a remote function const client = new GRPCConnector({ host: 'localhost', port: 50051 }); client .call('add', [2, 3]) .then((result) => console.log('Result:', result)) .catch(console.error);
Debug
Known issues
gotchaWhen publishing a single function via connector.publish(myFunc), the function name becomes the service method name but calling with call('', args) uses an empty string because the service is anonymous.
fix
Always publish an object with named keys (e.g., { myFunc }) or use call('functionName') for named methods.
affects: >=1.0.0
gotchaThe library relies on @grpc/grpc-js which does not support protobuf schema validation; serialization is JSON-based, not protobuf.
fix
Ensure all arguments and return values are JSON-serializable. Complex types (e.g., Dates) may be serialized unexpectedly.
affects: >=1.0.0
deprecatedThe call() method uses positional arguments array; there is no named parameter support.
fix
Always pass arguments as an array, even for a single parameter: call('fn', [arg])
affects: >=1.0.0
gotchaSSL/TLS is optional but if enabled, both server and client must provide appropriate certificates; otherwise connections will fail silently.
fix
Refer to @grpc/grpc-js documentation for SSL setup and pass credentials via the GRPCConnector constructor options.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'call')
GRPCConnector not properly initialized or host/port not provided.
fix
Ensure you create a new instance: const connector = new GRPCConnector({ host: 'localhost', port: 50051 });
Error: 14 UNAVAILABLE: No connection established
The client cannot reach the server because it is not running or host/port is incorrect.
fix
Start the server first, and verify the client uses the same host and port as the server.
Error: function_name is not a function
Calling a function that was not published or the method name does not exist in the published service object.
fix
Check the service object keys and verify the exact name used in call(). Ensure the server has published the service.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredCore gRPC implementation used for server/client communication
Agent activity
13 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
simple-grpc-connector — npm install simple-grpc-connector · libregistry