Class Route<TReturn, THandlerParams>

Type Parameters

Hierarchy

  • Route

Constructors

Properties

aliases: Collection<string> = ...
displays: Collection<{
    display: string;
    stage: "handler" | "post" | "pre";
}> = ...
handler?: Constructable<((...x: THandlerParams) => TReturn)>
method: "ws" | HTTPMethod | HTTPMethod[]
parameters: Collection<ParameterProvidingMiddleware<unknown>> = ...
postflight: Collection<ResolvedRouteHandler> = ...
route: string
compiledGroupStack: RouteGroup[] = []

The current nested group stack. This is used internally when compiling the routes by nested group.

registeredGroups: RouteGroup[] = []

Groups of routes that have been registered with the application.

registeredRoutes: Route<unknown, unknown[]>[] = []

Routes that have been created and registered in the application.

Methods

  • Set a programmatic name for this route.

    Parameters

    • name: string

    Returns Route<TReturn, THandlerParams>

  • Type Parameters

    • TKey

    Parameters

    • key: any
    • selector: ((x: TKey) => ((...params: THandlerParams) => TReturn))
        • (x: TKey): ((...params: THandlerParams) => TReturn)
        • Parameters

          • x: TKey

          Returns ((...params: THandlerParams) => TReturn)

            • (...params: THandlerParams): TReturn
            • Parameters

              • Rest ...params: THandlerParams

              Returns TReturn

    Returns HandledRoute<TReturn, THandlerParams>

  • Given a request path, try to extract this route's paramters from the path string.

    Example

    For route /foo/:bar/baz and input /foo/bob/baz, extracts:

    {
    bar: 'bob'
    }

    Parameters

    • potential: string

    Returns undefined | {
        [key: string]: string;
    }

  • Parameters

    • handler: ((...params: THandlerParams) => TReturn)
        • (...params: THandlerParams): TReturn
        • Parameters

          • Rest ...params: THandlerParams

          Returns TReturn

    Returns HandledRoute<TReturn, THandlerParams>

  • Returns true if this route matches the given HTTP verb and request path.

    Parameters

    Returns boolean

  • Prefix the route's path with the given prefix, normalizing / characters.

    Parameters

    • prefix: string

    Returns Route<TReturn, THandlerParams>

  • Load and compile all the registered routes and their groups, accounting for nested groups and resolving handlers.

    This function attempts to resolve the route handlers ahead of time to cache them and also expose any handler resolution errors that might happen at runtime.

    Returns Promise<Route<unknown, unknown[]>[]>

  • Create a new route group with the given prefix.

    Parameters

    • prefix: string
    • group: (() => void | Promise<void>)
        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns RouteGroup