diff --git a/packages/express/src/config.ts b/packages/express/src/config.ts index 1eaaf42..4c29249 100644 --- a/packages/express/src/config.ts +++ b/packages/express/src/config.ts @@ -1,5 +1,5 @@ import express from 'express'; -import expressSession from 'express-session'; +import expressSession, { SessionData } from 'express-session'; import log4js from 'log4js'; export interface IExpressConfig { @@ -14,6 +14,7 @@ export interface IExpressConfig { password?: string; }; ttl: number; + custom_ttl?: (sess: SessionData) => number; secret: string; name?: string; save_uninitialized?: boolean; diff --git a/packages/express/src/create_app.ts b/packages/express/src/create_app.ts index 7a70ff9..9dd7b87 100644 --- a/packages/express/src/create_app.ts +++ b/packages/express/src/create_app.ts @@ -74,7 +74,7 @@ function setupSession(app: express.Express, config: IExpressConfig) { }); const session_store = new RedisStore({ client: redis_client, - ttl: config.session.ttl, + ttl: config.session.custom_ttl ?? config.session.ttl, }); session_store.on('disconnect', () => { console.log('RedisStore for express is disconnected. Exit the process...');