본문으로 건너뛰기
Public Source Viewer

비나래아카이브 개발자 포털

실제 서비스 구조를 살펴볼 수 있는 공개용 코드 뷰어입니다. 인증, 세션, 외부 연동, 토큰, 관리자 식별 등 보안상 민감한 구현은 파일 단위 또는 줄 단위로 검열됩니다.

Redacted View
src/middleware/theme.middleware.ts
공개 가능
1 import { Request, Response, NextFunction } from 'express';
2
3 export function themeMiddleware(req: Request, res: Response, next: NextFunction): void {
4 if (req.method === 'POST' && req.path === '/hinana/works/desktop-publish') { res.locals.theme = 'light'; return next(); }
5 if (!req.session.theme && req.cookies.theme) {
6 req.session.theme = req.cookies.theme;
7 }
8
9 if (!req.session.theme) {
10 req.session.theme = 'light';
11 }
12
13 res.locals.theme = req.session.theme;
14 res.locals.uiUsername = req.session.username || null;
15 res.locals.uiPath = req.originalUrl;
16 next();
17 }
18