- Eliminated extensive console logging in the auth controller, deserialize, serialize, and passport strategies to streamline code and improve performance. - Simplified response handling in the auth controller by directly returning the AuthResponse object. - Updated session middleware to enhance clarity and maintainability by removing unnecessary debug functions and logs.
25 lines
642 B
TypeScript
25 lines
642 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: true,
|
|
saveUninitialized: false,
|
|
rolling: true,
|
|
store: new pgSession({
|
|
pool: db.pool,
|
|
tableName: "pg_sessions"
|
|
}),
|
|
cookie: {
|
|
path: "/",
|
|
httpOnly: true,
|
|
secure: false,
|
|
maxAge: 30 * 24 * 60 * 60 * 1000 // 30 days
|
|
}
|
|
}); |