Browse Source

v1.0.7: Server options: sessionResave, sessionSaveUnitialized, sessionMaxAge

CrazyDoctor 8 months ago
parent
commit
c56321f70e

+ 2 - 2
dist/middlewares/SessionMiddleware.js

@@ -8,11 +8,11 @@ const express_session_1 = __importDefault(require("express-session"));
 const util_1 = require("../base/util");
 const util_1 = require("../base/util");
 class SessionMiddleware extends http_1.Middleware {
 class SessionMiddleware extends http_1.Middleware {
     constructor() {
     constructor() {
-        var _a;
+        var _a, _b, _c, _d;
         super(...arguments);
         super(...arguments);
         this.order = -98;
         this.order = -98;
         this.route = null;
         this.route = null;
-        this.action = (0, express_session_1.default)({ secret: ((_a = this.context.options) === null || _a === void 0 ? void 0 : _a.sessionSecret) || util_1.Guid.new(), resave: false, saveUninitialized: false });
+        this.action = (0, express_session_1.default)({ secret: ((_a = this.context.options) === null || _a === void 0 ? void 0 : _a.sessionSecret) || util_1.Guid.new(), resave: ((_b = this.context.options) === null || _b === void 0 ? void 0 : _b.sessionResave) || false, saveUninitialized: ((_c = this.context.options) === null || _c === void 0 ? void 0 : _c.sessionSaveUninitialized) || false, cookie: { maxAge: ((_d = this.context.options) === null || _d === void 0 ? void 0 : _d.sessionMaxAge) || 3600000 } });
     }
     }
 }
 }
 exports.default = SessionMiddleware;
 exports.default = SessionMiddleware;

+ 1 - 1
dist/middlewares/SessionMiddleware.js.map

@@ -1 +1 @@
-{"version":3,"file":"SessionMiddleware.js","sourceRoot":"","sources":["../../lib/middlewares/SessionMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,uCAA0C;AAC1C,sEAAsC;AACtC,uCAAoC;AACpC,MAAM,iBAAkB,SAAQ,iBAAU;IAA1C;;;QACW,UAAK,GAAG,CAAC,EAAE,CAAC;QACZ,UAAK,GAAG,IAAI,CAAC;QACb,WAAM,GAAG,IAAA,yBAAO,EAAC,EAAE,MAAM,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,OAAO,0CAAE,aAAa,KAAI,WAAI,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC;IACpI,CAAC;CAAA;AAED,kBAAe,iBAAiB,CAAC"}
+{"version":3,"file":"SessionMiddleware.js","sourceRoot":"","sources":["../../lib/middlewares/SessionMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,uCAA0C;AAC1C,sEAAsC;AACtC,uCAAoC;AACpC,MAAM,iBAAkB,SAAQ,iBAAU;IAA1C;;;QACW,UAAK,GAAG,CAAC,EAAE,CAAC;QACZ,UAAK,GAAG,IAAI,CAAC;QACb,WAAM,GAAG,IAAA,yBAAO,EAAC,EAAE,MAAM,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,OAAO,0CAAE,aAAa,KAAI,WAAI,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,OAAO,0CAAE,aAAa,KAAI,KAAK,EAAE,iBAAiB,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,OAAO,0CAAE,wBAAwB,KAAI,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,OAAO,0CAAE,aAAa,KAAI,OAAO,EAAE,EAAE,CAAC,CAAC;IACjS,CAAC;CAAA;AAED,kBAAe,iBAAiB,CAAC"}

+ 1 - 1
lib/middlewares/SessionMiddleware.ts

@@ -4,7 +4,7 @@ import { Guid } from '../base/util';
 class SessionMiddleware extends Middleware {
 class SessionMiddleware extends Middleware {
 	protected order = -98;
 	protected order = -98;
 	protected route = null;
 	protected route = null;
-	protected action = session({ secret: this.context.options?.sessionSecret || Guid.new(), resave: false, saveUninitialized: false });
+	protected action = session({ secret: this.context.options?.sessionSecret || Guid.new(), resave: this.context.options?.sessionResave || false, saveUninitialized: this.context.options?.sessionSaveUninitialized || false, cookie: { maxAge: this.context.options?.sessionMaxAge || 3600000 } });
 }
 }
 
 
 export default SessionMiddleware;
 export default SessionMiddleware;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "org.crazydoctor.expressts",
   "name": "org.crazydoctor.expressts",
-  "version": "1.0.6",
+  "version": "1.0.7",
   "devDependencies": {
   "devDependencies": {
     "@types/express-session": "^1.17.7",
     "@types/express-session": "^1.17.7",
     "@types/node": "^20.4.9",
     "@types/node": "^20.4.9",