diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/connect-dynamodb.iml b/.idea/connect-dynamodb.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/connect-dynamodb.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..02cb0d4 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..e6fda34 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + 1621926527903 + + + + + + \ No newline at end of file diff --git a/lib/connect-dynamodb.js b/lib/connect-dynamodb.js index 04189e9..665fe2c 100644 --- a/lib/connect-dynamodb.js +++ b/lib/connect-dynamodb.js @@ -65,28 +65,32 @@ module.exports = function (connect) { this._reap = setInterval(this.reap.bind(this), this.reapInterval); } - // check if sessions table exists, otherwise create it - this.client.describeTable({ - TableName: this.table - }, function (error, info) { - if (error) { - this.client.createTable({ - TableName: this.table, - AttributeDefinitions: [{ - AttributeName: this.hashKey, - AttributeType: 'S' - }], - KeySchema: [{ - AttributeName: this.hashKey, - KeyType: 'HASH' - }], - ProvisionedThroughput: { - ReadCapacityUnits: this.readCapacityUnits, - WriteCapacityUnits: this.writeCapacityUnits - } - }, console.log); - } - }.bind(this)); + const { autoCreateTable = true } = options + + // If autoCreateTable option is true, check if sessions table exists, otherwise create it + if (autoCreateTable) { + this.client.describeTable({ + TableName: this.table + }, function (error, info) { + if (error) { + this.client.createTable({ + TableName: this.table, + AttributeDefinitions: [{ + AttributeName: this.hashKey, + AttributeType: 'S' + }], + KeySchema: [{ + AttributeName: this.hashKey, + KeyType: 'HASH' + }], + ProvisionedThroughput: { + ReadCapacityUnits: this.readCapacityUnits, + WriteCapacityUnits: this.writeCapacityUnits + } + }, console.log); + } + }.bind(this)); + } }; /*