From 46891f322be23fb726218107f914a675009fb066 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 19 Apr 2023 13:18:01 -0400 Subject: [PATCH] refactor(striker-ui-api): rename session->expressSession, sessionHandler->session --- striker-ui-api/src/app.ts | 4 ++-- striker-ui-api/src/session.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/striker-ui-api/src/app.ts b/striker-ui-api/src/app.ts index 0bd58474..32f212b6 100644 --- a/striker-ui-api/src/app.ts +++ b/striker-ui-api/src/app.ts @@ -5,7 +5,7 @@ import { guardApi } from './lib/assertAuthentication'; import passport from './passport'; import routes from './routes'; import { rrouters } from './lib/rrouters'; -import sessionHandler from './session'; +import session from './session'; const app = express(); @@ -15,7 +15,7 @@ app.use(cors()); // Add session handler to the chain **after** adding other handlers that do // not depend on session(s). -app.use(sessionHandler); +app.use(session); app.use(passport.initialize()); app.use(passport.authenticate('session')); diff --git a/striker-ui-api/src/session.ts b/striker-ui-api/src/session.ts index ca22978d..aee10b8b 100644 --- a/striker-ui-api/src/session.ts +++ b/striker-ui-api/src/session.ts @@ -1,4 +1,4 @@ -import session, { +import expressSession, { SessionData, Store as BaseSessionStore, } from 'express-session'; @@ -13,7 +13,7 @@ import { getSessionSecret } from './lib/getSessionSecret'; import { isObject } from './lib/isObject'; import { stderr, stdout, stdoutVar, uuidgen } from './lib/shell'; -const DEFAULT_COOKIE_ORIGINAL_MAX_AGE = 1000 * 60 * 60; +const DEFAULT_COOKIE_ORIGINAL_MAX_AGE = 3600000; const getWriteCode = (obj: object) => { let result: number | undefined; @@ -218,7 +218,7 @@ export class SessionStore extends BaseSessionStore { } } -const sessionHandler = session({ +const session = expressSession({ cookie: { maxAge: DEFAULT_COOKIE_ORIGINAL_MAX_AGE }, genid: ({ path }) => { const sid = uuidgen('--random').trim(); @@ -233,4 +233,4 @@ const sessionHandler = session({ store: new SessionStore(), }); -export default sessionHandler; +export default session;