diff --git a/backend/index.js b/backend/index.js index 604834a..bf902cb 100644 --- a/backend/index.js +++ b/backend/index.js @@ -7,7 +7,7 @@ const FileStoreFactory = require('session-file-store') const { ensureData } = require('./src/db') const authRoutes = require('./src/routes/auth') -const topicsRoutes = require('./src/routes/games') +const topicsRoutes = require('./src/routes/topics') const tierListsRoutes = require('./src/routes/tierlists') const adminRoutes = require('./src/routes/admin') diff --git a/backend/src/routes/games.js b/backend/src/routes/topics.js similarity index 80% rename from backend/src/routes/games.js rename to backend/src/routes/topics.js index a5ba70d..43aa4ad 100644 --- a/backend/src/routes/games.js +++ b/backend/src/routes/topics.js @@ -9,8 +9,8 @@ router.get('/', async (req, res) => { res.json({ games: topics, topics }) }) -router.post('/:gameId/favorite', requireAuth, async (req, res) => { - const topic = await findTopicById(req.params.gameId) +router.post('/:topicId/favorite', requireAuth, async (req, res) => { + const topic = await findTopicById(req.params.topicId) if (!topic || topic.id === 'freeform') return res.status(404).json({ error: 'not_found' }) await favoriteTopic({ userId: req.session.userId, topicId: topic.id }) const topics = await listTopics(req.session.userId) @@ -18,8 +18,8 @@ router.post('/:gameId/favorite', requireAuth, async (req, res) => { res.json({ game: updated, topic: updated }) }) -router.delete('/:gameId/favorite', requireAuth, async (req, res) => { - const topic = await findTopicById(req.params.gameId) +router.delete('/:topicId/favorite', requireAuth, async (req, res) => { + const topic = await findTopicById(req.params.topicId) if (!topic || topic.id === 'freeform') return res.status(404).json({ error: 'not_found' }) await unfavoriteTopic({ userId: req.session.userId, topicId: topic.id }) const topics = await listTopics(req.session.userId) @@ -27,8 +27,8 @@ router.delete('/:gameId/favorite', requireAuth, async (req, res) => { res.json({ game: updated, topic: updated }) }) -router.get('/:gameId', async (req, res) => { - const detail = await getTopicDetail(req.params.gameId) +router.get('/:topicId', async (req, res) => { + const detail = await getTopicDetail(req.params.topicId) if (!detail) return res.status(404).json({ error: 'not_found' }) if (!detail.topic.isPublic && !req.session?.isAdmin) return res.status(404).json({ error: 'not_found' }) res.json({ game: detail.topic, topic: detail.topic, items: detail.items }) diff --git a/docs/history.md b/docs/history.md index df73690..f22c628 100644 --- a/docs/history.md +++ b/docs/history.md @@ -1,5 +1,9 @@ # 의사결정 이력 +## 2026-04-02 v1.4.22 +- 내부 함수명과 export를 정리한 뒤에도 라우트 파일명이 계속 `games.js`로 남아 있으면 마지막까지 개념 충돌을 남기게 되므로, 공개 주제 라우트 파일명도 실제 의미에 맞게 `topics.js`로 옮기는 편이 맞다고 판단했다. +- `/api/games` 호환 경로는 유지하더라도, 서버 내부 구현만큼은 `topic` 기준 param 이름과 파일 이름으로 정리해 두는 편이 이후 레거시 제거를 훨씬 더 쉽게 만든다고 정리했다. + ## 2026-04-02 v1.4.21 - 백엔드에서 `topic/template` 응답을 내보내더라도 프런트가 계속 `game` 키만 읽으면 호환 레이어가 끝나지 않으므로, 이번 단계부터는 실제 사용자 화면과 관리자 저장 흐름도 새 키를 우선 읽게 맞추는 편이 맞다고 판단했다. - 이 구간은 외부 API를 끊는 작업이 아니라 “프런트가 새 의미를 먼저 받아들이는 단계”이므로, 기존 `game` 키는 fallback으로만 남겨 두고 단계적으로 걷어내는 편이 가장 안전하다고 정리했다. diff --git a/docs/todo.md b/docs/todo.md index a87f7ef..fce5d21 100644 --- a/docs/todo.md +++ b/docs/todo.md @@ -1,6 +1,8 @@ # 할 일 및 이슈 ## 단기 확인 +- `v1.4.22`에서 공개 주제 라우트 파일을 `topics.js`로 옮겼으므로, 실제 서버 재기동 후 `/api/topics`와 `/api/games` 호환 경로가 모두 정상 응답하는지 한 번 더 QA한다. +- 다음 단계에서는 응답의 `game`, `gameId`, `gameName` 호환 키를 실제로 어느 범위까지 제거할지, 그리고 관리자/티어표 저장 payload에서 남은 `gameId` 입력 호환을 어디까지 유지할지 최종 결정한다. - `v1.4.21`에서 홈/주제 상세/에디터/나의 티어표/즐겨찾기/검색 결과/관리자 템플릿 생성이 `topic/template` 응답 키를 우선 읽도록 바뀌었으므로, 실제 브라우저에서 즐겨찾기 토글과 에디터 이동, 관리자 신규 템플릿 생성이 모두 정상인지 한 번 더 QA한다. - 다음 단계에서는 실제 응답의 `game`, `gameId`, `gameName` 호환 키를 어디까지 남길지, 그리고 `/api/games` 호환 경로와 `games.js` 파일명을 언제 걷어낼지 최종 범위를 정한다. - `v1.4.20`에서 백엔드 `db` export와 공개/관리자 라우트 내부 이름을 `topic/template` 기준으로 정리했으므로, 실제 브라우저와 관리자 화면에서 주제 목록/즐겨찾기/템플릿 생성/요청 반영 흐름이 모두 정상인지 한 번 더 QA한다. diff --git a/docs/update.md b/docs/update.md index a33dc46..db769a0 100644 --- a/docs/update.md +++ b/docs/update.md @@ -1,5 +1,9 @@ # 업데이트 로그 +## 2026-04-02 v1.4.22 +- 백엔드 공개 주제 라우트 파일을 [topics.js](/Users/bicute/Desktop/zenn.dev/tier-cursor/backend/src/routes/topics.js)로 옮기고, 진입점도 이 이름으로 읽히게 정리했다. 이제 서버 코드에서 `games.js` 파일명이 남아 있던 마지막 큰 표면도 실제 의미에 더 가깝게 맞춰졌다. +- 공개 주제 라우트의 path 파라미터도 `:topicId` 기준으로 읽히게 바꿔, 내부 구현에서 더 이상 `req.params.gameId`를 기본 전제로 보지 않도록 정리했다. + ## 2026-04-02 v1.4.21 - 프런트의 실제 소비 지점도 `topic/template` 응답 키를 우선 읽도록 옮겼다. 홈의 즐겨찾기 토글, 주제 상세 헤더, 티어표 편집기 템플릿 로딩, 나의 티어표/즐겨찾기/검색 결과의 에디터 이동이 이제 `topic`, `topicId`, `template`를 먼저 사용한다. - 관리자 템플릿 공개 상태 저장과 신규 템플릿 생성 흐름도 `data.template`를 우선 읽고, 기존 `data.game`은 fallback으로만 남겨 프런트와 백엔드의 의미 이름이 한 단계 더 가까워지게 맞췄다.