mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-27 12:34:47 +00:00
39 lines
911 B
TypeScript
39 lines
911 B
TypeScript
import { credentials } from '@grpc/grpc-js';
|
|
import {
|
|
ClientsProviderAsyncOptions,
|
|
GrpcOptions,
|
|
Transport,
|
|
} from '@nestjs/microservices';
|
|
import {
|
|
ProtoPackages,
|
|
ProtoPaths,
|
|
} from '@dadosfera/protospack-v2/dist/lib/Duc';
|
|
|
|
export class DucClient {
|
|
public name = 'DucClient';
|
|
|
|
private config: GrpcOptions = {
|
|
transport: Transport.GRPC,
|
|
options: {
|
|
url: process.env.DUC_URL,
|
|
package: [ProtoPackages.WritePackage, ProtoPackages.ReadPackage],
|
|
credentials:
|
|
process.env.LOCAL_ENV || process.env.ENV === 'local'
|
|
? undefined
|
|
: credentials.createSsl(),
|
|
protoPath: [ProtoPaths.WriteFilePath, ProtoPaths.ReadFilePath],
|
|
loader: {
|
|
keepCase: true,
|
|
enums: String,
|
|
objects: true,
|
|
arrays: true,
|
|
},
|
|
},
|
|
};
|
|
|
|
providerOptions: ClientsProviderAsyncOptions = {
|
|
name: this.name,
|
|
...this.config,
|
|
};
|
|
}
|