next-server-middleware
Version:
A simple type-safe express-like middleware for Next.js api routes using app directory and next/server
11 lines • 643 B
TypeScript
import type { NextResponse } from "next/server";
import type { Middleware } from "./types";
export interface WithErrorHandlingOptions {
errorFactory: (error: unknown, options: Omit<WithErrorHandlingOptions, "errorFactory">) => NextResponse;
errorStatus?: number;
}
export declare const makeDefaultErrorFactory: ({ ResponseObj }: {
ResponseObj: typeof NextResponse;
}) => (error: unknown, { errorStatus }?: Omit<WithErrorHandlingOptions, "errorFactory">) => NextResponse;
export declare const withErrorHandling: ({ errorFactory, errorStatus }: WithErrorHandlingOptions) => Middleware;
//# sourceMappingURL=withErrorHandling.d.ts.map