import { NextRequest } from 'next/server'; import { AuthUser } from '../types'; export interface MiddlewareRule { path?: string | RegExp | (string | RegExp)[]; role?: string | string[]; roles?: string | string[]; department?: string | string[]; departments?: string | string[]; permission?: string | string[]; permissions?: string | string[]; isAdmin?: boolean; isSuperAdmin?: boolean; requireAll?: boolean; custom?: (user: AuthUser) => boolean | Promise; } export interface AuthMiddlewareConfig { // Global settings loginUrl?: string; unauthorizedUrl?: string; publicPaths?: (string | RegExp)[]; // Rules rules?: MiddlewareRule[]; // Callbacks onUnauthorized?: (req: NextRequest, user: AuthUser | null) => Response | void; onError?: (error: Error, req: NextRequest) => Response | void; // Options tokenCookie?: string; checkRevoked?: boolean; debug?: boolean; } export interface ApiHandlerOptions { role?: string | string[]; roles?: string | string[]; department?: string | string[]; departments?: string | string[]; permission?: string | string[]; permissions?: string | string[]; isAdmin?: boolean; isSuperAdmin?: boolean; requireAll?: boolean; handler: (req: any, res: any, user: AuthUser) => Promise | void; }