const session = require("express-session");
const { RedisStore } = require("connect-redis"); // ✅ FIXED
const { redisClient } = require("./redis");

const sessionConfig = session({
  store: new RedisStore({
    client: redisClient,
  }),

  secret: process.env.SESSION_SECRET,
  resave: false,
  saveUninitialized: false,
  rolling: true, //  IMPORTANT

  cookie: {
    httpOnly: true,
    secure: false, // for local dev
    sameSite: "lax",
    maxAge: 1000 * 60 * 30,
  },
});

module.exports = sessionConfig;