25 lines
829 B
JavaScript
25 lines
829 B
JavaScript
import { createError, readBody } from 'h3'
|
|
import { requireAdminSession } from '../../../utils/admin-auth'
|
|
import { parseAdminNavigationInput } from '../../../utils/admin-navigation-input'
|
|
import { updateNavigationItems } from '../../../repositories/content-repository'
|
|
|
|
/**
|
|
* 관리자 네비게이션 일괄 저장 API
|
|
* @param {import('h3').H3Event} event - 요청 이벤트
|
|
* @returns {Promise<Array>} 저장된 네비게이션 항목 목록
|
|
*/
|
|
export default defineEventHandler(async (event) => {
|
|
requireAdminSession(event)
|
|
|
|
const parsedBody = parseAdminNavigationInput(await readBody(event))
|
|
|
|
if (!parsedBody.success) {
|
|
throw createError({
|
|
statusCode: 400,
|
|
message: '네비게이션 입력 형식이 올바르지 않습니다.'
|
|
})
|
|
}
|
|
|
|
return updateNavigationItems(parsedBody.data.items)
|
|
})
|