Example:
import express from 'express'
import session from 'express-session'
import restsession from 'restsession'
const app = express()
const HTTPStore = restsession(session)
app.use(session({
secret: 'Kgqnq5YsquMjEZd3TX',
store: new HTTPStore('http://127.0.0.1:1200/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 exists, The API should throw a HTTP 404 Not Found
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.