27 lines
753 B
TypeScript
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
|
|
}
|
|
}); |