@beerpsi/elysia-session
v0.1.0
Published
Session plugin for Elysia
Readme
elysia-session
Session plugin for Elysia. See the example.
Configuration
interface SessionOptions<
TStore extends Store,
Schema extends TObject | undefined = undefined,
> {
/**
* The session store implementation.
*/
store: TStore;
/**
* Type strict validation for session data. Session data is validated at:
* - session load time, for existing sessions
* - session save time, if the session will be saved (see {@link alwaysSave} and {@link saveUninitialized})
*
* New sessions are not validated.
*/
schema?: Schema;
/**
* The name of the session cookie.
*/
name?: string;
/**
* The function used to generate the session ID.
*/
generateSessionId?: () => string;
/**
* Force the session to be saved back to the store, even if it was never modified
* during the request.
*/
alwaysSave?: boolean;
/**
* Whether to save "uninitialized" sessions to the store.
*/
saveUninitialized?: boolean;
/**
* Additional session cookie options. See [Elysia's cookie configuration](https://elysiajs.com/patterns/cookie.html#config)
* for details.
*/
cookieOptions?: Omit<CookieOptions, "value">;
}Session store
Session stores must adhere to the Store interface. For example
implementations, see stores based on Bun's RedisClient and
SQL.
