mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-26 17:24:48 +00:00
34 lines
932 B
TypeScript
34 lines
932 B
TypeScript
import { credentials } from '@grpc/grpc-js';
|
|
import {
|
|
ClientProviderOptions,
|
|
GrpcOptions,
|
|
Transport,
|
|
} from '@nestjs/microservices';
|
|
import { ConnectionTest } from '@dadosfera/protospack-v2';
|
|
|
|
const isLocalConnection =
|
|
process.env.INFACTORY_URL.startsWith('in-factory:') ||
|
|
process.env.INFACTORY_URL.includes('0.0.0.0');
|
|
|
|
export class ConnectionTestClientConfiguration {
|
|
private config: GrpcOptions = {
|
|
transport: Transport.GRPC,
|
|
options: {
|
|
url: process.env.INFACTORY_URL,
|
|
package: [ConnectionTest.ProtoPackages.ReadPackage],
|
|
credentials: isLocalConnection ? undefined : credentials.createSsl(),
|
|
protoPath: [ConnectionTest.ProtoPaths.ReadFilePath],
|
|
loader: {
|
|
keepCase: true,
|
|
enums: String,
|
|
objects: true,
|
|
arrays: true,
|
|
},
|
|
},
|
|
};
|
|
providerOptions: ClientProviderOptions = {
|
|
name: 'ConnectionTestGrpcClient',
|
|
...this.config,
|
|
};
|
|
}
|