forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
21 lines (17 loc) · 644 Bytes
/
Copy pathutils.ts
File metadata and controls
21 lines (17 loc) · 644 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { constants } from '@clerk/backend/internal';
export function getAuthKeyFromRequest(req: Request, key: keyof typeof constants.Attributes): string | null | undefined {
return getHeader(req, constants.Headers[key]);
}
function getHeader(req: Request, name: string) {
return req.headers.get(name);
}
export const isRedirect = (res: Response) => {
return (
[300, 301, 302, 303, 304, 307, 308].includes(res.status) ||
res.headers.get(constants.Headers.ClerkRedirectTo) === 'true'
);
};
export const setHeader = <T extends Response>(res: T, name: string, val: string): T => {
res.headers.set(name, val);
return res;
};