fix: reorder migrate-owner route before /:id param route
Some checks failed
CI/CD / test (push) Successful in 23s
CI/CD / deploy (push) Failing after 2s

This commit is contained in:
2026-01-30 13:56:30 +00:00
parent 73bf9a69b1
commit 30d1892a7d

View File

@@ -142,6 +142,24 @@ export const todoRoutes = new Elysia({ prefix: "/api/todos" })
}) })
// PATCH update todo // PATCH update todo
// POST reassign all bearer todos to a real user (one-time migration)
.post("/migrate-owner", async ({ body, request, headers }) => {
const { userId } = await requireSessionOrBearer(request, headers);
const result = await db
.update(todos)
.set({ userId: body.targetUserId, updatedAt: new Date() })
.where(eq(todos.userId, body.fromUserId))
.returning({ id: todos.id });
return { migrated: result.length };
}, {
body: t.Object({
fromUserId: t.String(),
targetUserId: t.String(),
}),
})
.patch("/:id", async ({ params, body, request, headers }) => { .patch("/:id", async ({ params, body, request, headers }) => {
const { userId } = await requireSessionOrBearer(request, headers); const { userId } = await requireSessionOrBearer(request, headers);
@@ -279,20 +297,3 @@ export const todoRoutes = new Elysia({ prefix: "/api/todos" })
}), }),
}) })
// POST reassign all bearer todos to a real user (one-time migration)
.post("/migrate-owner", async ({ body, request, headers }) => {
const { userId } = await requireSessionOrBearer(request, headers);
const result = await db
.update(todos)
.set({ userId: body.targetUserId, updatedAt: new Date() })
.where(eq(todos.userId, body.fromUserId))
.returning({ id: todos.id });
return { migrated: result.length };
}, {
body: t.Object({
fromUserId: t.String(),
targetUserId: t.String(),
}),
});