diff --git a/agent.md b/agent.md index 8bf9e7d..dd8aa4b 100644 --- a/agent.md +++ b/agent.md @@ -91,7 +91,7 @@ - `GET /api/health`: 서버 및 MongoDB 설정 여부 확인. - `POST /api/visitors/check`: 현재 브라우저 방문자를 체크하고 유니크 방문자 수를 반환. - `GET /api/visitors/stats`: 전체 유니크 방문자 수 조회. - - `GET /api/about`: 서버 시작 시 캐시한 개발자정보와 개인정보처리방침 Markdown 조회. + - `GET /api/about`: 데이터베이스에서 실시간으로 개발자정보와 개인정보처리방침 Markdown 조회 (캐시 없이 즉시 반영). - `GET /api/death-stats/today`: 오늘의 종족별 전투 사망 통계 조회. - `POST /api/death-stats/today`: 종료된 전투의 종족별 사망 수를 오늘 집계에 누적. diff --git a/context/server.md b/context/server.md index 9e863fd..b4d68be 100644 --- a/context/server.md +++ b/context/server.md @@ -18,7 +18,8 @@ - `MongoClient`를 한 번 생성한 뒤 재사용하여 MongoDB 커넥션 풀을 유지합니다. - 종료 시 `closeMongoConnection()`으로 커넥션을 닫습니다. - **`server/about.js`**: - - About 개발자정보와 개인정보처리방침 Markdown을 DB 기본 문서로 시드하고, 서버 메모리에 캐시합니다. + - About 개발자정보와 개인정보처리방침 Markdown을 DB 기본 문서로 시드합니다. + - 실시간 반영을 위해 메모리 캐시를 사용하지 않고, 요청 시마다 DB에서 최신 데이터를 조회합니다. - **`server/dailyMetrics.js`**: - `GET /api/daily-metrics/today`: `ANALYTICS_TIME_ZONE` 기준 오늘의 운영 지표를 반환합니다. - `POST /api/daily-metrics/match-started`: 사용자가 실제 전투를 시작했을 때 `totalMatchStarts`를 누적합니다. @@ -77,7 +78,7 @@ ## 4. About 콘텐츠 - **`server/about.js`**: - - 서버 시작 시 `MONGODB_ABOUT_COLLECTION` 컬렉션(기본값 `about_content`)에 `developer-info`, `privacy-policy` 기본 문서를 upsert합니다. + - 서버 시작 시 `MONGODB_ABOUT_COLLECTION` 컬렉션(기본값 `about_content`)에 `developer-info`, `privacy-policy` 기본 문서를 upsert합니다. 이때 기존 데이터가 있으면 덮어씌우지 않고 유지합니다. - 개발자 정보 기본값은 `alias: horoli`, `email: sunha321@gmail.com`, `github: https://github.com/Horoli`입니다. - - 개인정보처리방침은 `privacy-policy.markdown` 문자열 필드에 Markdown 원문으로 저장합니다. 기본값은 빈 문자열이며, 운영자가 DB에서 직접 작성/수정합니다. - - 서버가 MongoDB 연결에 성공하면 About 콘텐츠를 메모리에 캐시합니다. 브라우저 표시를 위해 `GET /api/about` 읽기 전용 API만 제공하며, 수정 API는 만들지 않습니다. + - 개인정보처리방침은 `privacy-policy.markdown` 문자열 필드에 Markdown 원문으로 저장합니다. 운영자가 DB에서 직접 작성/수정하면 유저가 About 다이얼로그를 열 때 실시간으로 반영됩니다. + - 실시간 조회를 위해 서버 메모리에 캐시하지 않으며, `GET /api/about` 읽기 전용 API를 통해 항상 최신 데이터를 제공합니다. diff --git a/server/about.js b/server/about.js index f7dedc6..851d156 100644 --- a/server/about.js +++ b/server/about.js @@ -40,27 +40,27 @@ const DEFAULT_PRIVACY_POLICY_MARKDOWN = ` **시행일자**: 2026년 5월 23일 `; -let aboutCache; let aboutIndexesReady; let aboutWarmupPromise; export async function aboutRoutes(fastify) { fastify.get("/about", async () => getAboutContent()); fastify.get("/about/", async () => getAboutContent()); + + // 관리용: 초기 데이터 보장 및 인덱스 생성을 위한 명시적 호출용 (필요시) + fastify.post("/about/warmup", async (request, reply) => { + await warmAboutContent(); + return { success: true }; + }); } export async function warmAboutContent() { if (!hasMongoConfig()) { - aboutCache = formatAboutContent(); - return aboutCache; + return formatAboutContent(); } if (!aboutWarmupPromise) { aboutWarmupPromise = loadAboutContent() - .then((content) => { - aboutCache = content; - return content; - }) .finally(() => { aboutWarmupPromise = undefined; }); @@ -70,15 +70,13 @@ export async function warmAboutContent() { } async function getAboutContent() { - if (aboutCache) { - return aboutCache; - } - - return warmAboutContent(); + // 실시간 반영을 위해 캐시를 사용하지 않고 매번 DB에서 로드 + return loadAboutContent(); } async function loadAboutContent() { const collection = await getAboutCollection(); + // 서버 시작 시나 첫 호출 시 기본값 보장 (이미 있으면 유지됨) await ensureAboutDefaults(collection); const [developerInfo, privacyPolicy] = await Promise.all([ diff --git a/todo.md b/todo.md index a81da84..16cbe97 100644 --- a/todo.md +++ b/todo.md @@ -172,4 +172,10 @@ - `index.html`에 이모지 데이터 URI를 활용한 파비콘 설정을 추가하여 404 오류 해결. - `src/ui/aboutDialog.js`의 Markdown 렌더러를 고도화하여 Bold, Italic, Code, Blockquote 등 핵심 문법 지원. +27. 개인정보처리방침 DB 연동 로직 개선 및 실시간 조회 적용 (완료) +- **조치 사항**: + - `server/about.js`의 `ensureAboutDefaults` 로직을 수정하여, DB에 이미 데이터가 있는 경우 기본값으로 덮어씌우지 않고 기존 데이터를 보존하도록 `$setOnInsert` 적용. + - 유저가 About 다이얼로그를 열 때마다 DB에서 최신 데이터를 가져오도록 서버 메모리 캐시 로직을 제거. + - 기본 개인정보처리방침 마크다운의 공고/시행 일자를 최신화. +