-
Notifications
You must be signed in to change notification settings - Fork 20
/
remix.env.d.ts
51 lines (44 loc) · 1.18 KB
/
remix.env.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/// <reference types="@remix-run/dev" />
/// <reference types="@remix-run/node/globals" />
import type { RequestHandler } from "@remix-run/express";
import type { ServerBuild } from "@remix-run/node";
import type { Payload } from "payload";
import type { User } from "payload/generated-types";
export interface RemixRequestContext {
payload: Payload;
user?: {
id: string;
roles: ["staff" | "user"];
username: string;
avatar?: {
id: string;
url: string;
};
};
token?: string;
exp?: number;
res: Response;
}
declare module "@remix-run/node" {
interface AppLoadContext extends RemixRequestContext {}
}
//overload the request handler to include the payload and user objects
interface PayloadRequest extends Request {
payload: Payload;
user?: User;
}
type GetLoadContextFunction = (
req: PayloadRequest,
res: Response,
) => Promise<AppLoadContext> | AppLoadContext;
declare module "@remix-run/express" {
export declare function createRequestHandler({
build,
getLoadContext,
mode,
}: {
build: ServerBuild;
getLoadContext?: GetLoadContextFunction;
mode?: string;
}): RequestHandler;
}