8

GitHub - iendeavor/grpc-devtools: Browser DevTools extension for debugging gRPC...

 2 years ago
source link: https://github.com/iendeavor/grpc-devtools
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

gRPC Devtools

grpc-devtools requires at least grpc-web 1.1.0, so make sure you upgrade your grpc-web if you're still running an older one.

demo.png

Usage

const gRPCDevtoolsStreamInterceptor =
  typeof __gRPC_devtools__ === "object" &&
  __gRPC_devtools__ !== null &&
  __gRPC_devtools__.gRPCDevtoolsStreamInterceptor;
const streamInterceptors = gRPCDevtoolsStreamInterceptor
  ? [gRPCDevtoolsStreamInterceptor]
  : [];

const gRPCDevtoolsUnaryInterceptor =
  typeof __gRPC_devtools__ === "object" &&
  __gRPC_devtools__ !== null &&
  __gRPC_devtools__.gRPCDevtoolsUnaryInterceptor;
const unaryInterceptors = gRPCDevtoolsUnaryInterceptor
  ? [gRPCDevtoolsUnaryInterceptor]
  : [];

const client = new ChatServicePromiseClient(hostname, credentials, {
  unaryInterceptors: unaryInterceptors,
  streamInterceptors: streamInterceptors,
});

TypeScript

import type { StreamInterceptor, UnaryInterceptor } from "grpc-web";

declare const __gRPC_devtools__:
  | undefined
  | {
      gRPCDevtoolsStreamInterceptor: StreamInterceptor<unknown, unknown>;
      gRPCDevtoolsUnaryInterceptor: UnaryInterceptor<unknown, unknown>;
    };

TODOs

  • Search

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK