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