관리자 글 링크 참조 확인 추가
This commit is contained in:
24
server/routes/admin/api/posts/[id]/references.get.js
Normal file
24
server/routes/admin/api/posts/[id]/references.get.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createError, getRouterParam } from 'h3'
|
||||
import { requireAdminSession } from '../../../../../utils/admin-auth'
|
||||
import { listAdminPostReferences } from '../../../../../repositories/content-repository'
|
||||
|
||||
/**
|
||||
* 관리자 게시물 참조 목록 API
|
||||
* @param {import('h3').H3Event} event - 요청 이벤트
|
||||
* @returns {Promise<{ target: { id: string, title: string, slug: string }, posts: Array }>} 참조 목록
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAdminSession(event)
|
||||
|
||||
const id = getRouterParam(event, 'id')
|
||||
const references = await listAdminPostReferences(id)
|
||||
|
||||
if (!references) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
message: '게시물을 찾을 수 없습니다.'
|
||||
})
|
||||
}
|
||||
|
||||
return references
|
||||
})
|
||||
Reference in New Issue
Block a user