MCPcopy Create free account
hub / github.com/triggerdotdev/jsonhero-web / loader

Function loader

app/routes/actions/createFromUrl.ts:72–97  ·  view source on GitHub ↗
({ request, context })

Source from the content-addressed store, hash-verified

70};
71
72export let loader: LoaderFunction = async ({ request, context }) => {
73 const url = new URL(request.url);
74 const jsonUrl = url.searchParams.get("jsonUrl");
75
76 if (!jsonUrl) {
77 return redirect("/");
78 }
79
80 const jsonURL = new URL(jsonUrl);
81
82 invariant(jsonURL, "jsonUrl must be a valid URL");
83
84 const doc = await createFromUrl(jsonURL, jsonURL.href);
85
86 context.waitUntil(
87 sendEvent({
88 type: "create",
89 from: "url",
90 hostname: jsonURL.hostname,
91 id: doc.id,
92 source: url.searchParams.get("utm_source") ?? url.hostname,
93 })
94 );
95
96 return redirect(`/j/${doc.id}`);
97};

Callers

nothing calls this directly

Calls 2

createFromUrlFunction · 0.90
sendEventFunction · 0.90

Tested by

no test coverage detected