swaf/src/types/Express.d.ts

55 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-06-14 21:47:18 +02:00
import {Files} from "formidable";
import {Type} from "../Utils";
import Middleware from "../Middleware";
import {FlashMessages} from "../components/SessionComponent";
import {Session, SessionData} from "express-session";
import {PasswordAuthProofSessionData} from "../auth/password/PasswordAuthProof";
2020-04-22 15:52:17 +02:00
declare global {
namespace Express {
export interface Request {
getSession(): Session & Partial<SessionData>;
getSessionOptional(): Session & Partial<SessionData> | undefined;
2020-06-14 21:47:18 +02:00
files: Files;
2020-04-22 15:52:17 +02:00
middlewares: Middleware[];
as<M extends Middleware>(type: Type<M>): M;
flash(): FlashMessages;
2020-04-22 15:52:17 +02:00
flash(message: string): unknown[];
2020-04-22 15:52:17 +02:00
flash(event: string, message: unknown): void;
2020-04-22 15:52:17 +02:00
getPreviousUrl(): string | null;
getIntendedUrl(): string | null;
}
2020-04-22 15:52:17 +02:00
}
}
declare module 'express-session' {
interface SessionData {
id?: string;
previousUrl?: string;
wantsSessionPersistence?: boolean;
persistent?: boolean;
isAuthenticated?: boolean;
authPasswordProof?: PasswordAuthProofSessionData;
csrf?: string;
}
}