Skip to content

Commit 9712f5d

Browse files
authored
Merge pull request #87 from jackmuskopf/master
Fix expiry based on TTL; fix error handling of `dynamodb:DescribeTable`
2 parents 21d0f33 + a7ca3dd commit 9712f5d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/connect-dynamodb.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,14 @@ module.exports = function (connect) {
9393
.then(() => {
9494
this.initialized = true;
9595
})
96-
.catch(() => {
97-
return this.createSessionsTable().then(() => {
98-
this.initialized = true;
99-
});
96+
.catch((err) => {
97+
if (err.name == 'ResourceNotFoundException') {
98+
return this.createSessionsTable().then(() => {
99+
this.initialized = true;
100+
});
101+
} else {
102+
throw err;
103+
}
100104
});
101105
};
102106

@@ -342,7 +346,7 @@ module.exports = function (connect) {
342346
const now = Math.floor(Date.now() / 1000);
343347
const expires =
344348
typeof sess.cookie.maxAge === "number"
345-
? now + sess.cookie.maxAge
349+
? now + (sess.cookie.maxAge / 1000)
346350
: now + oneDayInSeconds;
347351
return expires;
348352
};

0 commit comments

Comments
 (0)