New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@connectrpc/connect-node

Package Overview
Dependencies
Maintainers
6
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@connectrpc/connect-node

Connect is a family of libraries for building and consuming APIs on different languages and platforms, and [@connectrpc/connect](https://www.npmjs.com/package/@connectrpc/connect) brings type-safe APIs with Protobuf to TypeScript.

  • 1.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
decreased by-76.18%
Maintainers
6
Weekly downloads
 
Created

What is @connectrpc/connect-node?

@connectrpc/connect-node is a package designed to facilitate the implementation of RPC (Remote Procedure Call) systems using the Connect protocol in Node.js applications. It provides tools for building both clients and servers that can communicate over HTTP/2, HTTP/1.1, and WebSockets, making it versatile for various network environments.

What are @connectrpc/connect-node's main functionalities?

Creating a Connect RPC Client

This feature allows you to create a Connect RPC client that can communicate with a Connect RPC server. The code sample demonstrates how to initialize a client with a base URL and a service definition, and then make a call to a method on that service.

const { createConnectClient } = require('@connectrpc/connect-node');
const client = createConnectClient({
  baseUrl: 'https://example.com',
  service: MyService,
});
const response = await client.myMethod({ myParameter: 'value' });

Setting up a Connect RPC Server

This feature enables you to set up a Connect RPC server that listens for incoming RPC calls. The code sample shows how to create a server with a list of services and start it on a specified port.

const { createConnectServer } = require('@connectrpc/connect-node');
const server = createConnectServer({
  services: [MyService],
  port: 8080,
});
server.start();

Handling Streaming RPCs

This feature supports streaming RPCs, allowing for bidirectional data flow between client and server. The code sample illustrates how to define a streaming method within a service, processing incoming items and yielding results back to the client.

const { createConnectServer } = require('@connectrpc/connect-node');
const server = createConnectServer({
  services: [
    {
      name: 'MyStreamingService',
      methods: {
        myStreamingMethod: async function* (request) {
          for (const item of request.items) {
            yield { result: processItem(item) };
          }
        }
      }
    }
  ],
  port: 8080,
});
server.start();

Other packages similar to @connectrpc/connect-node

FAQs

Package last updated on 10 Oct 2024

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