24 lines
630 B
TypeScript
24 lines
630 B
TypeScript
import { execute } from '../../../utils/db'
|
|
import { requireAuth } from '../../../utils/session'
|
|
|
|
/**
|
|
* TODO 완료 처리
|
|
* PUT /api/todo/[id]/complete
|
|
*/
|
|
export default defineEventHandler(async (event) => {
|
|
await requireAuth(event)
|
|
const todoId = parseInt(event.context.params?.id || '0')
|
|
|
|
if (!todoId) {
|
|
throw createError({ statusCode: 400, message: 'TODO ID가 필요합니다.' })
|
|
}
|
|
|
|
await execute(`
|
|
UPDATE wr_todo
|
|
SET status = 'COMPLETED', completed_at = NOW(), updated_at = NOW()
|
|
WHERE todo_id = $1
|
|
`, [todoId])
|
|
|
|
return { success: true, message: '완료 처리되었습니다.' }
|
|
})
|