25 lines
761 B
JavaScript
25 lines
761 B
JavaScript
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
|
|
})
|