koa-session-dynamodb-store
Version:
The DynamoDB extension store for koa-session.
1 lines • 571 B
JavaScript
;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)}