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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user