diff --git a/src/session/mod.ts b/src/session/mod.ts index 28748b4..dfd1f43 100644 --- a/src/session/mod.ts +++ b/src/session/mod.ts @@ -8,21 +8,24 @@ type SessionEntry = { export class SessionStore { static #store = new Map() + + static get maxAge() { + const halfHour = 30 * 60 * 1_000 + return Date.now() - halfHour + } static createSession(): Session { return new Session(this.#store) } static getSession(uuid: string): Session | undefined { // Check session validity - const halfHour = 30 * 60 * 1_000 - const maxAge = Date.now() - halfHour const session = this.#store.get(uuid) if (session === undefined) { return undefined } - if (session.timestamp < maxAge) { + if (session.timestamp < this.maxAge) { session.destroy() return undefined }