Class: ApplicationRoute
An Application Route.
ApplicationRoute
Constructors
new ApplicationRoute()
new ApplicationRoute(
registry
):ApplicationRoute
Creates an instance of ApplicationRoute.
Parameters
• registry: ApplicationRegistry
Returns
Defined in
types/registry/Routes/AppRouteType.ts:28
Methods
getApplicationRoute()
getApplicationRoute():
object
Gets the Routes's Details.
Returns
object
basePathOverride
basePathOverride:
null
|string
method
method:
Methods
middlewares
middlewares:
MiddlewareHandler
[]
route
route:
string
Defined in
types/registry/Routes/AppRouteType.ts:131
setMethod()
setMethod(
method
):this
Set the method of your route.
Parameters
• method: Methods
Returns
this
Default
Methods.ALL // Accepts any request on any method
Example
this.setMethod(Methods.GET)
Defined in
types/registry/Routes/AppRouteType.ts:55
setRequiredHeaders()
setRequiredHeaders(
headers
):this
Set required headers for your route, this enables a route-specific middleware for managing required headers.
Parameters
• headers: string
[]
Returns
this
Default
[] // No required headers.
Example
this.setRequiredHeaders(['Authorisation', 'Cookie'])
Defined in
types/registry/Routes/AppRouteType.ts:96
setRouteMiddlewares()
setRouteMiddlewares(
middlewares
):this
Set the middlewares for your route.
Includes all globally running middlewares by default.
Define these middlewares using your middlewares
dir.
Parameters
• middlewares: string
[]
Returns
this
Default
[] // No middlewares by default or no middlewares with middlewares running on all routes.
Example
this.setRouteMiddlewares(['authorisationMiddleware'])
Defined in
types/registry/Routes/AppRouteType.ts:72
setRouteName()
setRouteName(
route
):this
Set the route name.
This works with parameters too, works with anything that can go into the first perameter of a request handler.
Parameters
• route: string
Returns
this
Default
'' // Default route is just the root
Example
this.setRouteName('/api/astronauts')
Defined in
types/registry/Routes/AppRouteType.ts:42
useBasePathOverride()
useBasePathOverride(
basePath
):this
Enable the override for the basePath
option in the JovaServer
instance config.
Parameters
• basePath: string
Returns
this
Default
null // Use default basePath of '', also means disabled.
Example
this.useBasePathOverride('/api/iss')