Last active
September 27, 2025 22:49
-
-
Save bhaveshxrawat/7367545d0382bee84d6b6948302bbb0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { api } from "@netflix-comments/backend/convex/_generated/api"; | |
| import { createFileRoute, notFound } from "@tanstack/react-router"; | |
| import { createServerFn } from "@tanstack/react-start"; | |
| import { ConvexHttpClient } from "convex/browser"; //This import itself makes it a little sus since the package seems to be build for browser (client) | |
| import z from "zod"; | |
| const convex = new ConvexHttpClient(process.env.CONVEX_URL as string); | |
| const validatesTitle = createServerFn() | |
| .validator( | |
| z.object({ | |
| titleId: z.string().length(8), | |
| }) | |
| ) | |
| .handler(async (params) => { | |
| const titleId = params.data.titleId; | |
| const data = await convex.action(api.titles.getOrFetchTitle, { | |
| netflixId: titleId, | |
| }); | |
| if (!data) { | |
| throw notFound(); | |
| } | |
| return data; | |
| }); | |
| export const Route = createFileRoute("/title/$titleId")({ | |
| component: RouteComponent, | |
| beforeLoad: ({ params }) => | |
| validatesTitle({ | |
| data: { | |
| titleId: params.titleId, | |
| }, | |
| }), | |
| loader: (ctx) => { | |
| return ctx.context; | |
| }, | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment