사이트 설정 관리 추가
This commit is contained in:
24
server/routes/admin/api/settings.put.js
Normal file
24
server/routes/admin/api/settings.put.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createError, readBody } from 'h3'
|
||||
import { requireAdminSession } from '../../../utils/admin-auth'
|
||||
import { parseAdminSiteSettingsInput } from '../../../utils/admin-site-settings-input'
|
||||
import { updateSiteSettings } from '../../../repositories/content-repository'
|
||||
|
||||
/**
|
||||
* 관리자 사이트 설정 수정 API
|
||||
* @param {import('h3').H3Event} event - 요청 이벤트
|
||||
* @returns {Promise<Object>} 수정된 사이트 설정
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAdminSession(event)
|
||||
|
||||
const parsedBody = parseAdminSiteSettingsInput(await readBody(event))
|
||||
|
||||
if (!parsedBody.success) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
message: '사이트 설정 입력 형식이 올바르지 않습니다.'
|
||||
})
|
||||
}
|
||||
|
||||
return updateSiteSettings(parsedBody.data)
|
||||
})
|
||||
Reference in New Issue
Block a user