šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

grpc-modern

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-modern

[![codecov](https://codecov.io/gh/daangn/grpc-modern/branch/main/graph/badge.svg?token=DDA5G6PWJ1)](https://codecov.io/gh/daangn/grpc-modern) ![](https://img.shields.io/npm/v/grpc-modern) ![](https://img.shields.io/bundlephobia/min/grpc-modern) ![](https:

0.5.1
latest
Source
npm
Version published
Weekly downloads
650
-13.79%
Maintainers
1
Weekly downloads
Ā 
Created
Source

gRPC Modern

codecov

Makes grpc clients(@grpc/grpc-js, grpc) fit in modern JavaScript(TypeScript) environment.

  • Change callback interface with Promise
  • Change new + set interface with object literal

Installation

$ yarn add grpc-modern

# peer dependencies
$ yarn add @grpc/grpc-js google-protobuf
$ yarn add --dev @types/google-protobuf

# or
$ yarn add grpc google-protobuf
$ yarn add --dev @types/google-protobuf

Usage

/**
 * without `grpc-modern`
 */
import * as grpc from "@grpc/grpc-js";
import { GetSomethingReq, SomethingClient } from "../stubs/something/...";

const client = new SomethingClient(
  "example.com:80",
  grpc.credentials.createInsecure()
);

const req = new GetSomethingReq();
req.setId("...");
req.setSomeOption(false);

client.getSomething(req, (error, response) => {
  console.log(response);
});

/**
 * with `grpc-modern`
 */
import { makeModernClient } from "grpc-modern";

const client = makeModernClient(SomethingClient, {
  address: "example.com:80",
  credential: grpc.credentials.createInsecure(),
});

const response = await client.getSomething(
  set(GetSomethingReq, {
    id: "...",
    someOption: false,
  })
);

/**
 * or you can use with `grpc`
 */
import * as grpc from "grpc";

const client = makeModernClient(SomethingClient, {
  address: "example.com:80",
  credential: grpc.credentials.createInsecure(),
});

const response = await client.getSomething(
  set(GetSomethingReq, {
    id: "...",
    someOption: false,
  })
);

FAQs

Package last updated on 19 Aug 2021

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