Options
All
  • Public
  • Public/Protected
  • All
Menu

A class that can be used to build and reference dynamic routes in the application.

Routes can be defined in nested groups, with prefixes and middleware handlers.

example
Route.post('/api/v1/ping', (request: Request) => {
    return 'pong!'
})

Route.group('/api/v2', () => {
    Route.get('/status', 'controller::api:v2:Status.getStatus').pre('auth:UserOnly')
})

Hierarchy

Index

Constructors

constructor

Properties

aliases

aliases: string[] = []

Programmatic aliases of this route.

Protected Optional compiledHandler

compiledHandler: ResolvedRouteHandler

Pre-compiled route handlers for the post-middleware for this route.

Protected Optional compiledPostflight

compiledPostflight: ResolvedRouteHandler[]

Pre-compiled route handler for the main route handler for this route.

Protected Optional compiledPreflight

compiledPreflight: ResolvedRouteHandler[]

Pre-compiled route handlers for the pre-middleware for this route.

Protected Readonly handler

handler: RouteHandler

Protected method

Protected middlewares

middlewares: Collection<{ handler: RouteHandler; stage: "post" | "pre" }> = ...

Middlewares that should be applied to this route.

Protected route

route: string

Static Private compiledGroupStack

compiledGroupStack: RouteGroup[] = []

The current nested group stack. This is used internally when compiling the routes by nested group.

Static Private registeredGroups

registeredGroups: RouteGroup[] = []

Groups of routes that have been registered with the application.

Static Private registeredRoutes

registeredRoutes: Route[] = []

Routes that have been created and registered in the application.

Accessors

Private appClassApplication

Methods

alias

  • alias(name: string): Route

Protected app

Private appendMiddleware

  • appendMiddleware(def: { handler: RouteHandler; stage: "post" | "pre" }): void

Private compileResolvedHandler

Protected container

extract

  • extract(potential: string): undefined | {}
  • Given a request path, try to extract this route's paramters from the path string.

    example

    For route /foo/:bar/baz and input /foo/bob/baz, extracts:

    {
        bar: 'bob'
    }
    

    Parameters

    • potential: string

    Returns undefined | {}

getBoundMethod

  • getBoundMethod(methodName: string): (...args: any[]) => any
  • Get the method with the given name from this class, bound to this class.

    Parameters

    • methodName: string

    Returns (...args: any[]) => any

    function

      • (...args: any[]): any
      • Parameters

        • Rest ...args: any[]

        Returns any

getDisplayableHandler

  • getDisplayableHandler(): string

getMethod

getMiddlewares

getRoute

  • getRoute(): string

Protected make

  • make<T>(target: any, ...parameters: any[]): T

match

  • match(method: HTTPMethod, potential: string): boolean

post

pre

Private prepend

  • prepend(prefix: string): Route

Private prependMiddleware

  • prependMiddleware(def: { handler: RouteHandler; stage: "post" | "pre" }): void

resolveHandler

Private resolveMiddlewareHandlersForStage

resolvePostflight

resolvePreflight

toString

  • toString(): string

Static any

Static compile

  • compile(): Promise<Route[]>
  • Load and compile all of the registered routes and their groups, accounting for nested groups and resolving handlers.

    This function attempts to resolve the route handlers ahead of time to cache them and also expose any handler resolution errors that might happen at runtime.

    Returns Promise<Route[]>

Static delete

Static endpoint

Static get

Static group

  • group(prefix: string, group: () => void | Promise<void>): RouteGroup
  • Create a new route group with the given prefix.

    Parameters

    • prefix: string
    • group: () => void | Promise<void>
        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns RouteGroup

Static patch

Static post

Static put

Static registerGroup

Extollo Logo

extollo (v. latin) - to lift up, to elevate

Extollo is a free & libre application framework in TypeScript.