Session storage for koa-generic-session.
$ npm install koa-level
var koa = require('koa');
var level = require('levelup');
var session = require('koa-sess');
var store = require('koa-level');
var db = level('./db');
var app = koa();
app.use(session({
store: store({ db: db })
}));
app.use(function*() {
if(this.url.match(/hello\/\w+/)) {
this.session.name = this.url.match(/hello\/(\w+)/)[1];
}
this.body = 'Hello ' + this.session.name
});
app.listen(3000);
Create koa-generic-session compatilbe storage from
opts.db
.
If you don't want to pollute the db, use level-sublevel to prefix session ids (you can put data in different "tables").
TTL is only supported, when the underlying db supports it, via level-ttl or similar.
You can use leveldb over the network with multilevel.
MIT