MCPcopy
hub / github.com/triggerdotdev/trigger.dev / loader

Function loader

apps/webapp/app/routes/resources.codeexample.tsx:11–30  ·  view source on GitHub ↗
({ request }: LoaderFunctionArgs)

Source from the content-addressed store, hash-verified

9import { requireUserId } from "~/services/session.server";
10
11export async function loader({ request }: LoaderFunctionArgs) {
12 await requireUserId(request);
13 const url = new URL(request.url);
14 const codeUrl = url.searchParams.get("url");
15 invariant(typeof codeUrl === "string", "codeUrl is required");
16 const decodedCodeUrl = decodeURIComponent(codeUrl);
17 const response = await fetch(decodedCodeUrl);
18 if (!response.ok) {
19 throw new Error("Network response was not ok");
20 }
21
22 const code = await response.text();
23
24 const hideCodeRegex = /(\n)?\/\/ hide-code[\s\S]*?\/\/ end-hide-code(\n)*/gm;
25 const cleanedCode = code?.replace(hideCodeRegex, "\n");
26
27 return json({
28 code: cleanedCode,
29 });
30}
31
32export function CodeExample({ example }: { example: ApiExample }) {
33 const customerFetcher = useFetcher<typeof loader>();

Callers

nothing calls this directly

Calls 6

requireUserIdFunction · 0.90
jsonFunction · 0.85
replaceMethod · 0.80
textMethod · 0.65
fetchFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…