Skip to main content

Class: DynamicRoute

Defined in: packages/core/src/router/DynamicRoute.ts:51

Utility for representing and manipulating a single dynamic route in the router's configuration. Dynamic route is defined by regExp used for route matching and overrides for toPath and extractParameters functions to generate and put together valid path.

Extends

Constructors

new DynamicRoute()

new DynamicRoute(name, pathExpression, controller, view, options?): DynamicRoute

Defined in: packages/core/src/router/DynamicRoute.ts:58

Initializes the route.

Parameters

name

string

pathExpression

RoutePathExpression

Path expression used in route matching, to generate valid path with provided params and parsing params from current path.

controller

AsyncRouteController

view

AsyncRouteView

options?

Partial<RouteFactoryOptions>

Returns

DynamicRoute

Overrides

AbstractRoute.constructor

Properties

_controller

protected _controller: object

Defined in: packages/core/src/router/AbstractRoute.ts:58

The full name of Object Container alias identifying the controller associated with this route.

cached

cached: null | RouteController | Promise<RouteController>

controller

controller: AsyncRouteController

resolved

resolved: boolean

Inherited from

AbstractRoute._controller


_name

protected _name: string

Defined in: packages/core/src/router/AbstractRoute.ts:48

The unique name of this route, identifying it among the rest of the routes in the application.

Inherited from

AbstractRoute._name


_options

protected _options: RouteFactoryOptions

Defined in: packages/core/src/router/AbstractRoute.ts:76

The route additional options.

Inherited from

AbstractRoute._options


_pathExpression

protected _pathExpression: RoutePathExpression

Defined in: packages/core/src/router/AbstractRoute.ts:53

Path expression used in route matching, to generate valid path with provided params and parsing params from current path.

Inherited from

AbstractRoute._pathExpression


_view

protected _view: object

Defined in: packages/core/src/router/AbstractRoute.ts:67

The full name or Object Container alias identifying the view class associated with this route.

cached

cached: null | RouteView | Promise<RouteView>

resolved

resolved: boolean

view

view: AsyncRouteView

Inherited from

AbstractRoute._view

Methods

extractParameters()

extractParameters(path, baseUrl): RouteParams

Defined in: packages/core/src/router/DynamicRoute.ts:112

Extracts the parameter values from the provided path. The method extracts both the in-path parameters and parses the query, allowing the query parameters to override the in-path parameters.

The method returns an empty hash object if the path does not match this route.

Parameters

path

string

Currently routed path.

baseUrl

string

Currently routed baseUrl.

Returns

RouteParams

Map of parameter names to parameter values.

Overrides

AbstractRoute.extractParameters


getController()

getController(): RouteController | Promise<RouteController>

Defined in: packages/core/src/router/AbstractRoute.ts:153

Returns Controller class/alias/constant associated with this route. Internally caches async calls for dynamically imported controllers, meaning that once they're loaded, you get the same promise for subsequent calls.

Returns

RouteController | Promise<RouteController>

The Controller class/alias/constant.

Inherited from

AbstractRoute.getController


getName()

getName(): string

Defined in: packages/core/src/router/AbstractRoute.ts:132

Returns the unique identifying name of this route.

Returns

string

The name of the route, identifying it.

Inherited from

AbstractRoute.getName


getOptions()

getOptions(): RouteFactoryOptions

Defined in: packages/core/src/router/AbstractRoute.ts:210

Return route additional options.

Returns

RouteFactoryOptions

Inherited from

AbstractRoute.getOptions


getPathExpression()

getPathExpression(): RoutePathExpression

Defined in: packages/core/src/router/AbstractRoute.ts:220

Path expression used in route matching, to generate valid path with provided params and parsing params from current path.

Returns

RoutePathExpression

The path expression.

Inherited from

AbstractRoute.getPathExpression


getTrimmedPath()

getTrimmedPath(path): string

Defined in: packages/core/src/router/AbstractRoute.ts:230

Trims the trailing forward slash from the provided URL path.

Parameters

path

string

The path to trim.

Returns

string

Trimmed path.

Inherited from

AbstractRoute.getTrimmedPath


getView()

getView(): RouteView | Promise<RouteView>

Defined in: packages/core/src/router/AbstractRoute.ts:185

Returns View class/alias/constant associated with this route. Internally caches async calls for dynamically imported views, meaning that once they're loaded, you get the same promise for subsequent calls.

Returns

RouteView | Promise<RouteView>

The View class/alias/constant.

Inherited from

AbstractRoute.getView


isAsync()

isAsync(module): boolean

Defined in: packages/core/src/router/AbstractRoute.ts:139

Checks if given argument is an async handler.

Parameters

module

unknown

Returns

boolean

Inherited from

AbstractRoute.isAsync


isControllerResolved()

isControllerResolved(): boolean

Defined in: packages/core/src/router/AbstractRoute.ts:173

Returns true for resolved controller. This is always true for sync route views.

Returns

boolean

Inherited from

AbstractRoute.isControllerResolved


isViewResolved()

isViewResolved(): boolean

Defined in: packages/core/src/router/AbstractRoute.ts:203

Returns true for resolved view. This is always true for sync route views.

Returns

boolean

Inherited from

AbstractRoute.isViewResolved


matches()

matches(path): boolean

Defined in: packages/core/src/router/DynamicRoute.ts:105

Tests whether the provided URL path matches this route. The provided path may contain the query.

Parameters

path

string

The URL path.

Returns

boolean

true if the provided path matches this route.

Overrides

AbstractRoute.matches


preload()

preload(): Promise<[RouteController, RouteView]>

Defined in: packages/core/src/router/AbstractRoute.ts:239

Preloads dynamically imported view and controller.

Returns

Promise<[RouteController, RouteView]>

Promise.All resolving to [view, controller] tuple.

Inherited from

AbstractRoute.preload


toPath()

toPath(params): string

Defined in: packages/core/src/router/DynamicRoute.ts:98

Creates the URL and query parts of a URL by substituting the route's parameter placeholders by the provided parameter value.

The extraneous parameters that do not match any of the route's placeholders will be appended as the query string.

Parameters

params

The route parameter values.

Returns

string

Path and, if necessary, query parts of the URL representing this route with its parameters replaced by the provided parameter values.

Overrides

AbstractRoute.toPath