A flag to know if routes for explicit domains have been registered. The boolean is computed after calling the "commit" method.
Shortcut methods for commonly used route matchers
Query string parser for making URLs
The URLBuilder offers a type-safe API for creating URL for pre-registered routes or the route patterns.
We recommend using the URLBuilder over the "makeUrl" and "makeSignedUrl" methods.
Check if routes have been committed to the store. Once routes are committed, defining new set of routes will have no impact
Parses the route pattern
The route pattern to parse
Optional
matchers: RouteMatchersOptional route matchers
Define an array of middleware to use on all the routes. Calling this method multiple times pushes to the existing list of middleware
Array of middleware classes to apply globally
Current Router instance for method chaining
Define a collection of named middleware. The defined collection is not registered anywhere, but instead converted in a new collection of functions you can apply on the routes, or router groups.
Object mapping middleware names to middleware classes
Named middleware functions
Add route for a given pattern and methods
The route pattern
Array of HTTP methods
Route handler (function, string, or controller tuple)
The created route instance
Define a route that handles all common HTTP methods
The route pattern
Route handler (function, string, or controller tuple)
The created route instance
Creates a group of routes. A route group can apply transforms to routes in bulk
Function that defines routes within the group
The created route group instance
Registers a route resource with conventional set of routes
The resource name
Controller to handle the resource
The created route resource instance
Register a route resource with shallow nested routes.
The resource name
Controller to handle the resource
The created route resource instance
Returns a brisk route instance for a given URL pattern
The route pattern
The created brisk route instance
Define matcher for a given param. The global params are applied on all the routes (unless overridden at the route level).
The parameter name to match
The matcher pattern (RegExp, string, or RouteMatcher)
Current Router instance for method chaining
Commit routes to the store. The router is freezed after the commit method is called.
Finds a route by its identifier. The identifier can be the route name, controller.method name or the route pattern itself.
When "disableLegacyLookup" is set, the lookup will be performed only using the route name
Route name, pattern, or controller reference
Optional
domain: stringOptional domain to search within
Optional
method: stringOptional HTTP method to filter by
Optional
disableLegacyLookup: booleanWhether to disable legacy lookup strategies
Found route or null if not found
Finds a route by its identifier. The identifier can be the route name, controller.method name or the route pattern itself.
An error is raised when unable to find the route.
When "disableLegacyLookup" is set, the lookup will be performed only using the route name
Route name, pattern, or controller reference
Optional
domain: stringOptional domain to search within
Optional
method: stringOptional HTTP method to filter by
Optional
disableLegacyLookup: booleanWhether to disable legacy lookup strategies
Found route
Check if a route exists. The identifier can be the route name, controller.method name or the route pattern itself.
When "followLookupStrategy" is enabled, the lookup will be performed on the basis of the lookup strategy enabled via the "lookupStrategies" method. The default lookupStrategy is "name" and "pattern".
Route name, pattern, or controller reference
Optional
domain: stringOptional domain to search within
Optional
method: stringOptional HTTP method to filter by
Optional
followLookupStrategy: booleanWhether to follow the configured lookup strategy
True if route exists, false otherwise
Returns a list of routes grouped by their domain names
Object mapping domain names to route arrays
Generates types for the URL builder. These types must be written inside a file for the URL builder to pick them up.
Indentation level for generated types
Generated TypeScript types as string
Find route for a given URL, method and optionally domain
The URI to match
HTTP method
Whether to decode parameters
Optional
hostname: null | stringOptional hostname for domain matching
Matched route or null if no match found
Create URL builder instance.
Make URL to a pre-registered route
Optional
params: any[] | Record<string, any>Optional
options: MakeUrlOptionsMakes a signed URL to a pre-registered route.
Optional
params: any[] | Record<string, any>Optional
options: MakeSignedUrlOptions
Router class exposes a unified API to register new routes, group them or create route resources.