@nestcfork/grpc
TypeScript icon, indicating that this package has built-in type declarations

0.7.5 • Public • Published

NestCloud - Grpc

NPM Version Package License NPM Downloads Travis Linux Coverage

Description

The loadbalance grpc module for nestcloud.

Installation

$ npm install --save @nestcfork/grpc

Usage

import { Controller, Get } from '@nestjs/common';
import { GrpcClient, LbClient, IClientConfig, Service } from '@nestcfork/grpc';
import { HeroService } from './interfaces/hero-service.interface';
import { join } from 'path';

const grpcOptions: IClientConfig = {
    service: 'rpc-server',
    package: 'hero',
    protoPath: join(__dirname, './hero.proto'),
};

@Controller()
export class HeroController {
    @LbClient(grpcOptions)
    private readonly client: GrpcClient;
    @Service('HeroService', grpcOptions)
    private readonly heroService: HeroService;

    @Get()
    async execute(): Promise<any> {
        return await this.heroService.get({ id: 1 }).toPromise();
    }
}

More please visit the example: https://github.com/nest-cloud/nestcloud-grpc-example

Stay in touch

License

NestCloud is MIT licensed.

Readme

Keywords

none

Package Sidebar

Install

npm i @nestcfork/grpc

Weekly Downloads

1

Version

0.7.5

License

MIT

Unpacked Size

20.7 kB

Total Files

29

Last publish

Collaborators

  • kurbar