feat: verschlüsselte Integrationseinstellungen, Haushaltsmitglieder mit Ersteller, Backup-Download
This commit is contained in:
1 parent
a1195223e0
commit
267f4fcf70
21 files changed
+724
-30
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getDb } from "@/lib/db";
|
||||
|
||||
export async function GET() {
|
||||
const db = getDb();
|
||||
const members = await db.householdMember.findMany({ orderBy: { name: "asc" } });
|
||||
return NextResponse.json(members);
|
||||
}
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const name = String(body.name ?? "").trim();
|
||||
if (!name) return NextResponse.json({ errors: ["name"] }, { status: 400 });
|
||||
if (name.length > 100) return NextResponse.json({ errors: ["name"] }, { status: 400 });
|
||||
const db = getDb();
|
||||
const existing = await db.householdMember.findUnique({ where: { name } });
|
||||
if (existing) return NextResponse.json({ errors: ["name"] }, { status: 409 });
|
||||
const created = await db.householdMember.create({ data: { name } });
|
||||
return NextResponse.json(created, { status: 201 });
|
||||
}
|
||||
|
||||
export async function DELETE(req: NextRequest) {
|
||||
const id = Number(req.nextUrl.searchParams.get("id"));
|
||||
if (!Number.isInteger(id)) return NextResponse.json({ error: "not found" }, { status: 404 });
|
||||
const db = getDb();
|
||||
const existing = await db.householdMember.findUnique({ where: { id } });
|
||||
if (!existing) return NextResponse.json({ error: "not found" }, { status: 404 });
|
||||
await db.householdMember.delete({ where: { id } });
|
||||
return NextResponse.json({ ok: true });
|
||||
}
|
||||
Reference in new issue
Block a user