connect-couchdb
is a storage wrapper for the express-session middleware of connect/
expressjs frameworks.
- couchdb (tested with v1.5.0)
- yacw 0.2.x : the couchdb wrapper. Should be easy to use another one.
- mocha (only for tests)
For node v0.10, Connect v3 and Express v4 you must use the master branch. For olders node version, use others branches.
Via npm:
$ npm install connect-couchdb --save
var session = require('express-session'),
connect = require('connect');
ConnectCouchDB = require('connect-couchdb')(session);
var store = new ConnectCouchDB({
// Name of the database you would like to use for sessions.
name: 'myapp-sessions',
// Optional. Database connection details. See yacw documentation
// for more informations
username: 'username',
password: 'password',
host: 'localhost',
// Optional. How often expired sessions should be cleaned up.
// Defaults to 600000 (10 minutes).
reapInterval: 600000,
// Optional. How often to run DB compaction against the session
// database. Defaults to 300000 (5 minutes).
// To disable compaction, set compactInterval to -1
compactInterval: 300000,
// Optional. How many time between two identical session store
// Defaults to 60000 (1 minute)
setThrottle: 60000
});
var server = connect();
server.use(session({secret: 'YourSecretKey', store: store });
If the database specified doesn't already exist you have to create it with
tools/
files. Run following command to create database, populate with the
design document and setup the CouchDB database specific option _revs_limit
:
$ node tools/setup.js <database_name> <revs_limit> [username] [password]
For more informations about the _revs_limit
option, read
this.
It is highly recommended that you use a separate database for your sessions for performance of both the session views and any other document views you may have.
See example.js
file for an example connect server using connect-couch
.
Please invoke the tool to create the design documents when updating to insure you are using the last version of the view.
$ node tools/put_design_docs.js <database_name> [username] [password]
$ npm test
- Thomas de Barochez (tdebarochez)
$ git shortlog -s -n