import { query, queryOne } from '../../utils/db' /** * 개선의견 작성 * POST /api/feedback/create */ export default defineEventHandler(async (event) => { const userId = getCookie(event, 'user_id') if (!userId) { throw createError({ statusCode: 401, message: '로그인이 필요합니다.' }) } const body = await readBody<{ category: string content: string }>(event) if (!body.category || !body.content?.trim()) { throw createError({ statusCode: 400, message: '카테고리와 내용을 입력해주세요.' }) } const validCategories = ['FEATURE', 'UI', 'BUG', 'ETC'] if (!validCategories.includes(body.category)) { throw createError({ statusCode: 400, message: '올바른 카테고리를 선택해주세요.' }) } const result = await queryOne(` INSERT INTO wr_feedback (author_id, category, content) VALUES ($1, $2, $3) RETURNING feedback_id `, [userId, body.category, body.content.trim()]) return { success: true, feedbackId: result.feedback_id, message: '의견이 등록되었습니다.' } })