const DB = require("./connection");
const session = require('express-session');
const {ConnectSessionKnexStore} = require('connect-session-knex');
const {Application} = require("../core/server");

Application.set('trust proxy', 1);

const store = new ConnectSessionKnexStore({
    knex: DB,
    tablename: 'sessions',
    createtable: true,
    clearInterval: 1000 * 60 * 60 // Süresi dolmuş sessionları temizleme aralığı (1 saat)
});

Application.use(session({
    secret: 'ekoetkimardinsaqut',
    resave: false,
    saveUninitialized: false,
    store: store,
    cookie: {
        maxAge: 1000 * 60 * 60 * 3,
        secure: true,
        httpOnly: true 
    }
}));