import { createError, readBody } from 'h3' import { z } from 'zod' import { requireAdminSession } from '../../../../utils/admin-auth' import { reorderAdminPageSections } from '../../../../repositories/content-repository' const reorderPageSectionsSchema = z.object({ sectionIds: z.array(z.string().uuid()).min(1) }) /** * 관리자 페이지 섹션 정렬 저장 API * @param {import('h3').H3Event} event - 요청 이벤트 * @returns {Promise} 정렬 저장 후 페이지 섹션 목록 */ export default defineEventHandler(async (event) => { requireAdminSession(event) const parsedBody = reorderPageSectionsSchema.safeParse(await readBody(event)) if (!parsedBody.success) { throw createError({ statusCode: 400, message: '페이지 섹션 정렬 요청 형식이 올바르지 않습니다.' }) } return reorderAdminPageSections(parsedBody.data.sectionIds) })