Class ApiXUrlQueryParameter<T>

An class that defines an optional query parameter in a method.

Query parameters are included in the request URL as such: apix.example.com/entity/method?paramName=paramValue&param2=value2

In this example, there are 2 parameters, paramName and param2, and each has a value of paramValue and value2, respectively.

const queryParameters = [
// input is paramName, so it's expected to be `/entity/method?paramName=some_value`
new ApiXUrlQueryParameter('paramName', someValidator, someProcessor, true),
// input is 'ANOTHER_PARAM', so it's expected to be `/entity/method?ANOTHER_PARAM=some_value`
// use someProcessor to transform the name into something like anotherParam
new ApiXUrlQueryParameter('ANOTHER_PARAM', someValidator, someProcessor)
]

Type Parameters

  • T

Constructors

Accessors

Methods

Constructors

Accessors

Methods

  • A method that validates and processes a parameter into its final form.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

      The express request that contains the query parameters.

    Returns undefined | [string, T]

    The processed key value pair or undefined if missing and not required.

    MissingRequiredParameterError if the parameter is required but missing.

    InvalidParameterError if the parameter validation fails.