From 4c4b7252226c2319475b75b507713d8b747d24b1 Mon Sep 17 00:00:00 2001 From: Fretux Date: Wed, 14 Jan 2026 14:10:53 +0100 Subject: [PATCH] Ensure session storage directory exists --- server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 71c921b..1bf6178 100644 --- a/server.js +++ b/server.js @@ -12,12 +12,17 @@ const modelState = new Map(); const app = express(); const PORT = 3000; const DB_PATH = "./data/app.db"; +const SESSIONS_DIR = path.resolve("sessions"); const UNLOAD_AFTER_MS = 30 * 1000; if (!fs.existsSync("./data")) { fs.mkdirSync("./data", {recursive: true}); } +if (!fs.existsSync(SESSIONS_DIR)) { + fs.mkdirSync(SESSIONS_DIR, {recursive: true}); +} + function scheduleModelUnload(model) { if (!modelState.has(model)) { modelState.set(model, {timer: null, activeRequests: 0}); @@ -470,7 +475,7 @@ app.use(bodyParser.json()); app.use(express.static("public")); app.use( session({ - store: new FileStore({path: "./sessions"}), + store: new FileStore({path: SESSIONS_DIR}), secret: "-secret-key-here-", resave: false, saveUninitialized: false,