forked from fastify/session
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore.js
More file actions
31 lines (24 loc) · 710 Bytes
/
Copy pathstore.js
File metadata and controls
31 lines (24 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict'
const EventEmitter = require('events').EventEmitter
const util = require('util')
function Store (storeMap = new Map()) {
this.store = storeMap
EventEmitter.call(this)
}
util.inherits(Store, EventEmitter)
Store.prototype.set = function set (sessionId, session, callback) {
this.store.set(sessionId, session)
callback()
}
Store.prototype.get = function get (sessionId, callback) {
const session = this.store.get(sessionId)
callback(null, session)
}
Store.prototype.destroy = function destroy (sessionId, callback) {
this.store.delete(sessionId)
callback()
}
module.exports = Store
module.exports.default = Store
module.exports.Store = Store
module.exports.MemoryStore = Store