UNPKG

dynamodb-store

Version:

Implementation of a session storage using DynamoDB as an extension of the express-session middleware.

1 lines 571 B
'use strict';exports.__esModule=true;exports.toSecondsEpoch=toSecondsEpoch;exports.debug=debug;exports.isExpired=isExpired;function toSecondsEpoch(date){if(!(date instanceof Date)){throw new Error(`${date} is not a Date!`)}return Math.floor(date.getTime()/1000)}function debug(message,object){if(process.env.DYNAMODB_STORE_DEBUG){const argument=object||'';console.log(`${new Date().toString()} - DYNAMODB_STORE: ${message}`,typeof argument==='object'?JSON.stringify(argument):argument)}}function isExpired(expiresOn){return!expiresOn||expiresOn<=toSecondsEpoch(new Date)}