import { INestApplication } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { MicroserviceOptions, Transport } from '@nestjs/microservices' import { PROTO_PATHS } from '@teacinema/contracts' export function setupGrpc(app: INestApplication, config: ConfigService) { const host = config.getOrThrow('GRPC_HOST') const port = config.getOrThrow('GRPC_PORT') const url = `${host}:${port}` app.connectMicroservice({ transport: Transport.GRPC, options: { url, package: ['movie.v1', 'category.v1'], protoPath: [PROTO_PATHS.MOVIE, PROTO_PATHS.CATEGORY], loader: { keepCase: false, longs: String, enums: String, defaults: true, oneofs: true } } }) }