This is an ESM-only module, it must be imported using the import
declaration or the import()
syntax. It cannot be required from a CommonJS module.
Example:
import express from 'express'
import session from 'express-session'
import RestStore from './index.js'
const app = express()
app.use(session({
secret: 'xxxxxxxxxxxxxxxx',
store: new RestStore('http://127.0.0.1/sessions'),
cookie: {
maxAge: 24 * 60 * 60 * 1000,
httpOnly: true,
secure: false
},
saveUninitialized: false,
resave: false
}))
Request
GET /
Response
[
{
"key": "value"
},
...sessions
]
Request
DELETE /
Reponse
{
"status": "OK"
}
GET /{sid}
Response
{
"key": "value"
}
If the session doesn't exist, the API should respond with a 404 error code.
DELETE /{sid}
Reponse
{
"status": "OK"
}
Request
POST /{sid}
{
"key": "value"
}
Response
{
"key": "value"
}
This can also be used in conjuction with the ?ping
URL parameter. Then the API is able to update any existing expire times of the session if any.
If the session with {sid}
already exists, the API should update that one.