A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.npmjs.com/package/session-pouchdb-store below:

session-pouchdb-store - npm

session-pouchdb-store

A PouchDB session store for express.js.

Features Installation
npm install session-pouchdb-store --save

This will install session-pouchdb-store and add it to your application's package.json file.

Important Notes

If you use a remote PouchDB server, make sure the database exists prior to start your application/s

Basic Usage

Use 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 server

app.use(session({

  secret: 'thisismysecret',

  resave: false,

  saveUninitialized: true,

    store : new PouchSession('http://pouchdbserver:port/sessions')

}));

Custom instance

const PouchDB = require('pouchdb');

 

let db = new PouchDB("sessions",{adapter:'leveldb'});

app.use(session({

  secret: 'thisismysecret',

  resave: false,

  saveUninitialized: true,

    store : new PouchSession(db)

}));

Realtime synchronization

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