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.
createGrpcServer
✓ import { createGrpcServer } from 'testapi6-grpc'
Primary export for starting a gRPC server
GrpcClient
✓ import { GrpcClient } from 'testapi6-grpc'
✗ const GrpcClient = require('testapi6-grpc').GrpcClient
CommonJS may still work but ESM is preferred
default
✓ import testapi6Grpc from 'testapi6-grpc'
✗ import { default } from 'testapi6-grpc'
Default import accesses the entire module object, not recommended
Shows how to create a gRPC server and client using testapi6-grpc with proto loading and insecure connection.
import { createGrpcServer, GrpcClient } from 'testapi6-grpc';
import { loadPackageDefinition } from '@grpc/grpc-js';
import { loadSync } from '@grpc/proto-loader';
// Start a gRPC server
const server = createGrpcServer();
const protoPath = './path/to/service.proto';
const packageDefinition = loadSync(protoPath, {});
const proto = loadPackageDefinition(packageDefinition);
server.addService(proto.myService.service, {
myMethod: (call, callback) => {
callback(null, { message: 'Hello from testapi6-grpc' });
},
});
server.bindAsync('0.0.0.0:50051', server.ServerCredentials.createInsecure(), (err, port) => {
if (err) throw err;
console.log(`Server listening on port ${port}`);
server.start();
});
// Create a client
const client = new GrpcClient('localhost:50051', proto.myService, { channelOptions: {} });
client.myMethod({ name: 'World' }, (err, response) => {
if (err) throw err;
console.log(response.message);
});
Errors
Common errors & fixes
Error: Cannot find module 'testapi6'
Missing peer dependency testapi6.
fixRun 'npm install testapi6@^1.2.51'
TypeError: server.addService is not a function
The createGrpcServer returns a different object than expected, or proto definition is incorrect.
fixVerify that proto.loadPackageDefinition returns an object with service constructors.
Error: 14 UNAVAILABLE: No connection established
gRPC server not started or wrong address.
fixEnsure server is running on the expected host:port and client connects to it.
DeprecationWarning: channelOptions is deprecated
Using deprecated parameter in GrpcClient constructor.
fixRemove channelOptions or use new options API: remove the wrapper.
Audit
Dependencies
testapi6requiredPeer dependency; required core library for gRPC server/client integration