diff --git a/packages/microservices/client/client-kafka.ts b/packages/microservices/client/client-kafka.ts index ba9ad099a33..fc3869af416 100644 --- a/packages/microservices/client/client-kafka.ts +++ b/packages/microservices/client/client-kafka.ts @@ -57,14 +57,22 @@ export class ClientKafka extends ClientProxy { constructor(protected readonly options: KafkaOptions['options']) { super(); - const clientOptions = - this.getOptionsProp(this.options, 'client') || ({} as KafkaConfig); - const consumerOptions = - this.getOptionsProp(this.options, 'consumer') || ({} as ConsumerConfig); - const postfixId = - this.getOptionsProp(this.options, 'postfixId') ?? '-client'; - this.producerOnlyMode = - this.getOptionsProp(this.options, 'producerOnlyMode') || false; + const clientOptions = this.getOptionsProp( + this.options, + 'client', + {} as KafkaConfig, + ); + const consumerOptions = this.getOptionsProp( + this.options, + 'consumer', + {} as ConsumerConfig, + ); + const postfixId = this.getOptionsProp(this.options, 'postfixId', '-client'); + this.producerOnlyMode = this.getOptionsProp( + this.options, + 'producerOnlyMode', + false, + ); this.brokers = clientOptions.brokers || [KAFKA_DEFAULT_BROKER]; diff --git a/packages/microservices/client/client-proxy.ts b/packages/microservices/client/client-proxy.ts index bdd3484d7d4..3950cf3dbf2 100644 --- a/packages/microservices/client/client-proxy.ts +++ b/packages/microservices/client/client-proxy.ts @@ -130,7 +130,7 @@ export abstract class ClientProxy { T extends ClientOptions['options'], K extends keyof T, >(obj: T, prop: K, defaultValue: T[K] = undefined) { - return (obj && obj[prop]) || defaultValue; + return obj && prop in obj ? obj[prop] : defaultValue; } protected normalizePattern(pattern: MsPattern): string {