Registry / devops / rxjs-grpc

rxjs-grpc

JSON →
library0.2.7jsnpmunverified

Typesafe gRPC client and server library using RxJS observables in TypeScript. Version 0.2.7 is the latest stable release; the library generates TypeScript interfaces from protobuf definitions and allows implementing gRPC services that return RxJS Observables. It supports both client and server code generation. Requires rxjs (^6.0.0 || ^7.0.0) and the grpc package as peer dependencies. Key differentiator: strongly-typed gRPC with reactive patterns via RxJS, unlike the callback/promise-based @grpc/grpc-js.

npm install rxjs-grpc
INSTALL
IMPORT
SIG · RXJS-GRPC
R
rxjs-grpc
devopsjavascriptv0.2.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.

serverBuilder
import { serverBuilder } from 'rxjs-grpc'
const { serverBuilder } = require('rxjs-grpc')
CommonJS require works but TypeScript ESM import is preferred.
clientFactory
import { clientFactory } from 'rxjs-grpc'
import { clientFactory } from 'rxjs-grpc/src'
Do not import from subpaths; the module exports at the top level.
GrpcClient (or similar)
import { clientFactory } from 'rxjs-grpc'
No named export GrpcClient; use clientFactory and then instantiate the client class.
ServerBuilder type
import { serverBuilder } from 'rxjs-grpc'
Types are not exported separately; use typeof serverBuilder or infer from the generated namespace.

Complete example of generating TypeScript interfaces, implementing a gRPC server with Observable responses, and calling the service from a client.

// Create a protobuf file 'greeter.proto': // syntax = "proto3"; // package greeter; // service Greeter { rpc SayHello (HelloRequest) returns (HelloReply) {} } // message HelloRequest { string name = 1; } // message HelloReply { string message = 1; } // Generate TypeScript interfaces: // npx rxjs-grpc -o grpc-namespaces.ts greeter.proto // Implementation (server): import { of } from 'rxjs'; import { serverBuilder } from 'rxjs-grpc'; import { greeter } from './grpc-namespaces'; const server = serverBuilder<greeter.ServerBuilder>('greeter.proto', 'greeter'); server.addGreeter({ sayHello(request: greeter.HelloRequest) { return of({ message: 'Hello ' + request.name }); } }); server.start('0.0.0.0:50051'); // Client: import { clientFactory } from 'rxjs-grpc'; import { greeter } from './grpc-namespaces'; const Services = clientFactory<greeter.ClientFactory>('greeter.proto', 'greeter'); const services = new Services('localhost:50051'); const greeterClient = services.getGreeter(); greeterClient.sayHello({ name: 'world' }).forEach(response => { console.log(`Greeting: ${response.message}`); });
Debug
Known issues
gotchaThe generated namespace name must match the proto package; otherwise TypeScript generics fail.
fix
Ensure the proto file has a 'package' statement and pass that exact name as second argument to serverBuilder/clientFactory.
affects: >=0.0.0
deprecatedThe underlying 'grpc' package is deprecated; consider using '@grpc/grpc-js'. However, rxjs-grpc does not support '@grpc/grpc-js'.
fix
Stay on grpc package; monitor rxjs-grpc for future updates to support @grpc/grpc-js.
affects: >=0.0.0
gotchaThe code generator rxjs-grpc is a CLI tool invoked via npx or ./node_modules/.bin/rxjs-grpc; it is not a programmatic API.
fix
Use CLI as shown; do not attempt to import code generation functions.
affects: >=0.0.0
gotchaServer methods must return Observables (or Promises); returning raw objects causes TypeScript errors.
fix
Wrap return values in rxjs.of() or from().
affects: >=0.0.0
breakingIn version 0.2.x, the generated interfaces changed; the namespace structure may differ from 0.1.x.
fix
Regenerate TypeScript interfaces with the new CLI after upgrading.
affects: >=0.2.0 <0.3.0
Errors
Common errors & fixes
Error: Cannot find module 'typescript'
TypeScript is not installed or not in node_modules.
fix
Install TypeScript: npm install --save-dev typescript
TypeError: serverBuilder is not a function
Wrong import: using default import instead of named import.
fix
Use import { serverBuilder } from 'rxjs-grpc'
error TS2345: Argument of type '{ sayHello: (request: any) => { message: string; }; }' is not assignable to parameter of type 'Greeter'
Server method returns a plain object instead of Observable.
fix
Wrap the return value: sayHello(request) { return of({ message: 'Hello' }); }
Error: 14 UNAVAILABLE: Name resolution failed for target localhost:50051
gRPC server not running or wrong address.
fix
Start the server first; ensure address format is 'host:port' (e.g., '0.0.0.0:50051').
Upgrade
Version history
0.2.7latest on npm
Audit
Dependencies
rxjsrequiredRequired peer dependency for Observable types and operators.
grpcrequiredRequired peer dependency for gRPC functionality.
Agent activity
6 hits · last 30 days
node
6
Resources
rxjs-grpc — npm install rxjs-grpc · libregistry