feat: api v1 garden bangs routes and openapi

This commit is contained in:
ginnoir
2026-07-04 19:13:49 -05:00
parent d4304b005c
commit e8d13bede8
16 changed files with 1351 additions and 113 deletions
+28
View File
@@ -0,0 +1,28 @@
import { apiJson, withApiHandler } from "@/lib/api-handler";
import { deleteBangForScope, updateBangForScope } from "@/modules/bangs/server/actions";
import { updateBangInput } from "@/modules/bangs/server/schemas";
import { z } from "zod";
export async function PATCH(request: Request, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
return withApiHandler(request, async (scope, req) => {
const body: unknown = await req.json();
const parsed = updateBangInput.parse(body);
const bang = await updateBangForScope(scope, { id, ...parsed });
return apiJson({
id: bang.id,
occurredOn: bang.occurredOn,
recordedBy: bang.recordedBy,
createdAt: bang.createdAt.toISOString(),
});
});
}
export async function DELETE(request: Request, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
return withApiHandler(request, async (scope) => {
z.string().uuid().parse(id);
await deleteBangForScope(scope, { id });
return apiJson({ ok: true });
});
}