22 lines
519 B
TypeScript
22 lines
519 B
TypeScript
export const sessionConfig = {
|
|
password: process.env["SESSION_SECRET"] || "",
|
|
name: "slalog-session",
|
|
maxAge: 60 * 60 * 12,
|
|
cookie: {
|
|
httpOnly: true,
|
|
sameSite: "lax" as const,
|
|
path: "/",
|
|
secure: process.env["NODE_ENV"] === "production",
|
|
},
|
|
};
|
|
|
|
export interface SessionUser {
|
|
userId: string;
|
|
}
|
|
|
|
export function assertSessionConfig() {
|
|
if (!sessionConfig.password || sessionConfig.password.length < 32) {
|
|
throw new Error("SESSION_SECRET must be set with at least 32 characters.");
|
|
}
|
|
}
|