sipp
Version:
An Opinionated, High-Productivity MVC Web Framework in TypeScript
38 lines • 993 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Session = void 0;
class Session {
constructor(req) {
this.req = req;
this.session = req.session;
}
has(key) {
return this.session.hasOwnProperty(key);
}
get(key, defaultValue = undefined) {
return this.session[key] || defaultValue;
}
set(key, value) {
this.session[key] = value;
}
flash(key, msg) {
return this.req.flash(key, msg);
}
getFlash(key) {
return this.req.flash(key);
}
reflash(key) {
const value = this.getFlash(key);
value.length && value.forEach((msg) => this.flash(key, msg));
return value;
}
async destroy() {
return new Promise((resolve, reject) => {
this.req.session.destroy((err) => {
err ? reject(err) : resolve();
});
});
}
}
exports.Session = Session;
//# sourceMappingURL=Session.js.map