릴리스: v1.4.25 topic 응답/요청 키 정리

This commit is contained in:
2026-04-02 20:51:03 +09:00
parent 257d50f9c5
commit 932b4e35a7
20 changed files with 188 additions and 199 deletions

View File

@@ -61,7 +61,6 @@ const thumbnailUpload = createMemoryUpload(multer, { fileSize: 8 * 1024 * 1024 }
const templateRequestSchema = z.object({
type: z.enum(['create', 'update']),
sourceTierListId: z.string().max(64).optional().default(''),
gameId: z.string().min(1).max(120).optional(),
topicId: z.string().min(1).max(120).optional(),
requestTitle: z.string().trim().min(1).max(120),
requestDescription: z.string().trim().min(1).max(1000),
@@ -74,7 +73,7 @@ const templateRequestSchema = z.object({
name: z.string().min(1).max(16),
itemIds: z.array(z.string()).optional().default([]),
}).passthrough().superRefine((value, ctx) => {
if (!(value.topicId || value.gameId)) {
if (!value.topicId) {
ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'topicId_required', path: ['topicId'] })
}
})
@@ -91,7 +90,6 @@ const templateRequestSchema = z.object({
const tierListUpsertSchema = z.object({
id: z.string().optional(),
gameId: z.string().min(1).optional(),
topicId: z.string().min(1).optional(),
title: z.string().min(1).max(120),
thumbnailSrc: z.string().max(255).optional().default(''),
@@ -118,13 +116,13 @@ const tierListUpsertSchema = z.object({
})
),
}).superRefine((value, ctx) => {
if (!(value.topicId || value.gameId)) {
if (!value.topicId) {
ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'topicId_required', path: ['topicId'] })
}
})
router.get('/public', async (req, res) => {
const topicId = typeof req.query.topicId === 'string' ? req.query.topicId : req.query.gameId
const topicId = typeof req.query.topicId === 'string' ? req.query.topicId : ''
const queryText = typeof req.query.q === 'string' ? req.query.q : ''
const lists = await listPublicTierLists(topicId, req.session?.userId || '', queryText)
res.json({ tierLists: lists })
@@ -236,7 +234,7 @@ router.post('/template-request', requireAuth, async (req, res) => {
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const payload = parsed.data
const topicId = payload.topicId || payload.gameId
const topicId = payload.topicId
const normalizedBoardItems = payload.boardItems.map(normalizePoolItem)
const customItems = normalizedBoardItems.filter((item) => item?.origin === 'custom')
if (!customItems.length) return res.status(400).json({ error: 'custom_items_required' })
@@ -285,7 +283,7 @@ router.post('/', requireAuth, async (req, res) => {
const parsed = tierListUpsertSchema.safeParse(req.body)
if (!parsed.success) return res.status(400).json({ error: 'bad_request' })
const payload = parsed.data
const topicId = payload.topicId || payload.gameId
const topicId = payload.topicId
const normalizedPool = payload.pool.map(normalizePoolItem)
let existing = null
@@ -296,7 +294,7 @@ router.post('/', requireAuth, async (req, res) => {
const updated = await saveTierList({
id: existing.id,
authorId: existing.authorId,
topicId: existing.topicId || existing.gameId,
topicId: existing.topicId,
title: payload.title,
thumbnailSrc: payload.thumbnailSrc || '',
description: payload.description || '',