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

grpc-client-promise-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-client-promise-wrapper

Wrap the function of the grpc client, don't use callback anymore

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

grpc-client-promise-wrapper

Documentation

Use async/await for @grpc/grpc-js package

Installation

$ npm install grpc-client-promise-wrapper

Javascript

const promiseWrapper = require('grpc-client-promise-wrapper');

Typescript

import * as promiseWrapper from 'grpc-client-promise-wrapper';

Example

  • test.proto
syntax = "proto3";

package test;

service TestService {
  rpc GetTestFn (inputParam) returns (returnValue);
}

message InputParam {
  string inputParam = 1;
}

message ReturnValue {
  string returnValue = 1;
}
  • app.js
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const promiseWrapper = require('grpc-client-promise-wrapper');

const testStub = () => {
  const packageDefinition = protoLoader.loadSync(path.join(__dirname, './test.proto'));
  const testService = grpc.loadPackageDefinition(packageDefinition).test;
  return promiseWrapper(new testService.TestService('localhost:3001', grpc.credentials.createInsecure()));
};

const getTestFn = async (params) => {
  return testStub().getTestFn(params);
};

License

MIT License

Keywords

FAQs

Package last updated on 19 Dec 2022

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