You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
521 B
JavaScript

5 years ago
"use strict";
const bhttp = require("bhttp");
const nanoid = require("nanoid");
module.exports = function createSessionManager() {
let map = new Map();
return {
createSession: function (options) {
let id = nanoid();
let session = bhttp.session(options);
map.set(id, session);
return id;
},
getSession: function (id) {
let session = map.get(id);
if (session == null) {
throw new Error("No such session exists; this should never happen");
} else {
return session;
}
}
};
};