mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-14 23:29:08 +00:00
38 lines
989 B
TypeScript
38 lines
989 B
TypeScript
import {
|
|
ClientsProviderAsyncOptions,
|
|
GrpcOptions,
|
|
Transport,
|
|
} from '@nestjs/microservices';
|
|
import { credentials } from '@grpc/grpc-js';
|
|
import { Catalog } from '@dadosfera/protospack-v2';
|
|
|
|
const isLocalConnection = !!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,
|
|
],
|
|
credentials: isLocalConnection ? undefined : credentials.createSsl(),
|
|
protoPath: [
|
|
Catalog.ProtoPaths.ReadFilePath,
|
|
Catalog.ProtoPaths.WriteFilePath,
|
|
],
|
|
loader: {
|
|
keepCase: true,
|
|
enums: String,
|
|
defaults: false,
|
|
},
|
|
},
|
|
};
|
|
providerOptions: ClientsProviderAsyncOptions = {
|
|
name: this.name,
|
|
...this.config,
|
|
};
|
|
}
|