Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(microservices): allow falsy values in options #10549

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions packages/microservices/client/client-kafka.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
2 changes: 1 addition & 1 deletion packages/microservices/client/client-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down