feat: api v1 routes for calendar lists and notes
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { apiJson, withApiHandler } from "@/lib/api-handler";
|
||||
import { createNoteForScope } from "@/modules/notes/server/actions";
|
||||
import { noteInput } from "@/modules/notes/server/schemas";
|
||||
import { listNotesForScope } from "@/modules/notes/server/queries";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
return withApiHandler(request, async (scope) => {
|
||||
const notes = await listNotesForScope(scope.householdId);
|
||||
return apiJson(notes);
|
||||
});
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
return withApiHandler(request, async (scope, req) => {
|
||||
const body: unknown = await req.json();
|
||||
const parsed = noteInput.parse(body);
|
||||
const note = await createNoteForScope(scope, parsed);
|
||||
return apiJson(note, 201);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user