Nuxt 3 app with: - SQLite (better-sqlite3) for persistence - Anonymous idea submission and voting - Admin auth with session cookies - AI analysis via Gemini API - Nuxt UI components + Tailwind Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
21 lines
626 B
TypeScript
21 lines
626 B
TypeScript
import db from '../../utils/db'
|
|
import { requireAdmin } from '../../utils/auth'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
requireAdmin(event)
|
|
const id = getRouterParam(event, 'id')
|
|
const body = await readBody(event)
|
|
|
|
if (body.hidden !== undefined) {
|
|
db.prepare('UPDATE ideas SET hidden = ? WHERE id = ?').run(body.hidden ? 1 : 0, id)
|
|
}
|
|
if (body.text !== undefined) {
|
|
db.prepare('UPDATE ideas SET text = ? WHERE id = ?').run(body.text, id)
|
|
}
|
|
if (body.category !== undefined) {
|
|
db.prepare('UPDATE ideas SET category = ? WHERE id = ?').run(body.category, id)
|
|
}
|
|
|
|
return { ok: true }
|
|
})
|