import { Controller, Get, OnModuleInit } from '@nestjs/common'; import { AppService } from './app.service'; // import { UtilsModule } from '@app/utils'; import { grpcClientOptions } from './grpc-scene.options'; import { ClientGrpc, Client } from '@nestjs/microservices'; import { Observable } from 'rxjs'; interface Point { x: string; y: string; z: string; } interface routeParam { sLocation: Point; eLocation: Point; sceneCode: string; } interface SceneGrpcService { getRoute(params: routeParam): Observable; testMethod(data: { id: string; name: string }): Observable; } @Controller() export class AppController implements OnModuleInit { @Client(grpcClientOptions) private readonly client: ClientGrpc; private sceneGrpcService: SceneGrpcService; constructor(private readonly appService: AppService) { } onModuleInit() { console.log('this.client', this.client); this.sceneGrpcService = this.client.getService('SceneGrpcService'); } @Get() getHello(): string { // console.log('UtilsModule', UtilsModule); const params: routeParam = { sLocation: { x: '6.0', y: '0.0', z: '-4.0', }, eLocation: { x: '4.0', y: '0.0', z: '-3.0', }, sceneCode: 'Hello', }; console.log('params', params); const test = this.sceneGrpcService.getRoute(params); test.subscribe((val) => { console.log('val', val); }); return this.appService.getHello(); } }