Files
Michess/server/src/middleware/session.ts
Michess 7dac042d73 feat: Michess – Initiales Setup auf Basis von chessu
- Rebranding: chessu → Michess (Header, Footer, Metadata, Session-Cookie)
- Stockfish KI-Integration: 6 Schwierigkeitsgrade (Anfänger bis Meister)
- Admin-Panel: Nutzerverwaltung, Sperren/Entsperren, Git-Pull-Update
- Freundessystem: Anfragen, Freundesliste, Nutzersuche
- DB-Schema: role, banned, friend_request, friendship Tabellen
- Docker: NAS-optimiertes docker-compose.yml mit PostgreSQL Healthcheck
- Stockfish binary via apk im Alpine-Image installiert
- .env.example für einfaches Deployment
- scripts/update.sh für manuelles NAS-Update
- Brain.md + Plan.md als Projekt-Gedächtnis

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-13 10:02:52 +02:00

44 lines
1.2 KiB
TypeScript

import type { User } from "@chessu/types";
import PGSimple from "connect-pg-simple";
import type { Session } from "express-session";
import session from "express-session";
import { nanoid } from "nanoid";
import { db } from "../db/index.js";
const PGSession = PGSimple(session);
declare module "express-session" {
// eslint-disable-next-line no-unused-vars
interface SessionData {
user: User;
}
}
declare module "http" {
// eslint-disable-next-line no-unused-vars
interface IncomingMessage {
session: Session & {
user: User;
};
}
}
const sessionMiddleware = session({
store: new PGSession({ pool: db, createTableIfMissing: true }),
secret: process.env.SESSION_SECRET || "make sure to change this!",
resave: false,
saveUninitialized: false,
name: "michess",
proxy: true,
cookie: {
maxAge: 30 * 24 * 60 * 60 * 1000, // 30 days
secure: process.env.NODE_ENV === "production" ? true : false,
httpOnly: true,
sameSite: process.env.NODE_ENV === "production" ? "none" : "lax"
},
genid: function () {
return nanoid(21);
}
});
export default sessionMiddleware;