connect-remote

2.0.0 • Public • Published

connect-remote is a session store backed by any compatbile remote RESTful API service.

Setup

npm install connect-remote express-session

Pass the express-session store into connect-remote to create a RemoteStore constructor.

var session = require('express-session');
var RemoteStore = require('connect-remote')(session);

app.use(session({
    store: new RedisStore(options),
    secret: 'keyboard cat',
    resave: false
}));

Options

A compatbile remote RESTful API URI is required. It is passed directly using the uri param.

  • uri Remote service uri

The following additional params may be included:

  • timeout Value used for timeout option in Request (defaults to 100).

Compatbile remote RESTful API service

This stores implement below functions:

  • destroy: By DELETE method agasint uri ${uri}/${session_id}.
  • get: By GET method agasint uri ${uri}/${session_id}.
  • set: By PUT method agasint uri ${uri}/${session_id} with session data as request body.
  • all: By GET method agasint uri ${uri}/.
  • clear: By DELETE method agasint uri ${uri}/.
  • length: By GET method agasint uri ${uri}/count.
  • touch: By POST method agasint uri ${uri}/${session_id} with session data as request body.

All service response should be a JSON with data attribute that containing the result.

// RESTful API response sample for get method
{
    "data": {
        "cookie": {
            "originalMaxAge": 3600000,
            "expires": "2019-02-26T06:20:10.358Z",
            "httpOnly": true,
            "path": "/"
        }
    }
}

// RESTful API response sample for length method
{
    "data": 5
}

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i connect-remote

Weekly Downloads

35

Version

2.0.0

License

MIT

Unpacked Size

3.99 kB

Total Files

3

Last publish

Collaborators

  • chengusky