express-limiter-pro
Version:
A TypeScript library for safe display and sanitization to prevent XSS attacks.
36 lines (35 loc) • 940 B
TypeScript
import { Request } from 'express';
import { Options } from 'express-rate-limit';
import { UserRole } from 'cca-entities';
export interface RateLimitConfig {
api: Partial<Options>;
auth: Partial<Options>;
sensitive: Partial<Options>;
}
export interface RateLimitOptions extends Partial<Options> {
errorName?: string;
message?: string;
}
export interface RateLimitRule {
paths: string[];
limiter: import('express').RequestHandler;
condition?: (req: any) => boolean;
}
export interface TokenPayload {
userId: string;
role: UserRole;
twoFactorAuthenticated?: boolean;
}
export interface TokenSecret {
accessTokenSecret: string;
isDevelopment: boolean;
}
export type ConfigSource = () => Promise<TokenSecret>;
export interface AuthInfo {
id: string;
role: UserRole;
twoFactorAuthenticated?: boolean;
}
export interface AuthenticatedRequest extends Request {
auth?: AuthInfo;
}