Abstract class representing a base controller with commonly used methods for handling requests and parameters. This class extends the ControllerInstance and provides utility methods for parameter retrieval and parsing.

Hierarchy (View Summary)

Constructors

Methods

  • Retrieves and parses the "id" parameter from the given request object.

    Parameters

    • request: Request

      The request object containing parameters.

    • OptionalshouldThrow: boolean = true

      Determines whether an exception should be thrown if the "id" parameter is missing.

    Returns number

    The parsed integer value of the "id" parameter if present, or null if not present and shouldThrow is false.

    Throws an exception if the "id" parameter is missing and shouldThrow is true.

  • Tries to get parameter specified by key from requests route parameters. If the parameter is not found in the request, the default value will be returned.

    Type Parameters

    • T extends string | number | boolean | DateTime<boolean>

    Parameters

    • request: Request

      {Express.Request}

    • key: string

      {string}

    • defaultValue: T

      {T}

    Returns T