Nuxt 초기 세팅 추가
This commit is contained in:
20
server/api/posts/[slug].get.js
Normal file
20
server/api/posts/[slug].get.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { getSamplePostBySlug } from '../../utils/sample-content'
|
||||
|
||||
/**
|
||||
* 공개 게시물 상세 API
|
||||
* @param {import('h3').H3Event} event - 요청 이벤트
|
||||
* @returns {Object} 게시물 상세
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
const slug = getRouterParam(event, 'slug')
|
||||
const post = getSamplePostBySlug(slug)
|
||||
|
||||
if (!post) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: '게시물을 찾을 수 없습니다'
|
||||
})
|
||||
}
|
||||
|
||||
return post
|
||||
})
|
||||
Reference in New Issue
Block a user