structured-plugin-session-redis
v0.1.5
Published
Plugin for Structured framework (structured-fw) allowing for Redis-persisted sessions.
Maintainers
Readme
structured-plugin-session-redis
This is a plugin for Structured framework that allows for persistent sessions using Redis.
To use the plugin, install it using:npm install structured-plugin-session-redis
In your entry TS file:import { redisSessions } from 'structured-plugin-session-redis';
Then, before calling app.init(), add:app.registerPlugin(redisSessions, {});
Second argument is the options (RedisSessionOptions)
Options:
type RedisSessionOptions = {
sessionPrefix?: string,
preserveTypes?: boolean,
loadExpiredSessions?: boolean,
}sessionPrefix - sessions are stored in Redis with key [sessionPrefix].[sessionId], if omitted prefix is auto generated based on the app pathpreserveTypes - if true, additional types will survive data serialization (Date, BigInt, RegExp, Map and Uint8Array)loadExpiredSessions - if true expired sessions are not discarded when loading sessions. Useful when sessionExpired event needs to be handled. Expired sessions will be garbage collected by Structured, firing sessionExpired in the process
You will no longer lose sessions when you restart the app.
