Files
worklenz/worklenz-backend/src/middlewares/session-middleware.ts
chamikaJ 8825b0410a init
2025-04-17 18:28:54 +05:30

27 lines
753 B
TypeScript

import session from "express-session";
import db from "../config/db";
import { isProduction } from "../shared/utils";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pgSession = require("connect-pg-simple")(session);
export default session({
name: process.env.SESSION_NAME,
secret: process.env.SESSION_SECRET || "development-secret-key",
proxy: false,
resave: false,
saveUninitialized: true,
rolling: true,
store: new pgSession({
pool: db.pool,
tableName: "pg_sessions"
}),
cookie: {
path: "/",
// secure: isProduction(),
// httpOnly: isProduction(),
// sameSite: "none",
// domain: isProduction() ? ".worklenz.com" : undefined,
maxAge: 30 * 24 * 60 * 60 * 1000 // 30 days
}
});