관리자 기능과 태그 표시 설정 추가

This commit is contained in:
2026-05-01 18:00:22 +09:00
parent 237eb2990f
commit 787747aa7f
51 changed files with 2261 additions and 128 deletions

View File

@@ -0,0 +1,35 @@
import { createError, readBody } from 'h3'
import { requireAdminSession } from '../../../utils/admin-auth'
import { parseAdminPostInput } from '../../../utils/admin-post-input'
import { createAdminPost } from '../../../repositories/content-repository'
/**
* 관리자 게시물 생성 API
* @param {import('h3').H3Event} event - 요청 이벤트
* @returns {Promise<Object>} 생성된 게시물
*/
export default defineEventHandler(async (event) => {
requireAdminSession(event)
const parsedBody = parseAdminPostInput(await readBody(event))
if (!parsedBody.success) {
throw createError({
statusCode: 400,
message: '게시물 입력 형식이 올바르지 않습니다.'
})
}
try {
return await createAdminPost(parsedBody.data)
} catch (error) {
if (error?.code === '23505') {
throw createError({
statusCode: 409,
message: '이미 사용 중인 슬러그입니다.'
})
}
throw error
}
})