koa-session
Advanced tools
Comparing version 5.8.3 to 5.9.0
5.9.0 / 2018-08-28 | ||
================== | ||
**features** | ||
* [[`7241400`](http://github.com/koajs/session/commit/724140076b65867b1a0cffee4f061971be8751c0)] - feat: Add autoCommit option (#139) (Jonas Galvez <<jonasgalvez@gmail.com>>) | ||
5.8.3 / 2018-08-22 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -45,3 +45,5 @@ 'use strict'; | ||
} finally { | ||
await sess.commit(); | ||
if (opts.autoCommit) { | ||
await sess.commit(); | ||
} | ||
} | ||
@@ -71,2 +73,3 @@ }; | ||
if (opts.signed == null) opts.signed = true; | ||
if (opts.autoCommit == null) opts.autoCommit = true; | ||
@@ -73,0 +76,0 @@ debug('session options %j', opts); |
@@ -199,3 +199,3 @@ 'use strict'; | ||
if (this.store) this.externalKey = externalKey || this.opts.genid(); | ||
this.session = new Session(this.ctx, val); | ||
this.session = new Session(this, val); | ||
} | ||
@@ -202,0 +202,0 @@ |
@@ -15,4 +15,5 @@ 'use strict'; | ||
constructor(ctx, obj) { | ||
this._ctx = ctx; | ||
constructor(sessionContext, obj) { | ||
this._sessCtx = sessionContext; | ||
this._ctx = sessionContext.ctx; | ||
if (!obj) { | ||
@@ -115,4 +116,15 @@ this.isNew = true; | ||
} | ||
/** | ||
* commit this session's headers if autoCommit is set to false | ||
* | ||
* @api public | ||
*/ | ||
async manuallyCommit() { | ||
await this._sessCtx.commit(); | ||
} | ||
} | ||
module.exports = Session; |
@@ -5,3 +5,3 @@ { | ||
"repository": "koajs/session", | ||
"version": "5.8.3", | ||
"version": "5.9.0", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "koa", |
@@ -56,2 +56,3 @@ # koa-session | ||
maxAge: 86400000, | ||
autoCommit: true, /** (boolean) automatically commit headers (default true) */ | ||
overwrite: true, /** (boolean) can overwrite or not (default true) */ | ||
@@ -154,2 +155,6 @@ httpOnly: true, /** (boolean) httpOnly or not (default true) */ | ||
### Session#manuallyCommit() | ||
Session headers are auto committed by default. Use this if `autoCommit` is set to `false`. | ||
### Destroying a session | ||
@@ -156,0 +161,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27319
531
169