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

Function loader

apps/webapp/app/routes/api.v2.whoami.ts:9–41  ·  view source on GitHub ↗
({ request }: LoaderFunctionArgs)

Source from the content-addressed store, hash-verified

7import { authenticateApiRequestWithPersonalAccessToken } from "~/services/personalAccessToken.server";
8
9export async function loader({ request }: LoaderFunctionArgs) {
10 logger.info("whoami v2", { url: request.url });
11 try {
12 const authenticationResult = await authenticateApiRequestWithPersonalAccessToken(request);
13 if (!authenticationResult) {
14 return json({ error: "Invalid or Missing Access Token" }, { status: 401 });
15 }
16
17 const user = await prisma.user.findUnique({
18 select: {
19 email: true,
20 },
21 where: {
22 id: authenticationResult.userId,
23 },
24 });
25
26 if (!user) {
27 return json({ error: "User not found" }, { status: 404 });
28 }
29
30 const result: WhoAmIResponse = {
31 userId: authenticationResult.userId,
32 email: user.email,
33 dashboardUrl: env.APP_ORIGIN,
34 };
35 return json(result);
36 } catch (error) {
37 const errorMessage = error instanceof Error ? error.message : "Something went wrong";
38 logger.error("Error in whoami v2", { error: errorMessage });
39 return json({ error: errorMessage }, { status: 400 });
40 }
41}

Callers

nothing calls this directly

Calls 4

jsonFunction · 0.85
infoMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…