A PouchDB session store for express.js.
Featuresnpm install session-pouchdb-store --save
This will install session-pouchdb-store
and add it to your application's package.json
file.
If you use a remote PouchDB server, make sure the database exists prior to start your application/s
Basic UsageUse with your express session middleware, like this:
constÂ
    express = require("express"),
    session = require("express-session"),
    PouchSession = require("session-pouchdb-store");
Â
let app = express();
Â
app.use(session({
  secret: 'thisismysecret',
  resave: false,
  saveUninitialized: true,
    store : new PouchSession()
}));
Â
app.listen(3000, () => {
    console.log(`Server ${process.pid} started on port 3000`);
});
By default, PouchSession creates an in-memory database for testing purposes. You can pass your own instance or connect to a remote PouchDB/CouchDB server:
Remote PouchDB serverCustom instanceapp.use(session({
  secret: 'thisismysecret',
  resave: false,
  saveUninitialized: true,
    store : new PouchSession('http://pouchdbserver:port/sessions')
}));
Realtime synchronizationconst PouchDB = require('pouchdb');
Â
let db = new PouchDB("sessions",{adapter:'leveldb'});
app.use(session({
  secret: 'thisismysecret',
  resave: false,
  saveUninitialized: true,
    store : new PouchSession(db)
}));
In order to synchronize session data, the current version of the store requires a remote PouchDB server, so multiple express processes can connect to the same database and perform synchronization.
API new PouchSession(pouchInstance, options)Creates a new store instance. The first argument can be one of the following:
Options is an object that allows overriding some store behaviours:
Default options are as follows:
Here is a list of all available options:
var options = {
   Â
    maxIdle : 5*60*1000,
   Â
    scavenge : 1000,
   Â
    purge : 5*60*1000
};
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4