feat: api v1 routes for calendar lists and notes

This commit is contained in:
ginnoir
2026-07-04 19:03:08 -05:00
parent ea5d1d050c
commit d4304b005c
25 changed files with 1141 additions and 236 deletions
+33
View File
@@ -0,0 +1,33 @@
import { apiJson, withApiHandler } from "@/lib/api-handler";
import { deleteListForScope, updateListForScope } from "@/modules/lists/server/actions";
import { listUpdateInput } from "@/modules/lists/server/schemas";
import { getListForScope } from "@/modules/lists/server/queries";
import { z } from "zod";
export async function GET(request: Request, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
return withApiHandler(request, async (scope) => {
const list = await getListForScope(scope.householdId, id);
return apiJson(list);
});
}
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 = listUpdateInput.parse(body);
await updateListForScope(scope, { id, ...parsed });
const list = await getListForScope(scope.householdId, id);
return apiJson(list);
});
}
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 deleteListForScope(scope, { id });
return apiJson({ ok: true });
});
}