You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

grpc-mocky

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-mocky

This is a mock of grpc used for javascript development.

0.1.31
latest
Source
npmnpm
Version published
Weekly downloads
59
2850%
Maintainers
1
Weekly downloads
 
Created
Source

Welcome to grpc-mocky 😀

GitHub Actions status

Introduction

  • This is a mock of grpc used for javascript development
  • Can have multiple entry points
  • Supports the following methods
    • unary
    • serverStreming
    • clientStreming
    • duplexStreming

Install

npm i -D grpc-mocky

Cli

gen-grpc-tamplate

  • Output mock json template
node ./node_module/.bin/gen-grpc-template {path}
ParameterDescription
pathSet the directory where the proto file or proto file is located
  • option
optionDescription
-iimport another path
  • e.g.
syntax = "proto3";
package helloworld;

service Greeter {
  rpc unary (UnaryRequest) returns (UnaryResponse) {}
  rpc serverStreaming (UnaryRequest) returns (stream UnaryResponse) {}
  rpc clientStreaming (stream UnaryRequest) returns (UnaryResponse) {}
  rpc duplexStreaming (stream UnaryRequest) returns (stream UnaryResponse) {}
}

message UnaryRequest {
  string name = 1;
}

message UnaryResponse {
  string message = 1;
}

generate...

{
  "protos": [
    {
      "path": "example/protos/helloWorld.proto",
      "pkg": "helloworld",
      "options": {},
      "services": [
        {
          "name": "Greeter",
          "methods": [
            { "name": "unary", "output": {} },
            { "name": "serverStreaming", "output": {} },
            { "name": "clientStreaming", "output": {} },
            { "name": "duplexStreaming", "output": {} }
          ]
        }
      ]
    }
  ]
}

Interface

run

ParameterTypeDescription
addressstringSet the address of the mock server to be started. default 0.0.0.0
portstringSet the port of the mock server to be started. default 50051
protosArray<proto>Required. Set proto and mock data to be loaded into mock server.
e.g. https://github.com/activeguild/grpc-mocky/blob/master/example/service.json
https://github.com/activeguild/grpc-mocky#user-content-proto

proto

ParameterTypeDescription
pathstringRequired. Set location of proto file.
pkgstringRequired. Set pkgName from ptoro file.
optionsstringhttps://github.com/grpc/grpc-node/tree/master/packages/proto-loader
servicesArray<service>Required. https://github.com/activeguild/grpc-mocky#user-content-service

service

ParameterTypeDescription
namestringRequired. Set service name from ptoro file.
methodsArray<method>Required. https://github.com/activeguild/grpc-mocky#user-content-method

method

ParameterTypeDescription
namestringRequired. Set method name from ptoro file.
outputObject | Array<object>Set response from server.
streamIntervalnumberSet the sense of server streaming.Unit is msec. default 1000
errorObjectSet grpc error.
https://cloud.google.com/apis/design/errors#error_model

e.g.

https://github.com/activeguild/grpc-mocky/tree/master/example

License

Keywords

grpc

FAQs

Package last updated on 12 Jul 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