-
Notifications
You must be signed in to change notification settings - Fork 7
/
env.d.ts
47 lines (41 loc) · 1.13 KB
/
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
/// <reference types="@remix-run/node" />
/// <reference types="vite/client" />
import type { User } from "payload/generated-types";
import type { Response, Request, NextFunction } from "express";
import type { Payload } from "payload";
import type { ServerBuild } from "@remix-run/node";
export interface RemixRequestContext {
payload: Payload;
user?: User;
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 Express.Request {
payload: Payload;
user?: User;
}
type GetLoadContextFunction = (
req: PayloadRequest,
res: Response
) => Promise<AppLoadContext> | AppLoadContext;
type RequestHandler = (
req: Request,
res: Response,
next: NextFunction
) => Promise<void>;
declare module "@remix-run/express" {
export function createRequestHandler({
build,
getLoadContext,
mode,
}: {
build: ServerBuild | (() => Promise<ServerBuild>);
getLoadContext?: GetLoadContextFunction;
mode?: string;
}): RequestHandler;
}