first commit

This commit is contained in:
ysj7705 committed 2026-07-15 17:29:25 +09:00
commit a74fe7a388
42 files changed
+6058

No files matched your search

@@ -0,0 +1,21 @@
import type { RequestHandler } from 'express';
import { getSession, touchSession } from '../services/sessionStore.js';
const COOKIE = 'sejong_sid';
export { COOKIE as SESSION_COOKIE };
export const requireSession: RequestHandler = (req, res, next) => {
const sessionId =
(req.cookies?.[COOKIE] as string | undefined) ??
(req.header('x-session-id') as string | undefined);
if (!sessionId || !getSession(sessionId)) {
res.status(401).json({ error: 'session_required' });
return;
}
touchSession(sessionId);
res.locals.sessionId = sessionId;
next();
};