Registry / devops / saas-grpc-lib

saas-grpc-lib

JSON →
library1.0.5jsnpmunverified

A TypeScript library providing gRPC client/server abstractions for CDM SaaS microservices. Version 1.0.5 includes auto-generated protobuf types, service stubs, and interceptors for auth, logging, and metrics. It publishes ESM and CJS bundles, ships self-contained .d.ts declarations, and follows semantic versioning. Key differentiators: opinionated conventions for service naming, built-in retry with exponential backoff, and lightweight dependency footprint (only @grpc/grpc-js and protobufjs at runtime).

npm install saas-grpc-lib
INSTALL
IMPORT
SIG · SAAS-GRPC-LIB
S
saas-grpc-lib
devopsjavascriptv1.0.5
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.

GrpcClient
import { GrpcClient } from 'saas-grpc-lib'
const GrpcClient = require('saas-grpc-lib').GrpcClient
Default exports removed in v1.0.0. Use named import for ESM or require the default export for CJS.
GrpcServer
import { GrpcServer } from 'saas-grpc-lib'
import GrpcServer from 'saas-grpc-lib'
Only named export available. Default import returns module object.
ServiceDefinition
import type { ServiceDefinition } from 'saas-grpc-lib'
import { ServiceDefinition } from 'saas-grpc-lib'
ServiceDefinition is a type-only export. Use type import to avoid runtime overhead.
createClient
import { createClient } from 'saas-grpc-lib/client'
import { createClient } from 'saas-grpc-lib'
This helper is exported from a subpath. The main module does not re-export it.

Demonstrates creating a gRPC server and client, making a remote call, and shutting down.

import { GrpcServer, GrpcClient } from 'saas-grpc-lib'; import { resolve } from 'path'; const protoPath = resolve('./my-service.proto'); const server = new GrpcServer({ protoPath, address: '0.0.0.0:50051' }); await server.start(); const client = new GrpcClient({ protoPath, target: 'localhost:50051' }); const response = await client.call('MyService', 'MyMethod', { requestField: 'value' }); console.log(response); await server.stop();
Debug
Known issues
breakingThe GrpcClient constructor now requires 'target' instead of 'host' and 'port' as separate fields.
fix
Replace { host: 'localhost', port: 50051 } with { target: 'localhost:50051' }.
affects: >=1.0.0
deprecatedThe 'createServer' factory function has been deprecated in favor of the GrpcServer class.
fix
Use new GrpcServer({...}) instead of createServer({...}).
affects: >=0.9.0
gotchaProto paths must be absolute or relative to process.cwd(). Relative paths relative to __dirname do not work as expected.
fix
Use path.resolve(__dirname, './my.proto') to ensure absolute paths.
affects: >=1.0.0
gotchaThe library uses esModuleInterop and expects @grpc/grpc-js to be ESM-compatible. If your project is CJS-only, you may encounter import errors.
fix
Ensure your tsconfig has "esModuleInterop": true or use dynamic import().
affects: >=1.0.0
breakingIn v1.0.0, the protobuf loading method was changed from synchronous to asynchronous. The constructors now return promises.
fix
Use await when creating GrpcServer or GrpcClient instances.
affects: =1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'saas-grpc-lib'
The package is not installed or the import path is incorrect.
fix
Run 'npm install saas-grpc-lib' and ensure the import path is 'saas-grpc-lib' (not '@saas/grpc-lib').
TypeError: GrpcClient is not a constructor
Default import used when only named export exists.
fix
Use named import: import { GrpcClient } from 'saas-grpc-lib'.
Error: [PROTOBUF] Cannot resolve import "google/protobuf/empty.proto".
Proto file has unresolved imports that are not provided.
fix
Add the missing proto files to the 'includeDirs' option or install @grpc/proto-loader.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredCore gRPC runtime for client/server communication.
protobufjsrequiredRequired for loading .proto files and message encoding/decoding.
Agent activity
12 hits · last 30 days
node
12
Resources
saas-grpc-lib — npm install saas-grpc-lib · libregistry