Socket
Book a DemoInstallSign in
Socket

grpc-client-egg

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-client-egg

An egg grpc client.

0.1.3
latest
npmnpm
Version published
Weekly downloads
12
Maintainers
1
Weekly downloads
 
Created
Source

grpc-client-egg

npm version

An egg grpc client written in Typescript.

How to use

1 install

npm i -S grpc-client-egg

2 include

import { EggPlugin } from 'egg'

const plugin: EggPlugin = {

    routerPlus: {
        enable: true,
        package: 'egg-router-plus',
    },
    grpcClient: {
        enable: true,
        package: 'grpc-client-egg',
    },
}
export default plugin

3 config

import { EggAppConfig, PowerPartial } from 'egg'

export default () => {
    const config: PowerPartial<EggAppConfig> = {

        grpcClient: {
            clients: [
                {
                    name: 'main',
                    protoPath: 'app/proto/main',
                    host: '0.0.0.0',
                    port: 50051,
                },
            ],
        },
    }
    return config
}

4 invoke promisified grpc service methods

import { Service } from 'egg'

export default class Greeter extends Service {

    readonly service: GreeterService = this.app.grpcClient.main.greeter.Greeter

    public async sayHello(name: string) {
        return this.service.sayHello({ name })
    }

    public async sayGoodbye(name: string) {
        return this.service.sayGoodbye({ name })
    }
}

Default config from the plugin

    loaderOption: {
        keepCase: true,
        longs: String,
        enums: String,
        defaults: true,
        oneofs: true,
    },

    clients: [
        {
            name: 'main',
            protoPath: 'app/proto/main',
            host: '0.0.0.0',
            port: 50051,
        },
    ],

FAQs

Package last updated on 28 Apr 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.