Members
(static) dependencies :Array.<string>
- Source:
Class dependencies:
['app', 'server', 'router.handler', 'router.route', 'router.controller']
.
Methods
get(path, action)
- Source:
Register a new GET route with the router.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The route path. |
action |
string | function | The route action. |
Returns:
The newly created route instance.
- Type
- http.Route
post(path, action)
- Source:
Register a new POST route with the router.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The route path. |
action |
string | function | The route action. |
Returns:
The newly created route instance.
- Type
- http.Route
put(path, action)
- Source:
Register a new PUT route with the router.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The route path. |
action |
string | function | The route action. |
Returns:
The newly created route instance.
- Type
- http.Route
patch(path, action)
- Source:
Register a new PATCH route with the router.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The route path. |
action |
string | function | The route action. |
Returns:
The newly created route instance.
- Type
- http.Route
delete(path, action)
- Source:
Register a new DELETE route with the router.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The route path. |
action |
string | function | The route action. |
Returns:
The newly created route instance.
- Type
- http.Route
any(path, action)
- Source:
Register a new route responding to all verbs.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The route path. |
action |
string | function | The route action. |
Returns:
The newly created route instance.
- Type
- http.Route
all(path, action)
- Source:
Register a new route responding to all verbs.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The route path. |
action |
string | function | The route action. |
Returns:
The newly created route instance.
- Type
- http.Route
fallback(action)
- Source:
Register a fallback route that matches anything in the current scope.
Parameters:
Name | Type | Description |
---|---|---|
action |
string | function | The route action. |
Returns:
The newly created route instance.
- Type
- http.Route
redirect(from, to, permanentopt)
- Source:
Create a redirection route.
The redirection can either be permanent or temporary.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
from |
string | The path to redirect from. | ||
to |
string | The destination path to redirect on. | ||
permanent |
boolean |
<optional> |
false
|
Indicates that the redirection is permanent. |
Returns:
The newly created route instance.
- Type
- http.Route
permanentRedirect(from, to)
- Source:
Create a permanent redirection route.
Parameters:
Name | Type | Description |
---|---|---|
from |
string | The path to redirect from. |
to |
string | The destination path to redirect on. |
Returns:
The newly created route instance.
- Type
- http.Route
static(path, folder)
- Source:
Register a static path for files.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The path for static route serving. |
folder |
string | The folder where the static content is hosted. |
Returns:
The newly created route instance.
- Type
- http.Route
withCorePrefix(name)
- Source:
Get controller name with core prefix.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The controller name. |
Returns:
The fully qualified controller name.
- Type
- string
controller(name, controller)
- Source:
Add a controller binding.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The controller name. |
controller |
http.controllers.Controller | The controller class. |
Returns:
The controller repository instance.
controllerGroup(namespace, group)
- Source:
Create a controller group.
Parameters:
Name | Type | Description |
---|---|---|
namespace |
string | The controller namespace. |
group |
function | The controller group closure. |
Returns:
The controller repository instance.
resource(resource, controller, onlyopt, apiOnlyopt)
- Source:
Create resource routes.
Uses the same controller for each resource route with the proper action.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
resource |
string | The resource for which the routes should be created. | ||
controller |
string | The resource controller name that will handle requests. | ||
only |
Array.<string> |
<optional> |
Indicates the routes restrictions. | |
apiOnly |
boolean |
<optional> |
false
|
Indicates that only API routes should be considered. |
Returns:
The current router instance.
- Type
- http.services.Router
apiResource(resource, controller, onlyopt)
- Source:
Create API resource routes, without "create" and "edit" routes, which normally show form.
Uses the same controller for each resource route with the proper action.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
resource |
string | The resource for which the routes should be created. | ||
controller |
string | The resource controller name that will handle requests. | ||
only |
Array.<string> |
<optional> |
[]
|
Indicates the routes restrictions. |
Returns:
The current router instance.
- Type
- http.services.Router
group(options, group)
- Source:
Create a route group.
Parameters:
Name | Type | Description |
---|---|---|
options |
http.GroupOptions | The group options. |
group |
function | The group closure. |
Returns:
The current router instance.
- Type
- http.services.Router
addRoute(method, path, action)
- Source:
Add a route in the route repository.
Parameters:
Name | Type | Description |
---|---|---|
method |
string | The HTTP verb, such as "GET", "POST", "DELETE", etc. |
path |
string | The route path. |
action |
string | function | The action that will handle the request. |
Returns:
The newly created route instance.
- Type
- http.Route
makeRoute(attributes)
- Source:
Create a new route instance.
Parameters:
Name | Type | Description |
---|---|---|
attributes |
http.RouteAttributes | The route attributes. |
Returns:
The newly created route instance.
- Type
- http.Route
getRouteMapping(route)
- Source:
Get route or route group mapping.
Parameters:
Name | Type | Description |
---|---|---|
route |
http.Route | The route instance. |
Returns:
The route mapping.
- Type
- http.RouteAttributes
getRouteAsPrefixMapping(route)
- Source:
Get route or route group asPrefix mapping.
Parameters:
Name | Type | Description |
---|---|---|
route |
http.Route | The route instance. |
Returns:
The route name prefix.
- Type
- string
getRoutePathMapping(route)
- Source:
Get route or route group path mapping.
Parameters:
Name | Type | Description |
---|---|---|
route |
http.Route | The route instance. |
Returns:
The full route path.
- Type
- string
getRouteActionMapping(route)
- Source:
Get route or route group action mapping.
Parameters:
Name | Type | Description |
---|---|---|
route |
http.Route | The route instance. |
Returns:
The route action name.
- Type
- string
generate()
- Source:
Generate route binding in Express server.
Returns:
The Express Router instance.
- Type
- express.Router
call(path, methodopt, requestopt)
- Source:
Call the route handler.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
path |
string | The route path. | ||
method |
string |
<optional> |
get
|
The HTTP method to use. |
request |
* |
<optional> |
The request instance to use. |
Returns:
The async process promise.
- Type
- Promise
runMiddleware(path, request)
- Source:
Manually run middleware to programmatically process an internal request.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The route path. |
request |
request | The request instance to use. |
Returns:
The HTTP code result and the response body.
- Type
- Promise.<{code: number, data: *}>
callByName(name, parametersopt, requestopt)
- Source:
Call the route handler associated with the given name.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string | The route name. | ||
parameters |
object |
<optional> |
{}
|
The route parameters. |
request |
object | request |
<optional> |
{}
|
The request instance to use. |
Returns:
The async process promise.
- Type
- Promise
getResourceMapping(resource, controller)
- Source:
Get the resource mapping data.
Parameters:
Name | Type | Description |
---|---|---|
resource |
string | The resource from which to get the mapping. |
controller |
string | The controller name. |
Returns:
The List of resource action mapping.
- Type
- Array.<object>
getResourceData(resource, controller, action)
- Source:
Get single resource route data.
Parameters:
Name | Type | Description |
---|---|---|
resource |
string | The resource from which to get data. |
controller |
string | The controller name. |
action |
string | The controller action name. |
Returns:
The resource data.
- Type
- http.ResourceData
getResourceActions()
- Source:
Get available resource actions.
Returns:
The resource actions.
- Type
- Array.<{name: string, method: string, single: boolean}>
getResourceAction(action)
- Source:
Get single resource action data.
Parameters:
Name | Type | Description |
---|---|---|
action |
string | The action name. |
Returns:
The resource action.
- Type
- http.ResourceAction
getResourceActionMethod(action)
- Source:
Get single resource action method name.
Parameters:
Name | Type | Description |
---|---|---|
action |
string | The action name. |
Returns:
The resource action HTTP method.
- Type
- string
getResourceUrlMapping(resource, action)
- Source:
Get single resource action URL mapping.
Parameters:
Name | Type | Description |
---|---|---|
resource |
string | The resource name. |
action |
string | The resource action. |
Returns:
The URL for the resource for the specific action.
- Type
- string
resolvePath(path, constraints)
- Source:
Resolve Express path based on given path and parameter constraints.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The route path. |
constraints |
* | The constraints for route parameters. |
Returns:
The resolved path.
- Type
- string
getServer()
- Source:
Get server instance.
Returns:
The Express server instance.
- Type
- Express