
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
simple-grpc-connector
Advanced tools
Simple gRPC Connector is a JavaScript library that provides an easy-to-use interface for integrating gRPC functionality into your applications. It simplifies the process of creating gRPC clients and servers, making it effortless to publish functions as gR
Simple gRPC Connector is a JavaScript library that provides an easy-to-use interface for integrating gRPC functionality into your applications. It simplifies the process of creating gRPC clients and servers, making it effortless to publish functions as gRPC services and invoke them over gRPC. The Simple gRPC Connector library leverages the powerful capabilities of the @grpc/grpc-js module, which is a modern, pure JavaScript gRPC implementation. By utilizing @grpc/grpc-js, the library ensures compatibility with the latest versions of Node.js and offers improved performance and reliability for your gRPC-based applications.
import {GRPCConnector} from "simple-grpc-connector"
const service = {
add: (a, b) => a + b,
greet: (name) => `Hello, ${name}!`,
}
// Create a new gRPC connector
const connector = new GRPCConnector({ host: 'localhost', port: 50051 })
// Publish the service functions
connector.publish(service)
import {GRPCConnector} from "simple-grpc-connector"
const connector = new GRPCConnector({ host: 'localhost', port: 50051 });
// Call a published function
connector
.call('greet', [2, 3])
.then((result) => {
console.log('Result:', result); // Output: 5
})
.catch((error) => {
console.error('Error:', error);
});
import {GRPCConnector} from "simple-grpc-connector"
// Create a GRPCConnector instance with host and port
const connector = new GRPCConnector({ host: 'localhost', port: 50051 })
// Define the function
function sayHello(name) {
return `Hello, ${name}!`
}
// Publish the function
connector.publish(sayHello)
console.log('Server started')
import {GRPCConnector} from "simple-grpc-connector"
// Create a GRPCConnector instance with host and port
const connector = new GRPCConnector({ host: 'localhost', port: 50051 })
// Call the function
const name = 'John';
connector.call('', [name])
.then((result) => {
console.log('Response:', result)
})
.catch((error) => {
console.error('Error:', error)
})
import {GRPCConnector} from "simple-grpc-connector"
// Create a GRPCConnector instance with host and port
const connector = new GRPCConnector({ host: 'localhost', port: 50051 })
// Define the object
const myObj = {
name: `John Doe`,
place: `Utopia`
}
// Publish the object
connector.publish(myObj)
console.log('Server started')
import {GRPCConnector} from "simple-grpc-connector"
// Create a GRPCConnector instance with host and port
const connector = new GRPCConnector({ host: 'localhost', port: 50051 })
// Access the object
connector.call('', [])
.then((result) => {
console.log('Response:', result)
})
.catch((error) => {
console.error('Error:', error)
})
The Simple gRPC Connector library provides seamless support for SSL/TLS encryption, enabling secure communication between gRPC services and clients.
The following example demonstrates how you can configure and use SSL options with the Simple gRPC Connector to establish secure connections between your gRPC services and clients.
import { GRPCConnector, GRPCConnectorOptions } from 'simple-grpc-connector';
// Create SSL options
const sslOptions = {
host: 'localhost',
port: 50051,
useSSL: true,
SSLOptions: {
rootCert: '/path/to/rootCert.pem',
privateKey: '/path/to/privateKey.pem',
certChain: '/path/to/certChain.pem'
}
};
// Create connector options with SSL options
const connectorOptions = new GRPCConnectorOptions({ ...sslOptions });
In the above example, SSL options are provided as part of the GRPCConnectorOptions when initializing the connector. The SSL options include the paths to the root certificate (rootCert.pem), private key (privateKey.pem), and certificate chain (certChain.pem). By setting useSSL to true, the connector will use SSL/TLS for secure communication.
Make sure to replace the file paths (/path/to/rootCert.pem, /path/to/privateKey.pem, /path/to/certChain.pem) with the actual paths to your SSL/TLS files.
The Simple gRPC Connector library fully supports the use of asynchronous functions, allowing you to leverage the power of asynchronous programming in your gRPC service implementation. This means you can define and publish asynchronous functions as gRPC service methods, enabling efficient and non-blocking communication with remote clients.
By utilizing async functions, you can handle time-consuming or I/O-bound operations without blocking the execution flow, resulting in better performance and responsiveness. The library seamlessly integrates with async/await syntax and supports the use of Promises, enabling you to write clean and concise asynchronous code.
Whether you need to perform complex computations, access databases, or make API calls, you can leverage the asynchronous capabilities of the Simple gRPC Connector to build efficient and scalable gRPC services.
With async function support, you can embrace modern JavaScript's asynchronous programming paradigm and unlock the full potential of your gRPC service implementation.
Please note that the Simple gRPC Connector has certain limitations when it comes to publishing complex data types such as functions or classes. Currently, the library only supports publishing plain JavaScript objects as gRPC services. Complex data types like functions, classes, or instances cannot be directly published using the connector.
If you require more advanced functionality or need to publish complex data types, you may need to consider alternative approaches or libraries that support such use cases.
We are actively working on adding comprehensive unit tests to ensure the reliability and stability of the Simple gRPC Connector library. Unit tests help us identify and fix any issues or bugs, as well as ensure that the library functions as expected.
At the moment, the unit tests are still in progress. We are dedicated to delivering a thoroughly tested library to provide you with a seamless experience. We appreciate your patience and understanding as we continue to work on this aspect.
Once the unit tests are completed, you will be able to run them to verify the functionality of the library in your own environment. Stay tuned for updates on the availability of unit tests.
In the meantime, if you encounter any issues or have any questions, please don't hesitate to reach out to us. We are here to assist you and address any concerns you may have.
That's it! With the Simple gRPC Connector, you can easily publish objects as gRPC services and access them remotely from gRPC clients.
Feel free to modify and extend the examples to suit your specific use case. Refer to the library documentation for more details on advanced usage and additional features provided by the Simple gRPC Connector.
For detailed usage instructions, API reference, and examples, please refer to the Documentation
Contributions are welcome! Please read the Contributing Guidelines for more information
This project is licensed under the MIT License.
FAQs
Simple gRPC Connector is a JavaScript library that provides an easy-to-use interface for integrating gRPC functionality into your applications. It simplifies the process of creating gRPC clients and servers, making it effortless to publish functions as gR
We found that simple-grpc-connector 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.