timeline db and react query

This commit is contained in:
2026-02-24 08:24:09 +01:00
parent 622dcdcacd
commit 117d44718e
7 changed files with 96 additions and 4 deletions

View File

@@ -0,0 +1,20 @@
import { eq } from "drizzle-orm";
import { db } from "@zendegi/db";
import { createServerFn } from "@tanstack/react-start";
import { timeline } from "@zendegi/db/schema/timeline";
import { queryOptions } from "@tanstack/react-query";
export const getTimelines = createServerFn({ method: "GET" }).handler(
async () => {
return db.query.timeline.findMany({
where: eq(timeline.visibility, "public"),
orderBy: (t, { desc }) => [desc(t.createdAt)],
});
}
);
export const timelinesQueryOptions = () =>
queryOptions({
queryKey: ["timelines"],
queryFn: () => getTimelines(),
});

View File

@@ -1,5 +1,4 @@
import { createServerFn } from "@tanstack/react-start";
import { authMiddleware } from "@/middleware/auth";
export const getUser = createServerFn({ method: "GET" })