Registry / devops / tl-ngrpc

tl-ngrpc

JSON →
library1.0.1jsnpmunverified

tl-ngrpc is a minimal Node.js gRPC helper library that simplifies gRPC server and client setup. Version 1.0.1 wraps the grpc package to provide an event-driven server pattern and a promise-based client, supporting both HTTP and socket services. It focuses on protocol conventions rather than business logic, allowing developers to define protobuf services and attach handlers easily. The library is designed for rapid prototyping and small to medium gRPC services, offering a simpler API than grpc-js or @grpc/proto-loader. Release cadence: single stable release.

npm install tl-ngrpc
INSTALL
IMPORT
SIG · TL-NGRPC
T
tl-ngrpc
devopsjavascriptv1.0.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.

TlApiRpcServer
const TlApiRpcServer = require('tl-ngrpc/server/TlApiRpcServer');
import { TlApiRpcServer } from 'tl-ngrpc'
This library uses CommonJS; ESM imports may not work without a bundler.
TlApiRpcClient
const TlApiRpcClient = require('tl-ngrpc/client/api/TlApiRpcClient');
import TlApiRpcClient from 'tl-ngrpc'
Default export is not available; use named require.
gRPC types (proto)
const teacherApiRpcClient = new TlApiRpcClient({...});
const client = new TlApiRpcClient({ protoPath: 'teacher.proto' });
The protoPath must be absolute, not relative; use path.resolve().

Demonstrates how to create a TlApiRpcServer with event handlers and a TlApiRpcClient to make gRPC calls using the library's event-based API.

const TlApiRpcServer = require('tl-ngrpc/server/TlApiRpcServer'); const TlApiRpcClient = require('tl-ngrpc/client/api/TlApiRpcClient'); const path = require('path'); // Server setup const server = new TlApiRpcServer({ protoPath: path.resolve(__dirname, './teacher.proto'), protoName: 'teacher', protoPackage: 'api', protoImpl: 'Teacher', ip: '127.0.0.1', port: 50051 }); server.on('hello', (call, callback) => { callback(null, { message: 'Hello ' + call.request.message }); }); server.start(); // Client setup (run separately) const client = new TlApiRpcClient({ protoPath: path.resolve(__dirname, './teacher.proto'), protoName: 'teacher', protoPackage: 'api', protoImpl: 'Teacher', ip: '127.0.0.1', port: 50051 }); client.emit('hello', { message: 'world' }).then(res => { console.log(res.message); // 'Hello world' });
Debug
Known issues
gotchaprotoPath must be an absolute path. Relative paths will cause file not found errors.
fix
Use path.resolve(__dirname, 'relative/proto/file.proto') to get absolute path.
affects: 1.0.1
gotchaInstallation requires compiling native gRPC module, which may fail on some systems without build tools.
fix
Ensure you have Python, make, and a C++ compiler installed. Alternatively, use grpc-tools or prebuilt binaries.
affects: >=1.0.0
gotchaThe library uses an older 'grpc' package, not the modern '@grpc/grpc-js'. This may cause compatibility issues in newer Node.js versions (<14).
fix
Consider migrating to @grpc/grpc-js for pure-JS, cross-platform compatibility.
affects: 1.0.1
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open 'teacher.proto'
protoPath is relative; the library expects an absolute path.
fix
Use path.resolve(__dirname, './teacher.proto') instead of just './teacher.proto'.
Error: Cannot find module 'tl-ngrpc'
Importing package incorrectly; this library is not on npm registry under that exact name.
fix
Install from GitHub: npm install git+https://github.com/tl-open-source/tl-ngrpc.git
Error: The 'grpc' package is no longer maintained. Please use '@grpc/grpc-js' instead.
Using the deprecated 'grpc' package. tl-ngrpc depends on it.
fix
Consider using '@grpc/grpc-js' and a different helper library, or accept the deprecation warning.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
grpcrequiredCore gRPC functionality for Node.js
@grpc/proto-loaderrequiredLoading .proto files
Agent activity
6 hits · last 30 days
node
6
Resources
tl-ngrpc — npm install tl-ngrpc · libregistry