Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@connectrpc/connect

Package Overview
Dependencies
Maintainers
7
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@connectrpc/connect

Type-safe APIs with Protobuf and TypeScript.

  • 1.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
104K
decreased by-41.36%
Maintainers
7
Weekly downloads
 
Created

What is @connectrpc/connect?

@connectrpc/connect is an npm package designed to facilitate the creation and management of RPC (Remote Procedure Call) connections. It provides tools for defining, implementing, and consuming RPC services, making it easier to build distributed systems and microservices.

What are @connectrpc/connect's main functionalities?

Defining RPC Services

This feature allows you to define RPC services with specific methods. In this example, a service named 'MyService' is created with a method 'sayHello' that takes a 'HelloRequest' and returns a 'HelloResponse'.

const { Service } = require('@connectrpc/connect');

const myService = new Service({
  name: 'MyService',
  methods: {
    sayHello: {
      requestType: 'HelloRequest',
      responseType: 'HelloResponse',
      handler: (request) => {
        return { message: `Hello, ${request.name}!` };
      }
    }
  }
});

Implementing RPC Clients

This feature allows you to implement RPC clients that can communicate with the defined services. In this example, a client is created to connect to 'MyService' and call the 'sayHello' method.

const { Client } = require('@connectrpc/connect');

const client = new Client({
  service: myService,
  address: 'http://localhost:5000'
});

client.sayHello({ name: 'World' }).then(response => {
  console.log(response.message); // Output: Hello, World!
});

Handling RPC Requests

This feature allows you to handle incoming RPC requests by starting a server. In this example, a server is created to handle requests for 'MyService' on port 5000.

const { Server } = require('@connectrpc/connect');

const server = new Server({
  services: [myService],
  port: 5000
});

server.start().then(() => {
  console.log('Server is running on port 5000');
});

Other packages similar to @connectrpc/connect

FAQs

Package last updated on 27 Oct 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc