릴리스: v1.4.24 topic/template 응답 키 축소
This commit is contained in:
@@ -132,7 +132,7 @@ router.post(['/games', '/templates'], requireAdmin, async (req, res) => {
|
||||
await updateTopicThumbnail(template.id, copiedThumb)
|
||||
}
|
||||
const savedTemplate = await findTopicById(template.id)
|
||||
res.json({ game: savedTemplate, template: savedTemplate })
|
||||
res.json({ template: savedTemplate })
|
||||
})
|
||||
|
||||
router.patch(['/games/:gameId', '/templates/:templateId'], requireAdmin, async (req, res) => {
|
||||
@@ -147,7 +147,7 @@ router.patch(['/games/:gameId', '/templates/:templateId'], requireAdmin, async (
|
||||
if (!template) return res.status(404).json({ error: 'not_found' })
|
||||
|
||||
const updated = await updateTopicVisibility(template.id, parsed.data.isPublic)
|
||||
res.json({ game: updated, template: updated })
|
||||
res.json({ template: updated })
|
||||
})
|
||||
|
||||
router.patch(['/games/display-order', '/templates/display-order'], requireAdmin, async (req, res) => {
|
||||
@@ -195,7 +195,7 @@ router.post(['/games/:gameId/thumbnail', '/templates/:templateId/thumbnail'], re
|
||||
})
|
||||
|
||||
const updated = await updateTopicThumbnail(templateId, optimized.src)
|
||||
res.json({ game: updated, template: updated })
|
||||
res.json({ template: updated })
|
||||
})
|
||||
|
||||
router.post(['/games/:gameId/images', '/templates/:templateId/images'], requireAdmin, upload.array('images', 50), async (req, res) => {
|
||||
|
||||
@@ -6,7 +6,7 @@ const router = express.Router()
|
||||
|
||||
router.get('/', async (req, res) => {
|
||||
const topics = await listTopics(req.session?.userId || '', { includePrivate: !!req.session?.isAdmin })
|
||||
res.json({ games: topics, topics })
|
||||
res.json({ topics })
|
||||
})
|
||||
|
||||
router.post('/:topicId/favorite', requireAuth, async (req, res) => {
|
||||
@@ -15,7 +15,7 @@ router.post('/:topicId/favorite', requireAuth, async (req, res) => {
|
||||
await favoriteTopic({ userId: req.session.userId, topicId: topic.id })
|
||||
const topics = await listTopics(req.session.userId)
|
||||
const updated = topics.find((entry) => entry.id === topic.id) || { ...topic, isFavorited: true }
|
||||
res.json({ game: updated, topic: updated })
|
||||
res.json({ topic: updated })
|
||||
})
|
||||
|
||||
router.delete('/:topicId/favorite', requireAuth, async (req, res) => {
|
||||
@@ -24,14 +24,14 @@ router.delete('/:topicId/favorite', requireAuth, async (req, res) => {
|
||||
await unfavoriteTopic({ userId: req.session.userId, topicId: topic.id })
|
||||
const topics = await listTopics(req.session.userId)
|
||||
const updated = topics.find((entry) => entry.id === topic.id) || { ...topic, isFavorited: false }
|
||||
res.json({ game: updated, topic: updated })
|
||||
res.json({ topic: updated })
|
||||
})
|
||||
|
||||
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 })
|
||||
res.json({ topic: detail.topic, items: detail.items })
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
|
||||
Reference in New Issue
Block a user