Compare commits

...

3 Commits

16 changed files with 131 additions and 72 deletions

View File

@@ -80,6 +80,7 @@ app.use(async (req, res, next) => {
app.use('/api/auth', authRoutes) app.use('/api/auth', authRoutes)
app.use('/api/games', gamesRoutes) app.use('/api/games', gamesRoutes)
app.use('/api/topics', gamesRoutes)
app.use('/api/tierlists', tierListsRoutes) app.use('/api/tierlists', tierListsRoutes)
app.use('/api/admin', adminRoutes) app.use('/api/admin', adminRoutes)

View File

@@ -54,6 +54,10 @@ const { createMemoryUpload, writeOptimizedImage, getImageOptimizationQueueState
const router = express.Router() const router = express.Router()
function getTemplateIdParam(req) {
return req.params.templateId || req.params.gameId || ''
}
function buildUploadFilename(file) { function buildUploadFilename(file) {
const ext = path.extname(file.originalname || '').toLowerCase() const ext = path.extname(file.originalname || '').toLowerCase()
const safeExt = ext && /^[.a-z0-9]+$/.test(ext) ? ext : '' const safeExt = ext && /^[.a-z0-9]+$/.test(ext) ? ext : ''
@@ -110,7 +114,7 @@ function canManageAdminRole(actingUser, primaryAdmin) {
return !!actingUser?.isAdmin && primaryAdmin?.id === actingUser.id return !!actingUser?.isAdmin && primaryAdmin?.id === actingUser.id
} }
router.post('/games', requireAdmin, async (req, res) => { router.post(['/games', '/templates'], requireAdmin, async (req, res) => {
const schema = z.object({ const schema = z.object({
id: z.string().min(1), id: z.string().min(1),
name: z.string().min(1).max(60), name: z.string().min(1).max(60),
@@ -126,24 +130,26 @@ router.post('/games', requireAdmin, async (req, res) => {
const copiedThumb = await copyUploadIntoGameAsset(parsed.data.thumbnailSrc) const copiedThumb = await copyUploadIntoGameAsset(parsed.data.thumbnailSrc)
await updateGameThumbnail(game.id, copiedThumb) await updateGameThumbnail(game.id, copiedThumb)
} }
res.json({ game: await findGameById(game.id) }) const template = await findGameById(game.id)
res.json({ game: template, template })
}) })
router.patch('/games/:gameId', requireAdmin, async (req, res) => { router.patch(['/games/:gameId', '/templates/:templateId'], requireAdmin, async (req, res) => {
const schema = z.object({ const schema = z.object({
isPublic: z.boolean(), isPublic: z.boolean(),
}) })
const parsed = schema.safeParse(req.body) const parsed = schema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' }) if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const game = await findGameById(req.params.gameId) const templateId = getTemplateIdParam(req)
const game = await findGameById(templateId)
if (!game) return res.status(404).json({ error: 'not_found' }) if (!game) return res.status(404).json({ error: 'not_found' })
const updated = await updateGameVisibility(game.id, parsed.data.isPublic) const updated = await updateGameVisibility(game.id, parsed.data.isPublic)
res.json({ game: updated }) res.json({ game: updated, template: updated })
}) })
router.patch('/games/display-order', requireAdmin, async (req, res) => { router.patch(['/games/display-order', '/templates/display-order'], requireAdmin, async (req, res) => {
const schema = z.object({ const schema = z.object({
gameIds: z.array(z.string().min(1)).max(50), gameIds: z.array(z.string().min(1)).max(50),
}) })
@@ -154,26 +160,28 @@ router.patch('/games/display-order', requireAdmin, async (req, res) => {
const validGameIds = new Set(games.map((game) => game.id)) const validGameIds = new Set(games.map((game) => game.id))
const filteredIds = parsed.data.gameIds.filter((gameId) => validGameIds.has(gameId)) const filteredIds = parsed.data.gameIds.filter((gameId) => validGameIds.has(gameId))
const updatedGames = await updateGameDisplayOrder(filteredIds) const updatedGames = await updateGameDisplayOrder(filteredIds)
res.json({ games: updatedGames }) res.json({ games: updatedGames, templates: updatedGames })
}) })
router.patch('/games/:gameId/items/display-order', requireAdmin, async (req, res) => { router.patch(['/games/:gameId/items/display-order', '/templates/:templateId/items/display-order'], requireAdmin, async (req, res) => {
const schema = z.object({ const schema = z.object({
itemIds: z.array(z.string().min(1)).min(1), itemIds: z.array(z.string().min(1)).min(1),
}) })
const parsed = schema.safeParse(req.body) const parsed = schema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' }) if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const game = await findGameById(req.params.gameId) const templateId = getTemplateIdParam(req)
const game = await findGameById(templateId)
if (!game) return res.status(404).json({ error: 'not_found' }) if (!game) return res.status(404).json({ error: 'not_found' })
const items = await updateGameItemDisplayOrder(game.id, parsed.data.itemIds) const items = await updateGameItemDisplayOrder(game.id, parsed.data.itemIds)
res.json({ items }) res.json({ items })
}) })
router.post('/games/:gameId/thumbnail', requireAdmin, upload.single('thumbnail'), async (req, res) => { router.post(['/games/:gameId/thumbnail', '/templates/:templateId/thumbnail'], requireAdmin, upload.single('thumbnail'), async (req, res) => {
if (!req.file) return res.status(400).json({ error: 'file_required' }) if (!req.file) return res.status(400).json({ error: 'file_required' })
const game = await findGameById(req.params.gameId) const templateId = getTemplateIdParam(req)
const game = await findGameById(templateId)
if (!game) return res.status(404).json({ error: 'not_found' }) if (!game) return res.status(404).json({ error: 'not_found' })
const optimized = await writeOptimizedImage({ const optimized = await writeOptimizedImage({
@@ -185,14 +193,15 @@ router.post('/games/:gameId/thumbnail', requireAdmin, upload.single('thumbnail')
quality: 84, quality: 84,
}) })
const updated = await updateGameThumbnail(req.params.gameId, optimized.src) const updated = await updateGameThumbnail(templateId, optimized.src)
res.json({ game: updated }) res.json({ game: updated, template: updated })
}) })
router.post('/games/:gameId/images', requireAdmin, upload.array('images', 50), async (req, res) => { router.post(['/games/:gameId/images', '/templates/:templateId/images'], requireAdmin, upload.array('images', 50), async (req, res) => {
const files = Array.isArray(req.files) ? req.files : [] const files = Array.isArray(req.files) ? req.files : []
if (!files.length) return res.status(400).json({ error: 'file_required' }) if (!files.length) return res.status(400).json({ error: 'file_required' })
const game = await findGameById(req.params.gameId) const templateId = getTemplateIdParam(req)
const game = await findGameById(templateId)
if (!game) return res.status(404).json({ error: 'not_found' }) if (!game) return res.status(404).json({ error: 'not_found' })
const labelsRaw = req.body?.labels const labelsRaw = req.body?.labels
@@ -223,19 +232,19 @@ router.post('/games/:gameId/images', requireAdmin, upload.array('images', 50), a
res.json({ item: items[0], items }) res.json({ item: items[0], items })
}) })
router.delete('/games/:gameId/items/:itemId', requireAdmin, async (req, res) => { router.delete(['/games/:gameId/items/:itemId', '/templates/:templateId/items/:itemId'], requireAdmin, async (req, res) => {
const game = await findGameById(req.params.gameId) const game = await findGameById(getTemplateIdParam(req))
if (!game) return res.status(404).json({ error: 'not_found' }) if (!game) return res.status(404).json({ error: 'not_found' })
await deleteGameItem(req.params.itemId) await deleteGameItem(req.params.itemId)
res.json({ ok: true }) res.json({ ok: true })
}) })
router.patch('/games/:gameId/items/:itemId', requireAdmin, async (req, res) => { router.patch(['/games/:gameId/items/:itemId', '/templates/:templateId/items/:itemId'], requireAdmin, async (req, res) => {
const schema = z.object({ label: z.string().trim().min(1).max(60) }) const schema = z.object({ label: z.string().trim().min(1).max(60) })
const parsed = schema.safeParse(req.body) const parsed = schema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' }) if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const game = await findGameById(req.params.gameId) const game = await findGameById(getTemplateIdParam(req))
if (!game) return res.status(404).json({ error: 'not_found' }) if (!game) return res.status(404).json({ error: 'not_found' })
const updated = await updateGameItemLabel(req.params.itemId, parsed.data.label) const updated = await updateGameItemLabel(req.params.itemId, parsed.data.label)
@@ -243,10 +252,11 @@ router.patch('/games/:gameId/items/:itemId', requireAdmin, async (req, res) => {
res.json({ item: updated }) res.json({ item: updated })
}) })
router.delete('/games/:gameId', requireAdmin, async (req, res) => { router.delete(['/games/:gameId', '/templates/:templateId'], requireAdmin, async (req, res) => {
const game = await findGameById(req.params.gameId) const templateId = getTemplateIdParam(req)
const game = await findGameById(templateId)
if (!game) return res.status(404).json({ error: 'not_found' }) if (!game) return res.status(404).json({ error: 'not_found' })
await deleteGame(req.params.gameId) await deleteGame(templateId)
res.json({ ok: true }) res.json({ ok: true })
}) })

View File

@@ -6,7 +6,7 @@ const router = express.Router()
router.get('/', async (req, res) => { router.get('/', async (req, res) => {
const games = await listGames(req.session?.userId || '', { includePrivate: !!req.session?.isAdmin }) const games = await listGames(req.session?.userId || '', { includePrivate: !!req.session?.isAdmin })
res.json({ games }) res.json({ games, topics: games })
}) })
router.post('/:gameId/favorite', requireAuth, async (req, res) => { router.post('/:gameId/favorite', requireAuth, async (req, res) => {
@@ -15,7 +15,7 @@ router.post('/:gameId/favorite', requireAuth, async (req, res) => {
await favoriteGame({ userId: req.session.userId, gameId: game.id }) await favoriteGame({ userId: req.session.userId, gameId: game.id })
const games = await listGames(req.session.userId) const games = await listGames(req.session.userId)
const updated = games.find((entry) => entry.id === game.id) || { ...game, isFavorited: true } const updated = games.find((entry) => entry.id === game.id) || { ...game, isFavorited: true }
res.json({ game: updated }) res.json({ game: updated, topic: updated })
}) })
router.delete('/:gameId/favorite', requireAuth, async (req, res) => { router.delete('/:gameId/favorite', requireAuth, async (req, res) => {
@@ -24,14 +24,14 @@ router.delete('/:gameId/favorite', requireAuth, async (req, res) => {
await unfavoriteGame({ userId: req.session.userId, gameId: game.id }) await unfavoriteGame({ userId: req.session.userId, gameId: game.id })
const games = await listGames(req.session.userId) const games = await listGames(req.session.userId)
const updated = games.find((entry) => entry.id === game.id) || { ...game, isFavorited: false } const updated = games.find((entry) => entry.id === game.id) || { ...game, isFavorited: false }
res.json({ game: updated }) res.json({ game: updated, topic: updated })
}) })
router.get('/:gameId', async (req, res) => { router.get('/:gameId', async (req, res) => {
const detail = await getGameDetail(req.params.gameId) const detail = await getGameDetail(req.params.gameId)
if (!detail) return res.status(404).json({ error: 'not_found' }) if (!detail) return res.status(404).json({ error: 'not_found' })
if (!detail.game.isPublic && !req.session?.isAdmin) return res.status(404).json({ error: 'not_found' }) if (!detail.game.isPublic && !req.session?.isAdmin) return res.status(404).json({ error: 'not_found' })
res.json({ game: detail.game, items: detail.items }) res.json({ game: detail.game, topic: detail.game, items: detail.items })
}) })
module.exports = router module.exports = router

View File

@@ -1,5 +1,14 @@
# 의사결정 이력 # 의사결정 이력
## 2026-04-02 v1.4.12
- 프런트 이름만 바꾸는 단계가 끝난 뒤에는, 백엔드도 새 `/api/topics`, `/api/admin/templates` 경로를 열고 기존 `/games`는 호환용으로 남기는 점진 전환이 가장 안전하다고 판단했다.
## 2026-04-02 v1.4.11
- 백엔드 `/api/games` 경로를 바로 바꾸기보다, 프런트 API 객체에서 먼저 `topic/template` 의미 이름을 제공하고 호출부를 옮기는 편이 위험이 훨씬 낮다고 판단했다.
## 2026-04-02 v1.4.10
- 사용자 주소는 이미 `/topics`로 옮기기 시작했으므로, 라우트 이름과 기본 파라미터도 `topicHub / topicId` 기준으로 맞추고 기존 `gameId`는 호환 fallback으로만 남기는 편이 더 자연스럽다고 판단했다.
## 2026-04-02 v1.4.9 ## 2026-04-02 v1.4.9
- 경로 전환은 화면마다 문자열을 직접 고치는 방식보다, 공용 경로 헬퍼를 먼저 세워 주제·에디터·로그인 리다이렉트 흐름을 한 기준으로 묶는 편이 이후 리네이밍 비용을 훨씬 줄인다고 판단했다. - 경로 전환은 화면마다 문자열을 직접 고치는 방식보다, 공용 경로 헬퍼를 먼저 세워 주제·에디터·로그인 리다이렉트 흐름을 한 기준으로 묶는 편이 이후 리네이밍 비용을 훨씬 줄인다고 판단했다.

View File

@@ -1,6 +1,12 @@
# 할 일 및 이슈 # 할 일 및 이슈
## 단기 확인 ## 단기 확인
- `/api/topics`, `/api/admin/templates` alias를 연 뒤 프런트 호출도 새 경로로 옮겼으므로, 실제 브라우저에서 주제 목록/즐겨찾기/주제 상세/관리자 템플릿 관리가 모두 같은 세션으로 자연스럽게 동작하는지 한 번 더 QA한다.
- 다음 마지막 단계에서는 DB 스키마와 백엔드 함수/변수명까지 실제로 옮길지, 아니면 현재 alias 구조를 안정판으로 남길지 최종 결정한다.
- 프런트 API 호출부는 `topic/template` 의미 이름으로 옮겼으므로, 다음 단계에서는 `api.js` 안의 레거시 alias를 얼마나 더 유지할지와 백엔드 API 경로를 실제로 바꿀지 범위를 정한다.
- 관리자 템플릿/주제 화면과 홈·에디터·즐겨찾기에서 새 API 이름층으로 바뀐 뒤에도 저장, 즐겨찾기, 템플릿 생성, 아이템 정렬 흐름이 자연스러운지 한 번 더 QA한다.
- `topicHub / topicId`를 기본 라우트 기준으로 세웠으므로, 기존 `/games/...` 북마크와 새 `/topics/...` 주소 양쪽에서 주제 상세와 에디터 진입이 모두 자연스럽게 이어지는지 한 번 더 QA한다.
- 다음 단계에서는 `api.getGame`, `listGames`, `favoriteGame`처럼 남아 있는 프런트 API 이름을 어느 수준까지 `topic/template` 의미로 감쌀지 정리한다.
- 경로 헬퍼를 사용자 주요 화면에 연결했으므로, 로그인 리다이렉트·공유 프리뷰·복사본 이동·주제 복귀 흐름이 실제 브라우저에서 모두 같은 주소 체계로 자연스럽게 이어지는지 한 번 더 QA한다. - 경로 헬퍼를 사용자 주요 화면에 연결했으므로, 로그인 리다이렉트·공유 프리뷰·복사본 이동·주제 복귀 흐름이 실제 브라우저에서 모두 같은 주소 체계로 자연스럽게 이어지는지 한 번 더 QA한다.
- 다음 단계에서는 `router/index.js``gameHub`, `route.params.gameId`, `api.getGame`처럼 남아 있는 프런트 내부 이름도 어디까지 `topic/template` 의미로 감쌀지 범위를 더 좁힌다. - 다음 단계에서는 `router/index.js``gameHub`, `route.params.gameId`, `api.getGame`처럼 남아 있는 프런트 내부 이름도 어디까지 `topic/template` 의미로 감쌀지 범위를 더 좁힌다.
- 주제 상세 화면 제목은 ID fallback 대신 로딩 문구를 쓰도록 바꿨으므로, 직접 진입·뒤로가기·다른 주제로 연속 이동할 때 헤더가 깜빡이거나 이전 제목을 잠깐 유지하지 않는지 한 번 더 QA한다. - 주제 상세 화면 제목은 ID fallback 대신 로딩 문구를 쓰도록 바꿨으므로, 직접 진입·뒤로가기·다른 주제로 연속 이동할 때 헤더가 깜빡이거나 이전 제목을 잠깐 유지하지 않는지 한 번 더 QA한다.

View File

@@ -1,5 +1,17 @@
# 업데이트 로그 # 업데이트 로그
## 2026-04-02 v1.4.12
- 백엔드에 `/api/topics``/api/admin/templates` alias 경로를 추가하고, 주제/템플릿 응답도 `topic/topics`, `template/templates` 키를 함께 내려주도록 정리했다.
- 프런트의 새 의미 이름은 이제 실제로도 `/api/topics`, `/api/admin/templates`를 타도록 연결해, 경로 이름과 호출 이름이 다시 어긋나지 않게 맞췄다.
## 2026-04-02 v1.4.11
- 프런트 API 이름층을 한 단계 더 정리해 `listTopics / getTopic / favoriteTopic`, `updateAdminTemplate*`, `searchPublicTierListsByTopic` 같은 의미 기반 이름을 추가하고 실제 호출부도 이 기준으로 옮겼다.
- 백엔드 경로와 응답 구조는 그대로 유지한 채 프런트에서 읽는 이름만 먼저 바꿔, 다음 단계의 API/모델 리네이밍 부담을 더 줄였다.
## 2026-04-02 v1.4.10
- 주제 상세 라우트 이름을 `topicHub`로, 기본 경로 파라미터를 `topicId`로 바꾸고 기존 `gameId` 주소는 alias로 유지했다.
- 앱 셸, 주제 상세, 티어표 편집기는 이제 내부에서 `topicId`를 우선 읽고, 레거시 주소로 들어온 경우에만 `gameId` fallback을 쓰도록 정리했다.
## 2026-04-02 v1.4.9 ## 2026-04-02 v1.4.9
- `frontend/src/lib/paths.js`를 추가해 주제 진입, 에디터 이동, 로그인 리다이렉트, 공유 프리뷰 주소 같은 사용자 표면 경로를 공용 함수로 모았다. - `frontend/src/lib/paths.js`를 추가해 주제 진입, 에디터 이동, 로그인 리다이렉트, 공유 프리뷰 주소 같은 사용자 표면 경로를 공용 함수로 모았다.
- 홈, 주제 상세, 나의 티어표, 즐겨찾기, 검색 결과, 로그인, 설정, 관리자 미리보기, 티어표 편집기까지 이 경로 헬퍼를 쓰도록 바꿔 이후 `topics` 전환을 더 안전하게 이어갈 수 있는 기반을 만들었다. - 홈, 주제 상세, 나의 티어표, 즐겨찾기, 검색 결과, 로그인, 설정, 관리자 미리보기, 티어표 편집기까지 이 경로 헬퍼를 쓰도록 바꿔 이후 `topics` 전환을 더 안전하게 이어갈 수 있는 기반을 만들었다.

View File

@@ -23,6 +23,7 @@ const router = useRouter()
const auth = useAuthStore() const auth = useAuthStore()
const { toasts, dismissToast } = useToast() const { toasts, dismissToast } = useToast()
const RIGHT_RAIL_COPYRIGHT_URL = 'https://zenn.town/@murabito' const RIGHT_RAIL_COPYRIGHT_URL = 'https://zenn.town/@murabito'
const currentTopicId = computed(() => route.params.topicId || route.params.gameId || '')
const leftRailCollapsed = ref(false) const leftRailCollapsed = ref(false)
const rightRailOpen = ref(true) const rightRailOpen = ref(true)
@@ -135,15 +136,15 @@ const isGuideNextDisabled = computed(() => guideStepIndex.value >= guideSteps.le
const isLightTheme = computed(() => themeMode.value === 'light') const isLightTheme = computed(() => themeMode.value === 'light')
const themeToggleLabel = computed(() => (isLightTheme.value ? '다크 모드' : '라이트 모드')) const themeToggleLabel = computed(() => (isLightTheme.value ? '다크 모드' : '라이트 모드'))
const showSettingsThemePanel = computed(() => false && route.name === 'profile') const showSettingsThemePanel = computed(() => false && route.name === 'profile')
const showTopicViewToggle = computed(() => route.name === 'gameHub') const showTopicViewToggle = computed(() => route.name === 'topicHub')
const topicViewMode = computed(() => (route.query.view === 'list' ? 'list' : 'grid')) const topicViewMode = computed(() => (route.query.view === 'list' ? 'list' : 'grid'))
const leftBottomPrimaryAction = computed(() => { const leftBottomPrimaryAction = computed(() => {
if (!authReady.value) return null if (!authReady.value) return null
if (route.name === 'home' && auth.user) { if (route.name === 'home' && auth.user) {
return { label: '커스텀 티어표 만들기', to: editorNewPath('freeform'), iconSrc: iconDashboardCustomize } return { label: '커스텀 티어표 만들기', to: editorNewPath('freeform'), iconSrc: iconDashboardCustomize }
} }
if (route.name === 'gameHub') { if (route.name === 'topicHub') {
const target = editorNewPath(route.params.gameId) const target = editorNewPath(currentTopicId.value)
return { label: '새 티어표 만들기', to: auth.user ? target : loginPath(target), iconSrc: iconAddNotes } return { label: '새 티어표 만들기', to: auth.user ? target : loginPath(target), iconSrc: iconAddNotes }
} }
return null return null
@@ -162,7 +163,7 @@ const routeMeta = computed(() => {
}, },
} }
} }
if (route.name === 'gameHub') { if (route.name === 'topicHub') {
return { return {
title: '주제 티어표', title: '주제 티어표',
subtitle: '주제별 공개 티어표 탐색', subtitle: '주제별 공개 티어표 탐색',
@@ -170,7 +171,7 @@ const routeMeta = computed(() => {
contextText: auth.user ? '이 주제의 새 티어표를 만들거나 기존 공개 티어표를 확인할 수 있어요.' : '로그인 후 새 티어표를 만들 수 있어요.', contextText: auth.user ? '이 주제의 새 티어표를 만들거나 기존 공개 티어표를 확인할 수 있어요.' : '로그인 후 새 티어표를 만들 수 있어요.',
actionLabel: auth.user ? '새 티어표 만들기' : '로그인하러 가기', actionLabel: auth.user ? '새 티어표 만들기' : '로그인하러 가기',
action: () => { action: () => {
const target = editorNewPath(route.params.gameId) const target = editorNewPath(currentTopicId.value)
router.push(auth.user ? target : loginPath(target)) router.push(auth.user ? target : loginPath(target))
}, },
} }
@@ -346,7 +347,7 @@ function toggleRightRail() {
} }
function setTopicViewMode(mode) { function setTopicViewMode(mode) {
if (route.name !== 'gameHub') return if (route.name !== 'topicHub') return
const nextQuery = { ...route.query } const nextQuery = { ...route.query }
if (mode === 'list') nextQuery.view = 'list' if (mode === 'list') nextQuery.view = 'list'
else delete nextQuery.view else delete nextQuery.view

View File

@@ -167,7 +167,7 @@ export function useAdminCustomItems({
try { try {
item.isPromoting = true item.isPromoting = true
await api.promoteAdminCustomItem(item.id, { gameId: customItemModalTargetTemplateId.value }) await api.promoteAdminTemplateItem(item.id, { gameId: customItemModalTargetTemplateId.value })
const targetTemplateName = const targetTemplateName =
templates.value.find((template) => template.id === customItemModalTargetTemplateId.value)?.name || customItemModalTargetTemplateId.value templates.value.find((template) => template.id === customItemModalTargetTemplateId.value)?.name || customItemModalTargetTemplateId.value
if (selectedTemplateId.value === customItemModalTargetTemplateId.value) await loadTemplate() if (selectedTemplateId.value === customItemModalTargetTemplateId.value) await loadTemplate()

View File

@@ -70,7 +70,7 @@ export function useAdminFeaturedGames({
async function saveFeaturedOrder() { async function saveFeaturedOrder() {
resetMessages() resetMessages()
try { try {
const data = await api.updateAdminGameDisplayOrder({ gameIds: featuredTemplateIds.value }) const data = await api.updateAdminTemplateDisplayOrder({ gameIds: featuredTemplateIds.value })
templates.value = data.games || [] templates.value = data.games || []
featuredTemplateIds.value = templates.value featuredTemplateIds.value = templates.value
.filter((template) => template.displayRank != null) .filter((template) => template.displayRank != null)

View File

@@ -131,7 +131,7 @@ export function useAdminGameManager({
try { try {
isGameLoading.value = true isGameLoading.value = true
const data = await api.getGame(selectedTemplateId.value) const data = await api.getTopic(selectedTemplateId.value)
selectedTemplate.value = { selectedTemplate.value = {
...data, ...data,
items: (data.items || []).map((item) => ({ items: (data.items || []).map((item) => ({
@@ -155,7 +155,7 @@ export function useAdminGameManager({
const preserveUploadState = !!options.preserveUploadState const preserveUploadState = !!options.preserveUploadState
resetMessages() resetMessages()
try { try {
const res = await fetch(toApiUrl('/api/admin/games'), { const res = await fetch(toApiUrl('/api/admin/templates'), {
method: 'POST', method: 'POST',
credentials: 'include', credentials: 'include',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
@@ -283,7 +283,7 @@ export function useAdminGameManager({
fd.append('images', entry.file) fd.append('images', entry.file)
fd.append('labels', entry.label.trim()) fd.append('labels', entry.label.trim())
}) })
const res = await fetch(toApiUrl(`/api/admin/games/${encodeURIComponent(selectedTemplateId.value)}/images`), { const res = await fetch(toApiUrl(`/api/admin/templates/${encodeURIComponent(selectedTemplateId.value)}/images`), {
method: 'POST', method: 'POST',
credentials: 'include', credentials: 'include',
body: fd, body: fd,
@@ -336,7 +336,7 @@ export function useAdminGameManager({
if (!selectedTemplateId.value || !selectedTemplate.value?.items?.length) return if (!selectedTemplateId.value || !selectedTemplate.value?.items?.length) return
try { try {
const data = await api.updateAdminGameItemDisplayOrder(selectedTemplateId.value, { const data = await api.updateAdminTemplateItemDisplayOrder(selectedTemplateId.value, {
itemIds: selectedTemplate.value.items.map((item) => item.id), itemIds: selectedTemplate.value.items.map((item) => item.id),
}) })
selectedTemplate.value = { selectedTemplate.value = {

View File

@@ -30,17 +30,17 @@ export const api = {
login: ({ email, password }) => request('/api/auth/login', { method: 'POST', body: { email, password } }), login: ({ email, password }) => request('/api/auth/login', { method: 'POST', body: { email, password } }),
logout: () => request('/api/auth/logout', { method: 'POST' }), logout: () => request('/api/auth/logout', { method: 'POST' }),
listGames: () => request('/api/games'), listTopics: () => request('/api/topics'),
getGame: (gameId) => request(`/api/games/${encodeURIComponent(gameId)}`), getTopic: (topicId) => request(`/api/topics/${encodeURIComponent(topicId)}`),
favoriteGame: (gameId) => request(`/api/games/${encodeURIComponent(gameId)}/favorite`, { method: 'POST' }), favoriteTopic: (topicId) => request(`/api/topics/${encodeURIComponent(topicId)}/favorite`, { method: 'POST' }),
unfavoriteGame: (gameId) => request(`/api/games/${encodeURIComponent(gameId)}/favorite`, { method: 'DELETE' }), unfavoriteTopic: (topicId) => request(`/api/topics/${encodeURIComponent(topicId)}/favorite`, { method: 'DELETE' }),
updateAdminGameDisplayOrder: (payload) => request('/api/admin/games/display-order', { method: 'PATCH', body: payload }), updateAdminTemplateDisplayOrder: (payload) => request('/api/admin/templates/display-order', { method: 'PATCH', body: payload }),
updateAdminGameItemDisplayOrder: (gameId, payload) => updateAdminTemplateItemDisplayOrder: (templateId, payload) =>
request(`/api/admin/games/${encodeURIComponent(gameId)}/items/display-order`, { method: 'PATCH', body: payload }), request(`/api/admin/templates/${encodeURIComponent(templateId)}/items/display-order`, { method: 'PATCH', body: payload }),
updateAdminGame: (gameId, payload) => updateAdminTemplate: (templateId, payload) =>
request(`/api/admin/games/${encodeURIComponent(gameId)}`, { method: 'PATCH', body: payload }), request(`/api/admin/templates/${encodeURIComponent(templateId)}`, { method: 'PATCH', body: payload }),
updateAdminGameItem: (gameId, itemId, payload) => updateAdminTemplateItem: (templateId, itemId, payload) =>
request(`/api/admin/games/${encodeURIComponent(gameId)}/items/${encodeURIComponent(itemId)}`, { method: 'PATCH', body: payload }), request(`/api/admin/templates/${encodeURIComponent(templateId)}/items/${encodeURIComponent(itemId)}`, { method: 'PATCH', body: payload }),
listAdminCustomItems: ({ q = '', page = 1, limit = 50, filter = 'all' } = {}) => listAdminCustomItems: ({ q = '', page = 1, limit = 50, filter = 'all' } = {}) =>
request( request(
`/api/admin/custom-items?q=${encodeURIComponent(q)}&page=${encodeURIComponent(page)}&limit=${encodeURIComponent(limit)}&filter=${encodeURIComponent(filter)}` `/api/admin/custom-items?q=${encodeURIComponent(q)}&page=${encodeURIComponent(page)}&limit=${encodeURIComponent(limit)}&filter=${encodeURIComponent(filter)}`
@@ -66,13 +66,13 @@ export const api = {
cleanupAdminMissingImageReferences: () => request('/api/admin/image-assets/missing/cleanup', { method: 'POST', body: {} }), cleanupAdminMissingImageReferences: () => request('/api/admin/image-assets/missing/cleanup', { method: 'POST', body: {} }),
listAdminUnusedImageAssets: ({ limit = 100, minAgeHours = 24 } = {}) => request(`/api/admin/image-assets/orphans?limit=${encodeURIComponent(limit)}&minAgeHours=${encodeURIComponent(minAgeHours)}`), listAdminUnusedImageAssets: ({ limit = 100, minAgeHours = 24 } = {}) => request(`/api/admin/image-assets/orphans?limit=${encodeURIComponent(limit)}&minAgeHours=${encodeURIComponent(minAgeHours)}`),
cleanupAdminUnusedImageAssets: (payload) => request('/api/admin/image-assets/cleanup', { method: 'POST', body: payload || {} }), cleanupAdminUnusedImageAssets: (payload) => request('/api/admin/image-assets/cleanup', { method: 'POST', body: payload || {} }),
promoteAdminCustomItem: (itemId, payload) => promoteAdminTemplateItem: (itemId, payload) =>
request(`/api/admin/custom-items/${encodeURIComponent(itemId)}/promote`, { method: 'POST', body: payload }), request(`/api/admin/custom-items/${encodeURIComponent(itemId)}/promote`, { method: 'POST', body: payload }),
updateAdminCustomItemLabel: (itemId, payload) => updateAdminCustomItemLabel: (itemId, payload) =>
request(`/api/admin/custom-items/${encodeURIComponent(itemId)}/label`, { method: 'PATCH', body: payload }), request(`/api/admin/custom-items/${encodeURIComponent(itemId)}/label`, { method: 'PATCH', body: payload }),
promoteAdminTierListItems: (tierListId, payload) => promoteAdminTierListItems: (tierListId, payload) =>
request(`/api/admin/tierlists/${encodeURIComponent(tierListId)}/promote-items`, { method: 'POST', body: payload }), request(`/api/admin/tierlists/${encodeURIComponent(tierListId)}/promote-items`, { method: 'POST', body: payload }),
createAdminGameTemplateFromTierList: (tierListId, payload) => createAdminTemplateFromTierList: (tierListId, payload) =>
request(`/api/admin/tierlists/${encodeURIComponent(tierListId)}/create-game-template`, { method: 'POST', body: payload }), request(`/api/admin/tierlists/${encodeURIComponent(tierListId)}/create-game-template`, { method: 'POST', body: payload }),
startAdminTemplateRequestReview: (requestId) => startAdminTemplateRequestReview: (requestId) =>
request(`/api/admin/template-requests/${encodeURIComponent(requestId)}/review`, { method: 'POST', body: {} }), request(`/api/admin/template-requests/${encodeURIComponent(requestId)}/review`, { method: 'POST', body: {} }),
@@ -111,10 +111,10 @@ export const api = {
}, },
deleteAdminUser: (userId) => request(`/api/admin/users/${encodeURIComponent(userId)}`, { method: 'DELETE' }), deleteAdminUser: (userId) => request(`/api/admin/users/${encodeURIComponent(userId)}`, { method: 'DELETE' }),
listPublicTierLists: (gameId) => listPublicTierListsByTopic: (topicId) =>
request(`/api/tierlists/public?gameId=${encodeURIComponent(gameId || '')}`), request(`/api/tierlists/public?gameId=${encodeURIComponent(topicId || '')}`),
searchPublicTierLists: (gameId, q = '') => searchPublicTierListsByTopic: (topicId, q = '') =>
request(`/api/tierlists/public?gameId=${encodeURIComponent(gameId || '')}&q=${encodeURIComponent(q || '')}`), request(`/api/tierlists/public?gameId=${encodeURIComponent(topicId || '')}&q=${encodeURIComponent(q || '')}`),
searchAllPublicTierLists: (q = '') => request(`/api/tierlists/public?q=${encodeURIComponent(q || '')}`), searchAllPublicTierLists: (q = '') => request(`/api/tierlists/public?q=${encodeURIComponent(q || '')}`),
listMyTierLists: () => request('/api/tierlists/me'), listMyTierLists: () => request('/api/tierlists/me'),
listMyFavoriteTierLists: ({ q = '', sort = 'favorited' } = {}) => listMyFavoriteTierLists: ({ q = '', sort = 'favorited' } = {}) =>
@@ -146,4 +146,24 @@ export const api = {
deleteAdminCustomItem: (itemId) => request(`/api/admin/custom-items/${encodeURIComponent(itemId)}`, { method: 'DELETE' }), deleteAdminCustomItem: (itemId) => request(`/api/admin/custom-items/${encodeURIComponent(itemId)}`, { method: 'DELETE' }),
deleteAdminUnusedCustomItems: ({ q = '' } = {}) => deleteAdminUnusedCustomItems: ({ q = '' } = {}) =>
request(`/api/admin/custom-items?q=${encodeURIComponent(q)}`, { method: 'DELETE' }), request(`/api/admin/custom-items?q=${encodeURIComponent(q)}`, { method: 'DELETE' }),
listGames: () => request('/api/games'),
getGame: (gameId) => request(`/api/games/${encodeURIComponent(gameId)}`),
favoriteGame: (gameId) => request(`/api/games/${encodeURIComponent(gameId)}/favorite`, { method: 'POST' }),
unfavoriteGame: (gameId) => request(`/api/games/${encodeURIComponent(gameId)}/favorite`, { method: 'DELETE' }),
updateAdminGameDisplayOrder: (payload) => request('/api/admin/games/display-order', { method: 'PATCH', body: payload }),
updateAdminGameItemDisplayOrder: (gameId, payload) =>
request(`/api/admin/games/${encodeURIComponent(gameId)}/items/display-order`, { method: 'PATCH', body: payload }),
updateAdminGame: (gameId, payload) =>
request(`/api/admin/games/${encodeURIComponent(gameId)}`, { method: 'PATCH', body: payload }),
updateAdminGameItem: (gameId, itemId, payload) =>
request(`/api/admin/games/${encodeURIComponent(gameId)}/items/${encodeURIComponent(itemId)}`, { method: 'PATCH', body: payload }),
promoteAdminCustomItem: (itemId, payload) =>
request(`/api/admin/custom-items/${encodeURIComponent(itemId)}/promote`, { method: 'POST', body: payload }),
createAdminGameTemplateFromTierList: (tierListId, payload) =>
request(`/api/admin/tierlists/${encodeURIComponent(tierListId)}/create-game-template`, { method: 'POST', body: payload }),
listPublicTierLists: (gameId) =>
request(`/api/tierlists/public?gameId=${encodeURIComponent(gameId || '')}`),
searchPublicTierLists: (gameId, q = '') =>
request(`/api/tierlists/public?gameId=${encodeURIComponent(gameId || '')}&q=${encodeURIComponent(q || '')}`),
} }

View File

@@ -16,9 +16,9 @@ export function createRouter() {
history: createWebHistory(), history: createWebHistory(),
routes: [ routes: [
{ path: '/', name: 'home', component: HomeView }, { path: '/', name: 'home', component: HomeView },
{ path: '/topics/:gameId', alias: ['/games/:gameId'], name: 'gameHub', component: GameHubView }, { path: '/topics/:topicId', alias: ['/games/:gameId'], name: 'topicHub', component: GameHubView },
{ path: '/editor/:gameId/new', name: 'newEditor', component: TierEditorView }, { path: '/editor/:topicId/new', alias: ['/editor/:gameId/new'], name: 'newEditor', component: TierEditorView },
{ path: '/editor/:gameId/:tierListId', name: 'editEditor', component: TierEditorView }, { path: '/editor/:topicId/:tierListId', alias: ['/editor/:gameId/:tierListId'], name: 'editEditor', component: TierEditorView },
{ path: '/login', name: 'login', component: LoginView }, { path: '/login', name: 'login', component: LoginView },
{ path: '/me', name: 'me', component: MyTierListsView }, { path: '/me', name: 'me', component: MyTierListsView },
{ path: '/favorites', name: 'favorites', component: FavoriteTierListsView }, { path: '/favorites', name: 'favorites', component: FavoriteTierListsView },

View File

@@ -787,7 +787,7 @@ async function selectAdminTemplate(templateId) {
async function refreshTemplates() { async function refreshTemplates() {
try { try {
const data = await api.listGames() const data = await api.listTopics()
templates.value = data.games || [] templates.value = data.games || []
featuredTemplateIds.value = templates.value featuredTemplateIds.value = templates.value
.filter((template) => template.displayRank != null) .filter((template) => template.displayRank != null)
@@ -1148,7 +1148,7 @@ async function uploadThumbnail() {
try { try {
const fd = new FormData() const fd = new FormData()
fd.append('thumbnail', thumbFile.value) fd.append('thumbnail', thumbFile.value)
const res = await fetch(toApiUrl(`/api/admin/games/${encodeURIComponent(selectedTemplateId.value)}/thumbnail`), { const res = await fetch(toApiUrl(`/api/admin/templates/${encodeURIComponent(selectedTemplateId.value)}/thumbnail`), {
method: 'POST', method: 'POST',
credentials: 'include', credentials: 'include',
body: fd, body: fd,
@@ -1170,7 +1170,7 @@ async function saveTemplateVisibility() {
if (!selectedTemplate.value?.game?.id) return if (!selectedTemplate.value?.game?.id) return
try { try {
gameVisibilitySaving.value = true gameVisibilitySaving.value = true
const data = await api.updateAdminGame(selectedTemplate.value.game.id, { const data = await api.updateAdminTemplate(selectedTemplate.value.game.id, {
isPublic: !!selectedTemplate.value.game.isPublic, isPublic: !!selectedTemplate.value.game.isPublic,
}) })
selectedTemplate.value = { selectedTemplate.value = {
@@ -1217,7 +1217,7 @@ async function removeTemplateItem(itemId) {
resetMessages() resetMessages()
try { try {
const res = await fetch( const res = await fetch(
toApiUrl(`/api/admin/games/${encodeURIComponent(selectedTemplateId.value)}/items/${encodeURIComponent(itemId)}`), toApiUrl(`/api/admin/templates/${encodeURIComponent(selectedTemplateId.value)}/items/${encodeURIComponent(itemId)}`),
{ {
method: 'DELETE', method: 'DELETE',
credentials: 'include', credentials: 'include',
@@ -1244,7 +1244,7 @@ async function saveTemplateItemLabel(item) {
try { try {
item.isSavingLabel = true item.isSavingLabel = true
const data = await api.updateAdminGameItem(selectedTemplateId.value, item.id, { label: nextLabel }) const data = await api.updateAdminTemplateItem(selectedTemplateId.value, item.id, { label: nextLabel })
item.label = data.item.label item.label = data.item.label
item.draftLabel = data.item.label item.draftLabel = data.item.label
success.value = '기본 아이템 이름을 수정했어요.' success.value = '기본 아이템 이름을 수정했어요.'
@@ -1263,7 +1263,7 @@ async function removeTemplate() {
if (!ok) return if (!ok) return
try { try {
const res = await fetch(toApiUrl(`/api/admin/games/${encodeURIComponent(selectedTemplateId.value)}`), { const res = await fetch(toApiUrl(`/api/admin/templates/${encodeURIComponent(selectedTemplateId.value)}`), {
method: 'DELETE', method: 'DELETE',
credentials: 'include', credentials: 'include',
}) })
@@ -1589,7 +1589,7 @@ async function confirmTierListImport() {
return return
} }
const data = await api.createAdminGameTemplateFromTierList(tierList.id, { const data = await api.createAdminTemplateFromTierList(tierList.id, {
gameId: nextGameId, gameId: nextGameId,
name: nextGameName, name: nextGameName,
itemIds, itemIds,

View File

@@ -10,7 +10,7 @@ const route = useRoute()
const router = useRouter() const router = useRouter()
const auth = useAuthStore() const auth = useAuthStore()
const topicId = computed(() => route.params.gameId) const topicId = computed(() => route.params.topicId || route.params.gameId)
const topicName = ref('') const topicName = ref('')
const tierLists = ref([]) const tierLists = ref([])
const error = ref('') const error = ref('')
@@ -54,8 +54,8 @@ async function loadTierLists() {
isTopicLoading.value = true isTopicLoading.value = true
try { try {
const [gameRes, listRes] = await Promise.all([ const [gameRes, listRes] = await Promise.all([
api.getGame(topicId.value), api.getTopic(topicId.value),
api.searchPublicTierLists(topicId.value, query.value), api.searchPublicTierListsByTopic(topicId.value, query.value),
]) ])
topicName.value = gameRes.game?.name || '' topicName.value = gameRes.game?.name || ''
brokenThumbnailIds.value = {} brokenThumbnailIds.value = {}

View File

@@ -36,7 +36,7 @@ const templates = computed(() => {
async function loadTemplates() { async function loadTemplates() {
try { try {
const data = await api.listGames() const data = await api.listTopics()
templateRecords.value = data.games || [] templateRecords.value = data.games || []
} catch (e) { } catch (e) {
error.value = '백엔드에 연결할 수 없어요. backend 서버가 실행 중인지 확인해주세요.' error.value = '백엔드에 연결할 수 없어요. backend 서버가 실행 중인지 확인해주세요.'
@@ -60,7 +60,7 @@ async function toggleFavorite(template, event) {
try { try {
loadingFavoriteId.value = template.id loadingFavoriteId.value = template.id
const res = template.isFavorited ? await api.unfavoriteGame(template.id) : await api.favoriteGame(template.id) const res = template.isFavorited ? await api.unfavoriteTopic(template.id) : await api.favoriteTopic(template.id)
templateRecords.value = templateRecords.value.map((entry) => (entry.id === template.id ? { ...entry, ...res.game } : entry)) templateRecords.value = templateRecords.value.map((entry) => (entry.id === template.id ? { ...entry, ...res.game } : entry))
} catch (e) { } catch (e) {
error.value = '즐겨찾기 변경에 실패했어요.' error.value = '즐겨찾기 변경에 실패했어요.'

View File

@@ -20,7 +20,7 @@ const auth = useAuthStore()
const toast = useToast() const toast = useToast()
const globalRightRailOpen = inject('rightRailOpen', ref(true)) const globalRightRailOpen = inject('rightRailOpen', ref(true))
const localRightRailTarget = inject('localRightRailTarget', '#local-right-rail-root') const localRightRailTarget = inject('localRightRailTarget', '#local-right-rail-root')
const templateId = computed(() => route.params.gameId) const templateId = computed(() => route.params.topicId || route.params.gameId)
const tierListId = computed(() => route.params.tierListId) const tierListId = computed(() => route.params.tierListId)
const previewMode = computed(() => route.query.preview === '1') const previewMode = computed(() => route.query.preview === '1')
const templateName = ref('') const templateName = ref('')
@@ -898,7 +898,7 @@ onMounted(() => {
} }
try { try {
const gameRes = await api.getGame(templateId.value) const gameRes = await api.getTopic(templateId.value)
templateName.value = gameRes.game?.name || templateId.value templateName.value = gameRes.game?.name || templateId.value
const base = (gameRes.items || []).map((img) => ({ const base = (gameRes.items || []).map((img) => ({
id: img.id, id: img.id,