Skip to content

Commit

Permalink
refactor: scoped env key is empty strign rather than null
Browse files Browse the repository at this point in the history
  • Loading branch information
FPierre committed Jul 3, 2023
1 parent 5699070 commit 9b0c15e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
19 changes: 4 additions & 15 deletions lib/gc-pubsub.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,20 @@ export class GCPubSubClient extends ClientProxy {

this.clientConfig = this.options.client || GC_PUBSUB_DEFAULT_CLIENT_CONFIG;

this.scopedEnvKey = this.options.scopedEnvKey ?? null;
this.scopedEnvKey = this.options.scopedEnvKey ?? '';

this.topicName = this.options.topic || GC_PUBSUB_DEFAULT_TOPIC;

if (this.scopedEnvKey) {
this.topicName = `${this.scopedEnvKey}${this.topicName}`;
}
this.topicName = `${this.scopedEnvKey}${this.topicName}`;

this.subscriberConfig =
this.options.subscriber || GC_PUBSUB_DEFAULT_SUBSCRIBER_CONFIG;

this.publisherConfig =
this.options.publisher || GC_PUBSUB_DEFAULT_PUBLISHER_CONFIG;

this.replyTopicName = this.options.replyTopic;

if (this.scopedEnvKey) {
this.replyTopicName = `${this.scopedEnvKey}${this.replyTopicName}`;
}

this.replySubscriptionName = this.options.replySubscription;
this.replyTopicName = `${this.scopedEnvKey}${this.options.replyTopic}`;

if (this.scopedEnvKey) {
this.replySubscriptionName = `${this.scopedEnvKey}${this.replySubscriptionName}`;
}
this.replySubscriptionName = `${this.scopedEnvKey}${this.options.replySubscription}`;

this.noAck = this.options.noAck ?? GC_PUBSUB_DEFAULT_NO_ACK;
this.init = this.options.init ?? GC_PUBSUB_DEFAULT_INIT;
Expand Down
16 changes: 5 additions & 11 deletions lib/gc-pubsub.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,15 @@ export class GCPubSubServer extends Server implements CustomTransportStrategy {
super();

this.clientConfig = this.options.client || GC_PUBSUB_DEFAULT_CLIENT_CONFIG;
this.scopedEnvKey = this.options.scopedEnvKey ?? null;
this.topicName = this.options.topic || GC_PUBSUB_DEFAULT_TOPIC;
this.scopedEnvKey = this.options.scopedEnvKey ?? '';

if (this.scopedEnvKey) {
this.topicName = `${this.scopedEnvKey}${this.topicName}`;
}
this.topicName = this.options.topic || GC_PUBSUB_DEFAULT_TOPIC;
this.topicName = `${this.scopedEnvKey}${this.topicName}`;

this.subscriptionName =
this.options.subscription || GC_PUBSUB_DEFAULT_SUBSCRIPTION;

if (this.scopedEnvKey) {
this.subscriptionName = `${this.scopedEnvKey}${this.subscriptionName}`;
}
this.subscriptionName = `${this.scopedEnvKey}${this.subscriptionName}`;

this.subscriberConfig =
this.options.subscriber || GC_PUBSUB_DEFAULT_SUBSCRIBER_CONFIG;
Expand Down Expand Up @@ -214,9 +210,7 @@ export class GCPubSubServer extends Server implements CustomTransportStrategy {
message as unknown as OutgoingResponse,
);

if (this.scopedEnvKey) {
replyTo = `${this.scopedEnvKey}${replyTo}`;
}
replyTo = `${this.scopedEnvKey}${replyTo}`;

this.replyTopics.add(replyTo);

Expand Down

0 comments on commit 9b0c15e

Please sign in to comment.