Merge pull request #8 from Fretuks/fix-session-file-store-errors

Ensure session storage directory exists and use resolved path
This commit is contained in:
2026-01-14 14:11:47 +01:00
committed by GitHub
+6 -1
View File
@@ -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,