2.0.0 • Published 3 years ago
connect-remote v2.0.0
connect-remote is a session store backed by any compatbile remote RESTful API service.
Setup
npm install connect-remote express-sessionPass 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.
uriRemote service uri
The following additional params may be included:
timeoutValue used for timeout option in Request (defaults to 100).
Compatbile remote RESTful API service
This stores implement below functions:
destroy: ByDELETEmethod agasint uri${uri}/${session_id}.get: ByGETmethod agasint uri${uri}/${session_id}.set: ByPUTmethod agasint uri${uri}/${session_id}with session data as request body.all: ByGETmethod agasint uri${uri}/.clear: ByDELETEmethod agasint uri${uri}/.length: ByGETmethod agasint uri${uri}/count.touch: ByPOSTmethod 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