From 146ea1a9a015539f63f922ac883e1202a2a89861 Mon Sep 17 00:00:00 2001 From: rasim andiran Date: Thu, 6 Jun 2024 12:12:28 +0300 Subject: [PATCH 1/2] [fix] AdapterOptions: (#2) null check for opts values --- lib/index.ts | 8 ++++---- package-lock.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/index.ts b/lib/index.ts index 1e1e83e..06d54b2 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -52,24 +52,24 @@ async function createQueue( sqsClient: SQS, opts: AdapterOptions ) { - const topicName = opts.topicName || "socket-io"; + const topicName = opts?.topicName || "socket-io"; debug("creating topic [%s]", topicName); const createTopicCommandOutput = await snsClient.createTopic({ Name: topicName, - Tags: opts.topicTags, + Tags: opts?.topicTags, }); debug("topic [%s] was successfully created", topicName); - const queueName = `${opts.queuePrefix || "socket-io"}-${randomId()}`; + const queueName = `${opts?.queuePrefix || "socket-io"}-${randomId()}`; debug("creating queue [%s]", queueName); const createQueueCommandOutput = await sqsClient.createQueue({ QueueName: queueName, - tags: opts.queueTags, + tags: opts?.queueTags, }); debug("queue [%s] was successfully created", queueName); diff --git a/package-lock.json b/package-lock.json index 2ef9591..c5c54d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@socket.io/aws-sqs-adapter", - "version": "0.0.1", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@socket.io/aws-sqs-adapter", - "version": "0.0.1", + "version": "0.1.0", "license": "MIT", "dependencies": { "@aws-sdk/client-sns": "^3.535.0", From 52ee093e88a3c2a23abafccaef3d14fb8e8c8b03 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Mon, 10 Jun 2024 19:33:30 +0200 Subject: [PATCH 2/2] cleanup --- lib/index.ts | 10 +++++----- package-lock.json | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/index.ts b/lib/index.ts index 06d54b2..9488c47 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -52,24 +52,24 @@ async function createQueue( sqsClient: SQS, opts: AdapterOptions ) { - const topicName = opts?.topicName || "socket-io"; + const topicName = opts.topicName || "socket-io"; debug("creating topic [%s]", topicName); const createTopicCommandOutput = await snsClient.createTopic({ Name: topicName, - Tags: opts?.topicTags, + Tags: opts.topicTags, }); debug("topic [%s] was successfully created", topicName); - const queueName = `${opts?.queuePrefix || "socket-io"}-${randomId()}`; + const queueName = `${opts.queuePrefix || "socket-io"}-${randomId()}`; debug("creating queue [%s]", queueName); const createQueueCommandOutput = await sqsClient.createQueue({ QueueName: queueName, - tags: opts?.queueTags, + tags: opts.queueTags, }); debug("queue [%s] was successfully created", queueName); @@ -140,7 +140,7 @@ async function createQueue( export function createAdapter( snsClient: SNS, sqsClient: SQS, - opts: AdapterOptions & ClusterAdapterOptions + opts: AdapterOptions & ClusterAdapterOptions = {} ) { let isClosed = false; let _topicArn: string; diff --git a/package-lock.json b/package-lock.json index c5c54d4..2ef9591 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@socket.io/aws-sqs-adapter", - "version": "0.1.0", + "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@socket.io/aws-sqs-adapter", - "version": "0.1.0", + "version": "0.0.1", "license": "MIT", "dependencies": { "@aws-sdk/client-sns": "^3.535.0",