mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-03 15:39:09 +00:00
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
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.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,
|
|
],
|
|
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,
|
|
};
|
|
}
|