在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:pavelvlasov/koa-generic-session-mongo开源软件地址:https://github.com/pavelvlasov/koa-generic-session-mongo开源编程语言:JavaScript 100.0%开源软件介绍:koa-generic-session-mongoMongoDB store for koa-generic-session middleware backed by node-mongodb-native. Fork of connect-to-mongo store. Installation npm install koa-generic-session koa-generic-session-mongo --save UsageExamplevar koa = require('koa');
var session = require('koa-generic-session');
var MongoStore = require('koa-generic-session-mongo');
var app = koa();
app.keys = ['keys', 'keykeys'];
app.use(session({
store: new MongoStore({
host: '127.0.0.1'
}) // options
}));
app.use(function *() {
switch (this.path) {
case '/get':
get.call(this);
break;
case '/remove':
remove.call(this);
break;
}
});
function get() {
var session = this.session;
session.count = session.count || 0;
session.count++;
this.body = session.count;
}
function remove() {
this.session = null;
this.body = 0;
}
app.listen(8080); Options
LicenseMIT |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论