next-wayfinder
Version:
Apply multiple next.js middlewares with ease
21 lines (18 loc) • 1.21 kB
text/typescript
import { NextRequest } from 'next/server';
import { RequestParser, PathMatcher, UrlParams, HTTPMethod, Middleware, NextRequestWithParams } from './types.mjs';
import 'path-to-regexp';
declare const parse: RequestParser;
declare const getParams: (matcher: PathMatcher, pathname: string) => UrlParams;
interface FindOptions {
hostname: string;
path: string;
method: HTTPMethod;
}
declare function checkMethod<T>(m: Middleware<T>, method: HTTPMethod): boolean;
declare function findMiddleware<T>(middlewares: Middleware<T>[], { path, hostname, method }: FindOptions): Middleware<T> | undefined;
declare const getParamsDescriptor: (params: UrlParams) => PropertyDescriptor;
declare const getInjectorDescriptor: <T>(data: T) => PropertyDescriptor;
declare const applyContext: <T>(request: NextRequest, context?: T) => NextRequestWithParams<T>;
declare const addParams: <T>(request: NextRequest, matcher: PathMatcher, pathname: string) => NextRequestWithParams<T>;
declare const replaceValues: (pathname: string, values: UrlParams) => string;
export { type FindOptions, addParams, applyContext, checkMethod, findMiddleware, getInjectorDescriptor, getParams, getParamsDescriptor, parse, replaceValues };