Registry / devops / loopback-connector-grpc

loopback-connector-grpc

JSON →
library2.0.0jsnpmunverified

LoopBack connector for gRPC services, enabling LoopBack applications to interact with gRPC APIs. Current version 2.0.0 requires Node >=10.16. This connector loads gRPC specification files (protobuf) and creates dynamic LoopBack models for gRPC service operations. Compared to REST connectors, it leverages gRPC's performance and streaming capabilities. The connector is maintained by the LoopBack team at StrongLoop/IBM. Note: This is a specialized connector for LoopBack 3.x; not intended for standalone use. Release cadence is low; no major updates since 2020.

npm install loopback-connector-grpc
INSTALL
IMPORT
SIG · LOOPBACK-CONNECTOR
L
loopback-connector-grpc
devopsjavascriptv2.0.0
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.

loopback
import loopback from 'loopback';
const loopback = require('loopback');
LoopBack uses CommonJS, but ESM syntax works with transpilation. This lib is for LoopBack 3.x.
createDataSource
loopback.createDataSource('grpc', { connector: 'grpc', spec: 'service.proto' });
loopback.createDataSource({ connector: 'grpc', spec: 'service.proto' });
First argument is datasource name (string), second is options object.
ds.once
ds.once('connected', function() { /* create models */ });
ds.on('connected', function() { ... });
Use 'once' to avoid repeated connections. 'connected' event is emitted only once.

Creates a gRPC data source from a .proto file, waits for connection, then invokes a remote procedure call.

const loopback = require('loopback'); const ds = loopback.createDataSource('grpc', { connector: 'grpc', spec: 'path/to/service.proto', }); ds.once('connected', () => { const MyService = ds.createModel('MyService', {}); MyService.myRpcMethod({ arg1: 'value' }, (err, res) => { if (err) console.error(err); else console.log(res); }); });
Debug
Known issues
gotchaData source is not ready until 'connected' event fires; models must be created inside the event handler.
fix
Always use ds.once('connected', ...) to create models or call operations.
affects: >=1.0
deprecatedLoopBack 3.x is deprecated and no longer actively maintained. This connector does not work with LoopBack 4.
fix
Consider migrating to LoopBack 4 and using @loopback/grpc or a direct gRPC client.
affects: >=0.0
gotchaspec property must be a path to a .proto file, not a .yaml/.json file (documentation incorrectly lists .yaml/.json).
fix
Provide the path to a valid .proto file. For OpenAPI specs, use loopback-connector-rest.
affects: >=0.0
gotchaSecurity certificates (rootCerts, key, cert) must be file paths, not raw certificate content.
fix
Provide file system paths to the certificate files.
affects: >=0.0
Errors
Common errors & fixes
Error: Cannot read property 'prototype' of undefined
Attempting to create or use models before the data source is connected.
fix
Wrap model creation inside ds.once('connected', function() { ... });
Unhandled rejection TypeError: grpc.load is not a function
Incompatible version of @grpc/proto-loader or grpc package. The connector expects an older API.
fix
Install grpc@1.24.x or use @grpc/proto-loader@0.5.x. Check peer dependencies.
Error: ENOENT: no such file or directory, open 'service.proto'
The spec file path is incorrect or relative to the wrong directory.
fix
Ensure spec path is relative to process.cwd() or use an absolute path.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
loopback-datasource-jugglerrequiredProvides LoopBack model and data source infrastructure
Agent activity
21 hits · last 30 days
node
20
Resources
loopback-connector-grpc — npm install loopback-connector-grpc · libregistry