summaryrefslogtreecommitdiff
path: root/source/session.js
diff options
context:
space:
mode:
Diffstat (limited to 'source/session.js')
-rw-r--r--source/session.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/session.js b/source/session.js
new file mode 100644
index 0000000..5846271
--- /dev/null
+++ b/source/session.js
@@ -0,0 +1,21 @@
+const sessions = new Map()
+
+class Session {
+ constructor() {}
+
+ Create() {
+ const object = {
+ result: '',
+ characters: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
+ }
+
+ for (let i = 0; i < object.characters.length; i++) object.result += object.characters.charAt(Math.floor(Math.random() * object.characters.length))
+ sessions.set(object.result, Date.now() + (1000 * 60 * 60))
+ return object.result
+ }
+ Exists(x) {return sessions.has(x)}
+ Expired() {sessions.forEach((value, key) => {if (Date.now() > value) sessions.delete(key)})}
+}
+
+module.exports = () => {return new Session()}
+