Next.js app with a browser-side buttplug/buttplug-wasm control layer (server never touches real-time device commands), SQLite storage via Drizzle, single-secret auth, recordings/replay with device remapping, a usage stats dashboard, Docker deployment, and Gitea CI. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W8WkFF5ppURBAB918593Eb
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import { z } from "zod";
|
|
import { deleteRecording, getRecording, renameRecording } from "@/lib/db/queries/recordings";
|
|
|
|
const patchSchema = z.object({
|
|
name: z.string().min(1).max(160).optional(),
|
|
description: z.string().max(2000).optional(),
|
|
});
|
|
|
|
export async function GET(_req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
const { id } = await params;
|
|
const result = await getRecording(Number(id));
|
|
if (!result) return NextResponse.json({ error: "not found" }, { status: 404 });
|
|
return NextResponse.json(result);
|
|
}
|
|
|
|
export async function PATCH(req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
const { id } = await params;
|
|
const parsed = patchSchema.safeParse(await req.json().catch(() => null));
|
|
if (!parsed.success) {
|
|
return NextResponse.json({ error: "invalid body" }, { status: 400 });
|
|
}
|
|
const updated = await renameRecording(Number(id), parsed.data);
|
|
if (!updated) return NextResponse.json({ error: "not found" }, { status: 404 });
|
|
return NextResponse.json({ recording: updated });
|
|
}
|
|
|
|
export async function DELETE(_req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
const { id } = await params;
|
|
await deleteRecording(Number(id));
|
|
return NextResponse.json({ ok: true });
|
|
}
|