2024-07-18 21:37:45 +03:00
import session from "express-session" ;
2024-07-18 22:59:39 +03:00
import sessionFileStore from "session-file-store" ;
2024-07-18 21:35:17 +03:00
import sessionSecret from "../services/session_secret.js" ;
import dataDir from "../services/data_dir.js" ;
2025-02-10 08:35:01 +01:00
import config from "../services/config.js" ;
2024-07-18 22:59:39 +03:00
const FileStore = sessionFileStore ( session ) ;
2023-05-07 15:23:46 +02:00
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 : {
2025-02-10 19:07:21 +01:00
path : config.Session.cookiePath ,
2023-05-07 15:23:46 +02:00
httpOnly : true ,
maxAge : 24 * 60 * 60 * 1000 // in milliseconds
} ,
2025-01-09 18:07:02 +02:00
name : "trilium.sid" ,
2023-05-07 15:23:46 +02:00
store : new FileStore ( {
ttl : 30 * 24 * 3600 ,
path : ` ${ dataDir . TRILIUM_DATA_DIR } /sessions `
} )
} ) ;
2024-07-18 21:50:12 +03:00
export default sessionParser ;