koa-generic-session-mongo
MongoDB store for koa-generic-session middleware backed by node-mongodb-native.
Last updated 3 years ago by freakycue .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install koa-generic-session-mongo 
SYNC missed versions from official npm registry.

koa-generic-session-mongo

MongoDB 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

Usage

Example

var 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()
}));

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

  • url mongodb connection url (full connection string. host, port, db, ssl options will be ignored)
  • db mongodb-native database object or database name (test by default)
  • collection collection name (sessions by default)
  • host db hostname (127.0.0.1 by default)
  • port db port (27017 by default)
  • ttl ttl in milliseconds (if set it overrides cookie maxAge)
  • user user for MongoDB
  • password password for MongoDB authentication
  • ssl use SSL to connect to MongoDB (false by default)

License

MIT

Current Tags

  • 0.4.0                                ...           latest (3 years ago)

9 Versions

  • 0.4.0                                ...           3 years ago
  • 0.3.1                                ...           4 years ago
  • 0.3.0                                ...           4 years ago
  • 0.2.5                                ...           5 years ago
  • 0.2.4                                ...           5 years ago
  • 0.2.3                                ...           5 years ago
  • 0.2.2                                ...           5 years ago
  • 0.1.2                                ...           5 years ago
  • 0.1.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 3
This Month 80
Last Day 3
Last Week 6
Last Month 75
Dependencies (4)
Dev Dependencies (5)

Copyright 2014 - 2016 © taobao.org |