memorystore: simplify, refactor, re-enable

Removes a lot of unused (in ABS) functionality, refactors to ES6
style class, and re-enables this custom implementation with check
period and ttl of 1 day, and 1000 max entries.

The class now only implments the required (as per express-session docs)
methods and removes optional methods, except touch() which allows the
TTL of an entry to be refreshed without affecting its LRU recency.

There is no longer a way to stop the prune timer, but I don't belive
the function was ever being called beforehand. The session store's
lifetime is the same as the application's, and since it is unref()'d
should not cause any shutdown issues.
This commit is contained in:
James Ross 2024-08-19 08:17:54 +00:00 committed by James Ross
parent 27b3a44147
commit ec197b2e13
2 changed files with 58 additions and 241 deletions

View file

@ -41,6 +41,7 @@ const LibraryScanner = require('./scanner/LibraryScanner')
//Import the main Passport and Express-Session library
const passport = require('passport')
const expressSession = require('express-session')
const MemoryStore = require('./libs/memorystore')
class Server {
constructor(SOURCE, PORT, HOST, CONFIG_PATH, METADATA_PATH, ROUTER_BASE_PATH) {
@ -232,7 +233,8 @@ class Server {
cookie: {
// also send the cookie if were are not on https (not every use has https)
secure: false
}
},
store: new MemoryStore(86400000, 86400000, 1000)
})
)
// init passport.js