useRuntimeConfig() and better-sqlite3 were being called at module top-level, which crashes during Nitro server startup. Now all DB access is lazy via useDb(), and auth uses process.env directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
12 lines
379 B
TypeScript
12 lines
379 B
TypeScript
import { useDb } from '../../utils/db'
|
|
import { isAdmin } from '../../utils/auth'
|
|
|
|
export default defineEventHandler((event) => {
|
|
const db = useDb()
|
|
const admin = isAdmin(event)
|
|
const rows = admin
|
|
? db.prepare('SELECT * FROM ideas ORDER BY created_at DESC').all()
|
|
: db.prepare('SELECT * FROM ideas WHERE hidden = 0 ORDER BY created_at DESC').all()
|
|
return rows
|
|
})
|