From 214e40a6413d09db8d7654aa30a720072b80ef28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Issue=E5=93=A5?= Date: Fri, 26 Apr 2019 23:12:14 +0800 Subject: [PATCH 1/4] add ctx as arg for genid --- lib/context.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/context.js b/lib/context.js index 410996b..9edd6ba 100644 --- a/lib/context.js +++ b/lib/context.js @@ -202,7 +202,7 @@ class ContextSession { create(val, externalKey) { debug('create session with val: %j externalKey: %s', val, externalKey); - if (this.store) this.externalKey = externalKey || this.opts.genid(); + if (this.store) this.externalKey = externalKey || this.opts.genid(this.ctx); this.session = new Session(this, val); } From 05c10bc3bb875f2032fdab8abe118b340913084b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Issue=E5=93=A5?= Date: Fri, 26 Apr 2019 23:33:29 +0800 Subject: [PATCH 2/4] edit package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ff25fb3..eda4ed0 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "koa-session", + "name": "@viegg/koa-session", "description": "Koa cookie session middleware with external store support", - "repository": "koajs/session", - "version": "5.10.1", + "repository": "iwestlin/session", + "version": "5.10.2", "keywords": [ "koa", "middleware", From c7b57413ac08c778317ec39f9eac23b4092f77e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Issue=E5=93=A5?= Date: Fri, 26 Apr 2019 23:41:33 +0800 Subject: [PATCH 3/4] edit readme --- Readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index 6a00431..0351509 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,7 @@ ## Installation ```js -$ npm install koa-session +$ npm install @viegg/koa-session ``` ## Example @@ -41,7 +41,7 @@ $ npm install koa-session View counter example: ```js -const session = require('koa-session'); +const session = require('@viegg/koa-session'); const Koa = require('koa'); const app = new Koa(); @@ -113,7 +113,7 @@ console.log('listening on port 3000'); Once you pass `options.store`, session storage is dependent on your external store -- you can't access the session if your external store is down. **Use external session stores only if necessary, avoid using session as a cache, keep the session lean, and store it in a cookie if possible!** - The way of generating external session id is controlled by the `options.genid`, which defaults to `Date.now() + '-' + uid.sync(24)`. + The way of generating external session id is controlled by the `options.genid`, which defaults to `ctx => Date.now() + '-' + uid.sync(24)`. If you want to add prefix for all external session id, you can use `options.prefix`, it will not work if `options.genid` present. From b908c0fd6e4d08febbb76a39029127d89429c4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Issue=E5=93=A5?= Date: Fri, 26 Apr 2019 23:49:39 +0800 Subject: [PATCH 4/4] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eda4ed0..e759353 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@viegg/koa-session", "description": "Koa cookie session middleware with external store support", "repository": "iwestlin/session", - "version": "5.10.2", + "version": "5.10.3", "keywords": [ "koa", "middleware",