대표 이미지 전용 카드 썸네일로 정리
This commit is contained in:
26
server/routes/admin/api/media/thumbnail.post.js
Normal file
26
server/routes/admin/api/media/thumbnail.post.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { createError, readBody } from 'h3'
|
||||
import { requireAdminSession } from '../../../../utils/admin-auth'
|
||||
import { createPostThumbnailForImageUrl } from '../../../../utils/post-thumbnail-image.js'
|
||||
|
||||
/**
|
||||
* 게시물 대표 이미지 카드 썸네일 재생성 API
|
||||
* @param {import('h3').H3Event} event - 요청 이벤트
|
||||
* @returns {Promise<{ thumbnailUrl: string }>} 생성된 썸네일 URL
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAdminSession(event)
|
||||
|
||||
const body = await readBody(event)
|
||||
const thumbnailUrl = await createPostThumbnailForImageUrl(body?.url)
|
||||
|
||||
if (!thumbnailUrl) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
message: '카드 썸네일을 만들 수 있는 게시물 대표 이미지가 아닙니다.'
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
thumbnailUrl
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user