23 lines
648 B
TypeScript
23 lines
648 B
TypeScript
import { Inject, Injectable, OnModuleInit } from '@nestjs/common'
|
|
import type { ClientGrpc } from '@nestjs/microservices'
|
|
import {
|
|
AccountServiceClient,
|
|
GetAccountRequest
|
|
} from '@teacinema/contracts/gen/ts/account'
|
|
|
|
@Injectable()
|
|
export class AccountClientGrpc implements OnModuleInit {
|
|
private accountService: AccountServiceClient
|
|
|
|
constructor(@Inject('ACCOUNT_PACKAGE') private readonly client: ClientGrpc) {}
|
|
|
|
onModuleInit() {
|
|
this.accountService =
|
|
this.client.getService<AccountServiceClient>('AccountService')
|
|
}
|
|
|
|
public getAccount(request: GetAccountRequest) {
|
|
return this.accountService.getAccount(request)
|
|
}
|
|
}
|