diff --git a/server/api/todos/.post.ts b/server/api/todos/.post.ts index c6f2962..3f91a0a 100644 --- a/server/api/todos/.post.ts +++ b/server/api/todos/.post.ts @@ -4,7 +4,7 @@ import { Todo } from "~~/shared/types"; export const Body = z.object({ data: Todo, - position: z.literal(["top", "bottom"]), + position: z.literal(["top", "bottom"]).optional(), previousId: z.uuid().optional(), }); diff --git a/server/utils/db/todos.ts b/server/utils/db/todos.ts index deb6538..63d4895 100644 --- a/server/utils/db/todos.ts +++ b/server/utils/db/todos.ts @@ -39,13 +39,13 @@ export const Todos = { async updateOrAdd( userId: string, todo: Todo, - position: "top" | "bottom", + position?: "top" | "bottom", previous?: UUID, ): Promise { const storage = useStorage(); const todos = await Todos.getAll(userId); - updateOrInsertAfterTodo(todos, todo, position, previous); + updateOrInsertAfterTodo(todos, todo, position ?? "top", previous); await storage.set(getKey(userId), todos);