MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / loader

Function loader

apps/webapp/app/routes/projects.new.ts:8–29  ·  view source on GitHub ↗
({ request }: LoaderFunctionArgs)

Source from the content-addressed store, hash-verified

6
7//this loader chooses the best project to redirect you to, ideally based on the cookie
8export const loader = async ({ request }: LoaderFunctionArgs) => {
9 const user = await requireUser(request);
10
11 const url = new URL(request.url);
12
13 const presenter = new SelectBestProjectPresenter();
14
15 try {
16 const { organization } = await presenter.call({ userId: user.id, request });
17 //redirect them to the most appropriate project
18 return redirect(`${newProjectPath(organization)}${url.search}`);
19 } catch (e) {
20 const invites = await getUsersInvites({ email: user.email });
21
22 if (invites.length > 0) {
23 return redirect(invitesPath());
24 }
25
26 //this should only happen if the user has no projects, and no invites
27 return redirect(newOrganizationPath());
28 }
29};

Callers

nothing calls this directly

Calls 6

callMethod · 0.95
requireUserFunction · 0.90
newProjectPathFunction · 0.90
getUsersInvitesFunction · 0.90
invitesPathFunction · 0.90
newOrganizationPathFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…