@lbu/store
Advanced tools
Comparing version 0.0.51 to 0.0.52
@@ -373,27 +373,11 @@ import * as minioVendor from "minio"; | ||
/** | ||
* Stop the background job | ||
* Remove all expired sessions | ||
*/ | ||
kill(): void; | ||
clean(): Promise<void>; | ||
} | ||
export interface SessionStoreOptions { | ||
/** | ||
* Interval at which a background job runs to remove expired sessions | ||
* Defaults to 45 minutes | ||
*/ | ||
cleanupInterval?: number; | ||
/** | ||
* Disable deletion interval completely | ||
*/ | ||
disableInterval?: boolean; | ||
} | ||
/** | ||
* Create a session store that can be used in combination with @lbu/server#session | ||
* Create a session store compatible with @lbu/server#session | ||
*/ | ||
export function newSessionStore( | ||
sql: postgresVendor.Sql<{}>, | ||
opts?: SessionStoreOptions, | ||
): SessionStore; | ||
export function newSessionStore(sql: postgresVendor.Sql<{}>): SessionStore; | ||
@@ -400,0 +384,0 @@ /** |
{ | ||
"name": "@lbu/store", | ||
"version": "0.0.51", | ||
"version": "0.0.52", | ||
"description": "Postgres & S3-compatible wrappers for common things", | ||
@@ -18,4 +18,4 @@ "main": "./index.js", | ||
"dependencies": { | ||
"@lbu/insight": "0.0.51", | ||
"@lbu/stdlib": "0.0.51", | ||
"@lbu/insight": "0.0.52", | ||
"@lbu/stdlib": "0.0.52", | ||
"@types/minio": "7.0.6", | ||
@@ -47,3 +47,3 @@ "mime-types": "2.1.27", | ||
}, | ||
"gitHead": "25c297d76a4ac9d9a1bb4c0f6ab917d12db6f5f2" | ||
"gitHead": "a41579009d718cd285ea960c7ef5e66cc1eed9dd" | ||
} |
import { storeQueries } from "./generated/queries.js"; | ||
const DELETE_INTERVAL = 45 * 60 * 1000; // 45 minutes | ||
/** | ||
* | ||
* @param sql | ||
* @param {object} [options] | ||
* @param {number} [options.cleanupInterval] | ||
* @param {boolean} [options.disableInterval] | ||
* @param {Postgres} sql | ||
* @returns {SessionStore} | ||
*/ | ||
export function newSessionStore(sql, options) { | ||
options = options || {}; | ||
options.cleanupInterval = options.cleanupInterval || DELETE_INTERVAL; // 45 minutes | ||
let interval; | ||
if (!options.disableInterval) { | ||
interval = setInterval(() => { | ||
storeQueries.sessionStoreDelete(sql, { expiresLowerThan: new Date() }); | ||
}, options.cleanupInterval); | ||
} | ||
export function newSessionStore(sql) { | ||
return { | ||
@@ -46,6 +29,8 @@ get: async (sid) => { | ||
}, | ||
kill: () => { | ||
clearInterval(interval); | ||
clean: () => { | ||
return storeQueries.sessionStoreDelete(sql, { | ||
expiresLowerThan: new Date(), | ||
}); | ||
}, | ||
}; | ||
} |
76459
2170
+ Added@lbu/insight@0.0.52(transitive)
+ Added@lbu/stdlib@0.0.52(transitive)
- Removed@lbu/insight@0.0.51(transitive)
- Removed@lbu/stdlib@0.0.51(transitive)
Updated@lbu/insight@0.0.52
Updated@lbu/stdlib@0.0.52