import { Jups, Method } from './jups'; import { Request } from './request'; import { Response } from './response'; export interface Variable { index: number; name: string; optional: boolean; } export interface RouteRegex { route: string | RegExp; regex: RegExp; variables?: Variable[]; } export interface Route extends RouteRegex { method: Method; callback: RouteCallback; } export declare type RouteCallback = (req: Request, res: Response) => void; export declare type RouteCallbackError = (req: Request, res: Response, err: Error) => void; export declare type RouteFunction = (route: string | RegExp, callback: RouteCallback) => Jups; /** * This function gets all of the matching routes for a `Jups` instance. This will also be called for all subapps. * This will also fetch the correct `otherwise` and `error` callbacks. * * @param jups The `Jups` instance to handle the routes on. This could also be a subapp `Jups` instance. * @param req The `Request` object. * @param res The `Response` object. * @param url The URL to check for Regex matches. */ export declare function handleRoutes(jups: Jups, req: Request, res: Response, url: string): void; /** * This function generates the needed Regex for string routes. It handles URL variables, * wildcards, groups accordingly, and makes it very simple to work with for handling incoming * connections. * * @param route The route to generate the regex on. Only string routes are supported. * @param base If the route to generate has a base (basically anything that the `use` method receives). */ export declare function generateRouteRegex(route: string, base?: boolean): RegExp;