Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Router

Responsible to hold middleware functions and routes.

Hierarchy

  • Router

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new Router(basePath: string): Router
  • Instanciates a new router.

    Parameters

    • basePath: string

      Router base path that is common to all routes.

    Returns Router

Properties

Private _basePath

_basePath: string

Router's base path that is common to all routes that belong to this router.

Private _queue

_queue: Array<RequestDelegate>

Router's execution queue that contains all functions that are run when handle method is called.

Private _routes

_routes: Array<Route>

Array of routes that belong to this router.

Accessors

basePath

  • get basePath(): string

queue

Methods

handle

match

  • match(path: string, method: string): undefined | Route
  • Returns the route that matches requested path and method, otherwise undefined.

    Parameters

    • path: string

      requested path.

    • method: string

      requested method.

    Returns undefined | Route

use

  • Adds a function to the router execution queue.

    Parameters

    Returns void

useRoutes

  • useRoutes(routes: Route[]): void
  • Adds an array of routes to the router and updates routes path based on router base path.

    Parameters

    • routes: Route[]

      routes that are going to be added.

    Returns void

Generated using TypeDoc