Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AbstractHandler

Partial implementation of the data access handler that can work with and @akera/web instance holding application server(s) configuration.

Hierarchy

Implements

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • Parameters

    • webApp: AkeraWeb

      The @akera/web instance.

    Returns AbstractHandler

Properties

Protected _name

_name: string = ""

Protected _router

_router: express.Router

Protected _webApp

_webApp: AkeraWeb

Accessors

webApp

  • get webApp(): AkeraWeb
  • Returns the @akera/web instance used by the data access handler.

    Returns AkeraWeb

Methods

Protected _error

  • _error(err: Error | string, res?: express.Response, code?: number): void
  • Log an error message and optionally pipe it into the Response.

    Parameters

    • err: Error | string

      The error object or message string.

    • Optional res: express.Response

      The Response instance to pipe the error message.

    • Optional code: number

      The HTTP status code to use.

    Returns void

Protected _log

  • _log(msg: string, level?: LogLevel): void
  • Log a message back to the parrent @akera/web instance.

    Parameters

    • msg: string

      The log message

    • Default value level: LogLevel = LogLevel.info

      The log level

    Returns void

Protected Abstract _mount

  • _mount(broker?: string): express.Router
  • Returns the data access middleware, if the broker name is not passed as input it needs to be retrieved from the first route path parameter.

    Parameters

    • Optional broker: string

      The broker name

    Returns express.Router

init

  • init(): express.Router
  • Returns the middleware that can be mounted on an express route. If there is a single application server configured all requests on the route's root will be dispatched to that broker. When multiple application servers (different alias) are present in configuration then for each alias entry a separate 'sub-route' will be created and all requests on those routes will be dispatched to the respective application server. Requests made on route's root will be rejected with a 405 Method Not Allowed, those for a sub-route that doesn't match the name of any application server alias will be rejected with 404 Broker not found.

    Returns express.Router