Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
node-grpc-client
Advanced tools
Readme
Simple gRPC client on NodeJS v1.5.0
Send metadata
is supported.
Now are supported packages which have dots or style of inverse DNS like: com.github.nodegrpcclient
.
runService('TaskName', dataToSend, callback, options);
listMethods();
The dynamic methods are the methods of the GRPC, then, its depends of your definition on your proto file.
task1Async(data, callback, options);
.await task2Sync(data, options);
.task3Stream(data, options).on('data', callback);
syntax = "proto3";
package packageservice;
message ExampleRequest {
string id = 1;
string text = 2;
}
message ExampleResponse {
int32 send = 1;
string message = 2;
}
service Theservice {
rpc Task1 (ExampleRequest) returns (ExampleResponse);
rpc Task2 (ExampleRequest) returns (ExampleResponse);
}
Where
const GRPCClient = require('node-grpc-client');
const myClient = new GRPCClient(<protoPath>, <packageName>, <serviceName>, <url>);
const path = require('path');
const PROTO_PATH = path.resolve(__dirname, '../example.proto');
const GRPCClient = require('node-grpc-client');
const myClient = new GRPCClient(PROTO_PATH, 'packageservice', 'Theservice', 'localhost:3000');
const dataToSend = {
id: 'abc123',
text: 'Hello world'
};
// options is optional and is supported from version 1.5.0
const options = {
metadata: {
hello: 'world'
}
};
myClient.runService('Task1', dataToSend, (err, res) => {
console.log('Service response ', res);
}, options);
const path = require('path');
const PROTO_PATH = path.resolve(__dirname, '../example.proto');
const GRPCClient = require('node-grpc-client');
const myClient = new GRPCClient(PROTO_PATH, 'packageservice', 'Theservice', 'localhost:3000');
const dataToSend = {
id: 'abc123',
text: 'Hello world'
};
// options is optional and is supported from version 1.5.0
const options = {
metadata: {
hello: 'world'
}
};
myClient.task1Async(dataToSend, (err, res) => {
console.log('Service response ', res);
}, options);
const path = require('path');
const PROTO_PATH = path.resolve(__dirname, '../example.proto');
const GRPCClient = require('node-grpc-client');
const myClient = new GRPCClient(PROTO_PATH, 'packageservice', 'Theservice', 'localhost:3000');
const dataToSend = {
id: 'abc123',
text: 'Hello world'
};
// options is optional and is supported from version 1.5.0
const options = {
metadata: {
hello: 'world'
}
};
(async function () {
const response1 = await myClient.task1Sync(dataToSend, options);
console.log('The answer of request 1: ', response1);
const response2 = await myClient.task2Sync(dataToSend);
console.log('The answer of request 2: ', response2);
})();
Some gRPC methods return a stream. This allows subscription-based push communication between the server and the client, where the server can push data to the client.
You can use the dynamic stream method for this. For example, if the server has a gRPC method Task3 that returns a stream:
// options is optional and is supported from version 1.5.0
const options = {
metadata: {
hello: 'world'
}
};
const stream = myClient.task3Stream(dataToSend, options);
stream.on('data', (data) => console.log(data));
Options is a feature added in version 1.5.0.
{}
;metadata is a property added to options in version 1.5.0.
const options = {
metadata: {
myheader: 'testing metadata', //string
myheader2: '2', // string
'myheader-bin': myBuffer // buffer
}
}
FAQs
Simple gRPC client on NodeJS
The npm package node-grpc-client receives a total of 815 weekly downloads. As such, node-grpc-client popularity was classified as not popular.
We found that node-grpc-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.