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
17 lines
724 B
TypeScript
17 lines
724 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { z } from "zod";
|
|
import { renameDevice } from "@/lib/db/queries/devices";
|
|
|
|
const bodySchema = z.object({ displayName: z.string().min(1).max(120) });
|
|
|
|
export async function PATCH(req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
const { id } = await params;
|
|
const parsed = bodySchema.safeParse(await req.json().catch(() => null));
|
|
if (!parsed.success) {
|
|
return NextResponse.json({ error: "displayName is required" }, { status: 400 });
|
|
}
|
|
const updated = await renameDevice(Number(id), parsed.data.displayName);
|
|
if (!updated) return NextResponse.json({ error: "not found" }, { status: 404 });
|
|
return NextResponse.json({ device: updated });
|
|
}
|