import { RequestMethod } from "../interfaces/route"; import { Routes } from "./httpServer"; import { HttpRequestContext } from "../interfaces/requestContext"; export interface RouterData { /** The Prefix to have the Router available on */ prefix: string; /** The Subrouters this Router contains */ subRouters: Router[]; } export default class Router { private routes; private data; /** * Construct a new Router * @since 0.1.0 */ constructor( /** The Prefix to make this Router available on */ prefix?: string); /** * Add a Route to the router * @since 0.1.0 */ add( /** The Request Method to use */ method: RequestMethod, /** The Path of the Route */ path: string, /** The Code to run on the Request */ run: (ctx: HttpRequestContext) => Promise | unknown): this; /** * Add a Redirect to the router * @since 0.2.0 */ redirect( /** The Path of the Route */ path: string, /** The URL to Redirect to */ url: string): this; /** * Add a Subrouter with prefix * @since 0.1.0 */ prefix( /** The Prefix to add */ prefix: string): Router; /** * Get the Routers Routes * @ignore This is for Internal use only * @since 0.1.0 */ getRoutes(): Routes; }