Type of incoming events.
Type of outgoing responses.
ProtectedconstructorConstructs a Router instance.
Type of incoming events.
Type of outgoing responses.
Configuration options for the router.
Registers a route that supports the GET and HEAD methods.
The route path.
The route handler or functional definition.
The router instance for chaining.
Registers a route that supports all HTTP methods.
The route path.
The route handler or functional definition.
The router instance for chaining.
Configures the router with specific options.
A partial configuration object for the router.
The current Router instance.
Defines multiple route definitions in the router.
An array of route definitions to add.
The current Router instance.
Registers a route that supports the DELETE method.
The route path.
The route handler or functional definition.
The router instance for chaining.
Dispatches an event through the router to find and execute the corresponding route.
The incoming event to process.
A promise resolving to the outgoing response after executing the matched route.
Dumps all routes as an array of JSON objects.
An array of JSON objects representing the routes.
Registers a fallback route to handle unmatched requests.
The handler to execute for the fallback route.
The current Router instance.
One parameter of the route this event resolves to, from any layer.
The sugar over getBoundRoute for the common case: a group middleware reading the
orgCode its guard needs, a locale middleware reading :lang. Named alongside
findRoute, because find* is the family that takes an event and may match, where
getParam reads the already-dispatched current route.
A parameter of a route that does not exist is simply absent, so a miss answers the fallback rather than throwing: deciding that a request is a 404 is the router's job at dispatch, not the caller's at peek.
The incoming event.
The parameter to read.
Optionalfallback: TReturn
What to answer when the route has no such parameter, or no route matches.
The parameter's value, or the fallback.
Finds and matches a route for the given event.
The incoming event to find a route for.
The matched route.
Collects middleware for a specific route, including global and route-specific middleware.
The route for which middleware should be gathered.
An array of middleware to execute for the route.
Generates a URL based on a named route and the provided options.
Options for generating the URL, including the route name, parameters, and query.
The generated URL as a string.
Registers a route that supports the GET and HEAD methods.
The route path.
The route handler or functional definition.
The router instance for chaining.
The route this event resolves to, bound, from any layer.
Before routing (a kernel or group middleware), no route exists on the event yet, and even on the router layer the parameters are only bound after the route middleware have run. Reading a parameter therefore took a three-line dance everywhere: find the route, bind it, read it. This is that dance, done once and remembered per event.
It is a peek, not a dispatch: nothing is emitted, currentRoute is untouched, and the router's
own resolution later proceeds exactly as if nobody had looked. The event's already-resolved route
is reused when there is one, so asking after routing costs one map lookup.
The incoming event.
The bound route.
Retrieves the currently active route.
The current route, or undefined if no route is active.
Retrieves the name of the currently active route.
The name of the current route, or undefined if no route is active.
Retrieves a specific parameter from the current route.
The expected return type of the parameter.
The name of the parameter to retrieve.
Optionalfallback: TReturn
An optional fallback value to return if the parameter is not found.
The value of the parameter, or the fallback value if the parameter is not found.
Retrieves the parameters of the current route.
An object containing the parameters of the current route, or undefined if no route is active.
Retrieves the collection of all routes in the router.
A RouteCollection containing all registered routes.
Creates a route group.
The base path for the group.
Optionaldefinition: Omit<Optional group-specific route definitions.
The router instance for chaining.
Checks if the router contains a route with the given name(s).
A route name or an array of route names to check.
true if at least one of the specified routes exists, false otherwise.
Checks if the currently active route matches the specified name.
The name to compare with the current route's name.
true if the current route's name matches the specified name, false otherwise.
Adds a route to the router for specific HTTP methods.
The path for the route.
The handler to execute or a route definition object.
An array of HTTP methods this route should handle.
The current Router instance.
Navigates to a specific route.
Resolving the destination is platform-independent (a route name becomes a path here);
performing the effect is not, so it is delegated to the configured
RouterNavigator. The default one drives the browser's History API, which is
why this throws outside a browser unless another navigator is configured under
stone.router.navigator.
The path or navigation options, including route name and parameters.
Optionalreplace: boolean
Whether to replace the current history entry instead of adding a new one.
Removes the current group definition, ending the grouping context.
The router instance for chaining.
Unsubscribes from an event emitted by the router's event emitter.
The name of the event to stop listening for.
The listener function to remove.
The current Router instance.
Subscribes to an event emitted by the router's event emitter.
The name of the event to listen for.
The listener function to execute when the event is emitted.
The current Router instance.
Registers a route that supports the OPTIONS method.
The route path.
The route handler or functional definition.
The router instance for chaining.
Registers a route that supports the GET and HEAD methods.
Route is considered as a page route.
The route path.
The route functional definition.
The router instance for chaining.
Registers a route that supports the PATCH method.
The route path.
The route handler or functional definition.
The router instance for chaining.
Registers a route that supports the POST method.
The route path.
The route handler or functional definition.
The router instance for chaining.
Registers a route that supports the PUT method.
The route path.
The route handler or functional definition.
The router instance for chaining.
Dispatches an event to a specific route by its name.
The incoming event to process.
The name of the route to execute.
A promise resolving to the outgoing response after executing the specified route.
Sets the routes for the router using a RouteCollection.
The RouteCollection instance containing routes to set.
The current Router instance.
Adds global middleware to the router.
A single middleware or an array of middleware to add.
The current Router instance.
Attaches middleware to specific routes by their name.
A single route name or an array of route names to attach the middleware to.
A single middleware or an array of middleware to attach.
The current Router instance.
StaticcreateFactory method for creating a router instance.
Configuration options for the router.
A new Router instance.
Represents a configurable router for managing HTTP routes and handling incoming events.