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

grpc-web-service-generator

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-web-service-generator

gRPC-Web Service Generator

  • 0.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

gRPC-Web Service Generator

Wrapper service over base grpc-web.

Installation

$ yarn add grpc-web-service-generator

For server-side

$ yarn grpc-web-service-generator --proto-file=./proto/rpc.proto --output-dir=./proto --skip-grpc-service

For client-side

$ yarn grpc-web-service-generator --proto-file=./proto/rpc.proto --output-dir=./services/GrpcService

Parameters

  • --proto-file - path to main proto.
  • --output-dir - dir path for generated code.
  • --skip-grpc-service - disabling generation GrpcService (special for server-side)

Usage (client-side)

// rpc.proto

syntax = "proto3";

package RpcPackage;

service TodoService {
  rpc AddTodo() returns () {}
}

Version <= 0.1.6

import { GrpcService } from './GrpcService';

const grpcService = new GrpcService('http://localhost:8080');

grpcService.TodoService.AddTodo({}).then(response => ...)

Version >= 0.1.7 (Support for multiple packages)

import { GrpcService } from './GrpcService';

const grpcService = new GrpcService('http://localhost:8080');

grpcService.RpcPackage.TodoService.AddTodo({}).then(response => ...)

Interceptors

const updateGrpcServiceAccessToken = async () => {
  storedAccessToken = await grpcService.AuthService.GetAccessToken();
  console.log('updateGrpcServiceAccessToken', storedAccessToken);
  grpcService.setAccessToken(storedAccessToken);
};

grpcService.interceptors.errors.push((e) => {
  if (e === 'INVALID_TOKEN') {
    return updateGrpcServiceAccessToken();
  } else {
    return Promise.resolve();
  }
});

Keywords

FAQs

Package last updated on 10 Apr 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