4d56d4904a
- TributeSection: zwei Perspektiven (Familie + Dennis), emotional und persönlich - MusicPlayer: Autoplay mit stummem Start + Fade-In bei Interaktion, nahtloser Crossfade-Loop (überspringt stille letzten 10s), kompakter Mute-Button - Alle API-Routes: export const runtime = 'nodejs' für node:sqlite in Next.js 16 - Admin: defensive res.ok Checks vor .json() Parsing - DB: mkdirSync erst zur Laufzeit, path.resolve für DATA_DIR - page.tsx: plain() Helper für null-prototype SQLite-Rows - erinnerungen.md: alle Familieninfos und Erinnerungen dokumentiert - Nav: Musik-Tab entfernt, "Über Oma" hinzugefügt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 lines
916 B
TypeScript
32 lines
916 B
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import { getDb } from '@/lib/db'
|
|
|
|
export const runtime = 'nodejs'
|
|
|
|
export async function GET() {
|
|
const db = getDb()
|
|
const memories = db
|
|
.prepare('SELECT * FROM memories ORDER BY created_at DESC')
|
|
.all()
|
|
return NextResponse.json(memories)
|
|
}
|
|
|
|
export async function POST(req: NextRequest) {
|
|
const { title, content, author } = await req.json()
|
|
if (!title?.trim() || !content?.trim()) {
|
|
return NextResponse.json(
|
|
{ error: 'Titel und Inhalt sind erforderlich' },
|
|
{ status: 400 }
|
|
)
|
|
}
|
|
|
|
const db = getDb()
|
|
const result = db
|
|
.prepare('INSERT INTO memories (title, content, author) VALUES (?, ?, ?)')
|
|
.run(title.trim(), content.trim(), author?.trim() || null)
|
|
const memory = db
|
|
.prepare('SELECT * FROM memories WHERE id = ?')
|
|
.get(result.lastInsertRowid)
|
|
return NextResponse.json(memory, { status: 201 })
|
|
}
|