-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathglobal.d.ts
49 lines (43 loc) · 1.24 KB
/
global.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
import { Request } from "express";
type FlashMessageType = "info" | "error" | "success";
export type Page = {
readonly component: string;
props: props;
readonly url: string;
readonly version: string;
};
export type Inertia = {
readonly setViewData: (viewData: props) => Inertia;
readonly shareProps: (sharedProps: props) => Inertia;
readonly setStatusCode: (statusCode: number) => Inertia;
readonly setHeaders: (headers: Record<string, string>) => Inertia;
readonly render: (Page: Page) => Promise<Response>;
readonly redirect: (url: string) => Response;
};
export interface Flash {
setFlashMessage: (type: FlashMessageType, message: string) => number;
setFlashMessages: (type: FlashMessageType, message: string[]) => number;
flash: (type: FlashMessageType) => string[];
flashAll: () => Record<FlashMessageType, string[]>;
}
declare global {
namespace Express {
export interface Request {
Inertia: Inertia;
flash: Flash;
}
}
}
declare module "express-session" {
interface SessionData {
flashMessages: Record<string, string[]>;
xInertiaCurrentComponent: string | undefined;
user: {
id: string;
owner: boolean;
first_name: string;
last_name: string;
};
}
}
export {};