///
import { Route } from './route.js';
import { RouteGroup } from './group.js';
import { PendingRoute } from './pending-route.js';
import { RouteCollection } from './route-collection.js';
import { HttpContext } from '../server/index.js';
import { Middleware as KoaMiddleware } from '@koa/router';
import { HttpRouter, RouteHandler, RouteAttributes, HttpMethods, MiddlewareCtor, Application, HttpConfig } from '@supercharge/contracts';
export declare class Router implements HttpRouter {
private readonly meta;
/**
* Create a new router instance.
*/
constructor(app: Application, httpConfig: HttpConfig);
/**
* Returns the app instance.
*/
private app;
/**
* Returns the Koa router instance.
*/
private router;
/**
* Returns the route collection.
*/
routes(): RouteCollection;
/**
* Returns a middleware-function for the HTTP server handling
* the route-matching for an incoming request to the server.
*/
createRoutingMiddleware(): KoaMiddleware;
/**
* Ensure the router found a matching route for the request.
*/
private ensureMatchedRoute;
/**
* Register all collected routes to the router instance.
*/
private registerRoutesToRouter;
/**
* Register the given `route` and related route-level middleware to the router.
*/
private register;
/**
* Register an exception handler to process and respond for a given error.
*/
createErrorHandlerMiddleware(): any;
/**
* Creates and returns the route-level middleware stack.
*/
private createRouteMiddleware;
/**
* Throws if the given middleware `name` is not registered in the middleware stack.
*/
ensureMiddlewareExists(name: string): void;
/**
* Determine whether the given middleware is not registered.
*/
isMissingMiddleware(name: string): boolean;
/**
* Determine whether the given middleware is registered.
*/
hasMiddleware(name: string): boolean;
/**
* Returns a new middleware instance.
*/
private makeMiddleware;
/**
* Returns a Koa-compatible route handler.
*/
private createRouteHandler;
/**
* Handle the given request context for the related route.
*/
handleRequest(route: Route, ctx: HttpContext): Promise;
/**
* Wrap the given Koa `ctx` into a Supercharge ctx.
*/
private createContext;
/**
* Returns the route group stack.
*/
groupStack(): RouteGroup[];
/**
* Create a GET route.
*/
get(path: string, handler: RouteHandler, middleware?: string[]): Route;
/**
* Create a POST route.
*/
post(path: string, handler: RouteHandler, middleware?: string[]): Route;
/**
* Create a PUT route.
*/
put(path: string, handler: RouteHandler, middleware?: string[]): Route;
/**
* Create a DELETE route.
*/
delete(path: string, handler: RouteHandler, middleware?: string[]): Route;
/**
* Create a PATCH route.
*/
patch(path: string, handler: RouteHandler, middleware?: string[]): Route;
/**
* Create an OPTIONS route.
*/
options(path: string, handler: RouteHandler): Route;
/**
* Create a new route and add it to the routes collection.
*/
addRoute(methods: HttpMethods[], path: string, handler: RouteHandler, middleware?: string[]): Route;
/**
* Create a new route instance.
*/
createRoute(methods: HttpMethods[], path: string, handler: RouteHandler, middleware?: string[]): Route;
/**
* Determine whether an active route group exists.
*/
hasGroupStack(): boolean;
/**
* Returns the last route group.
*/
getLastGroup(): RouteGroup | undefined;
/**
* Merge the group attributes into the given route.
*/
mergeGroupAttributesIntoRoute(route: Route): void;
/**
* Create a new route group.
*/
group(callback: () => void): void;
group(prefix: string, callback: (() => void)): void;
group(attributes: RouteAttributes, callback: () => void): void;
/**
* Assign the given `prefix` to a route path or all routes defined in a route group.
*/
prefix(prefix: string): PendingRoute;
/**
* Assign the given `middleware` stack to a route or all routes defined in a route group.
*/
middleware(middleware: string): PendingRoute;
/**
* Register a named middleware.
*/
registerAliasMiddleware(name: string, Middleware: MiddlewareCtor): Router;
}