connect-remote
v2.0.0
Published
Connect session store whose storage is through remote REST API
Downloads
120
Readme
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
: ByDELETE
method agasint uri${uri}/${session_id}
.get
: ByGET
method agasint uri${uri}/${session_id}
.set
: ByPUT
method agasint uri${uri}/${session_id}
with session data as request body.all
: ByGET
method agasint uri${uri}/
.clear
: ByDELETE
method agasint uri${uri}/
.length
: ByGET
method agasint uri${uri}/count
.touch
: ByPOST
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