server-ts: Convert routes/session_parser

This commit is contained in:
Elian Doran
2024-04-07 14:32:08 +03:00
parent 34cd2eba91
commit 2e906af77d
5 changed files with 26 additions and 6 deletions

View File

@@ -0,0 +1,22 @@
import session = require("express-session");
import sessionSecret = require('../services/session_secret');
import dataDir = require('../services/data_dir');
const FileStore = require('session-file-store')(session);
const sessionParser = session({
secret: sessionSecret,
resave: false, // true forces the session to be saved back to the session store, even if the session was never modified during the request.
saveUninitialized: false, // true forces a session that is "uninitialized" to be saved to the store. A session is uninitialized when it is new but not modified.
cookie: {
// path: "/",
httpOnly: true,
maxAge: 24 * 60 * 60 * 1000 // in milliseconds
},
name: 'trilium.sid',
store: new FileStore({
ttl: 30 * 24 * 3600,
path: `${dataDir.TRILIUM_DATA_DIR}/sessions`
})
});
export = sessionParser;