@nimpl/middleware-chain
Version:
The package allows you to create a chain of native next.js middlewares without any modifications
7 lines (6 loc) • 650 B
TypeScript
import { type NextFetchEvent, type NextRequest, type NextResponse } from "next/server";
import { type ChainItem, type ChainConfig, type BaseRequest } from "./lib/types";
export { type ChainItem, type ChainConfig, type BaseRequest, type Middleware } from "./lib/types";
export { FinalNextResponse } from "./lib/final-next-response";
export declare const chain: <RequestType extends Request & BaseRequest = NextRequest, ResponseType extends Response = NextResponse<unknown>>(middlewares: ChainItem<RequestType, ResponseType>[], config?: ChainConfig) => (req: RequestType, event: NextFetchEvent) => Promise<NextResponse<unknown>>;
export default chain;