Skip to content

Commit

Permalink
feat: add session option for custom ttl function (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
Munilive authored Apr 15, 2024
1 parent 93f83d7 commit 194a179
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/express/src/config.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -14,6 +14,7 @@ export interface IExpressConfig {
password?: string;
};
ttl: number;
custom_ttl?: (sess: SessionData) => number;
secret: string;
name?: string;
save_uninitialized?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/express/src/create_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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...');
Expand Down

0 comments on commit 194a179

Please sign in to comment.