mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-08 17:54:49 +00:00
37 lines
960 B
TypeScript
37 lines
960 B
TypeScript
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?.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,
|
|
};
|
|
}
|