import { Input } from '@dadosfera/protospack-v2'; import { credentials } from '@grpc/grpc-js'; import { ClientProviderOptions, Transport, type GrpcOptions, } from '@nestjs/microservices'; const isLocalConnection = process.env.INFACTORY_URL.startsWith('in-factory:') || process.env.INFACTORY_URL.includes('0.0.0.0'); export class InputsGrpcClient { public readonly name = 'InputsGrpcClient'; private config: GrpcOptions = { transport: Transport.GRPC, options: { url: process.env.INFACTORY_URL, package: [ Input.ProtoPackages.WritePackage, Input.ProtoPackages.ReadPackage, ], credentials: isLocalConnection ? undefined : credentials.createSsl(), protoPath: [ Input.ProtoPaths.WriteFilePath, Input.ProtoPaths.ReadFilePath, ], loader: { keepCase: true, enums: String, defaults: false, }, }, }; providerOptions: ClientProviderOptions = { name: this.name, ...this.config, }; }