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

Function getApiKeyFromRequest

apps/proxy/src/apikey.ts:5–16  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

3const AuthorizationHeaderSchema = z.string().regex(/^Bearer .+$/);
4
5export function getApiKeyFromRequest(request: Request) {
6 const rawAuthorization = request.headers.get("Authorization");
7
8 const authorization = AuthorizationHeaderSchema.safeParse(rawAuthorization);
9 if (!authorization.success) {
10 return;
11 }
12
13 const apiKey = authorization.data.replace(/^Bearer /, "");
14 const type = isPrivateApiKey(apiKey) ? ("PRIVATE" as const) : ("PUBLIC" as const);
15 return { apiKey, type };
16}
17
18function isPrivateApiKey(key: string) {
19 return key.startsWith("tr_");

Callers 3

applyRateLimitFunction · 0.90
queueEventsFunction · 0.90
queueEventFunction · 0.90

Calls 3

isPrivateApiKeyFunction · 0.85
replaceMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…