UNPKG

next-middleware-enhancer

Version:
27 lines (21 loc) 850 B
import { NextRequest } from 'next/server'; import { NextResponse } from 'next/server'; /** * `createMiddleware` function * - Supports Next.js `matcher` patterns to apply middleware based on routes * - Allows multiple middleware functions to execute sequentially * - Returns `NextResponse.next()` if no matching middleware is found */ export declare function createMiddleware(middlewareList: MiddlewareList): { middleware: (req: NextRequest) => Promise<NextResponse<unknown>>; config: { matcher: string[]; }; }; declare type MiddlewareConfig = { matcher: string; handler: MiddlewareFunction | MiddlewareFunction[]; }; declare type MiddlewareFunction = (req: NextRequest) => NextResponse | void | Promise<NextResponse | void>; declare type MiddlewareList = MiddlewareConfig[]; export { }