import type { RequestEvent } from "./request_event"; import type { Handler, Handlers, NextFunction, RouterOrWare, TObject, TRet } from "./types"; export declare function findParams(el: TObject, url: string): any; export type TRouter = { base?: string; }; export declare const ANY_METHODS: readonly ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"]; type TMethod = typeof ANY_METHODS[number]; /** * Router * @example * const router = new Router(); * const router = new Router({ base: '/items' }); */ export default class Router { route: TObject; c_routes: TObject[]; midds: TRet[]; pmidds?: TRet[]; private base; constructor({ base }?: TRouter); /** * add middlware or router. * @example * app.use(...middlewares); * app.use('/api/v1', routers); */ use(prefix: string | RouterOrWare | RouterOrWare[], ...routerOrMiddleware: Array | RouterOrWare[]>): this; /** * build handlers (app or router) * @example * app.on("GET", "/", ...handlers); */ on(method: string, path: string | RegExp, ...handlers: Handlers): this; /** * add method handlers (app or router). * @example * app.add("GET", "/", ...handlers); * app.add(["GET", "POST"], "/", ...handlers); */ add(method: TMethod | TMethod[], path: string | RegExp, ...handlers: Handlers): this; /** * method GET (app or router) * @example * app.get("/", ...handlers); */ get(path: string | RegExp, ...handlers: Handlers): this; /** * method POST (app or router) * @example * app.post("/", ...handlers); */ post(path: string | RegExp, ...handlers: Handlers): this; /** * method PUT (app or router) * @example * app.put("/", ...handlers); */ put(path: string | RegExp, ...handlers: Handlers): this; /** * method PATCH (app or router) * @example * app.patch("/", ...handlers); */ patch(path: string | RegExp, ...handlers: Handlers): this; /** * method DELETE (app or router) * @example * app.delete("/", ...handlers); */ delete(path: string | RegExp, ...handlers: Handlers): this; /** * method ANY (allow all method directly) (app or router) * @example * app.any("/", ...handlers); */ any(path: string | RegExp, ...handlers: Handlers): this; /** * method HEAD (app or router) * @example * app.head("/", ...handlers); */ head(path: string | RegExp, ...handlers: Handlers): this; /** * method OPTIONS (app or router) * @example * app.options("/", ...handlers); */ options(path: string | RegExp, ...handlers: Handlers): this; /** * method TRACE (app or router) * @example * app.trace("/", ...handlers); */ trace(path: string | RegExp, ...handlers: Handlers): this; /** * method CONNECT (app or router) * @example * app.connect("/", ...handlers); */ connect(path: string | RegExp, ...handlers: Handlers): this; find(method: string, path: string, setParam: (obj: TObject, route_path: string) => void, notFound: (rev: Rev, next: NextFunction) => TRet): Handler[]; } export {};