@evlt/apix
    Preparing search index...

    Interface UrlQueryParameterProcessor<T>

    An object that processes a URL query parameter.

    The processor transforms a parameter's value to a format that a method request handler can work with easily. For example, URL query parameters that include lists are often comma-separated, e.g.: apix.example.com/entity/method?param=value1,value2,value3,value4.

    However, as this is a list, a processor can then turn this value into a ReadonlyArray<string>, as an example. The handler can then be implemented with the assumption that the parameter is processed.

    // transforms comma-separated strings such as `'mylist,of,values'` into
    // readonly arrays such as `['mylist', 'of', 'values']`. The parameter
    // name is always output in camelCase.
    class CommaSeparatedListUrlQueryParameterProcessor implements UrlQueryParameterProcessor<ReadonlyArray<string>> {
    process(name: string, value: string): [string, ReadonlyArray<string>] {
    // any input here has already been pre-validated.
    return [this.snakeCaseToCamelCase(name), value.split(',')];
    }

    // Converts something like snake_case or SNAKE_CASE to snakeCase.
    // it will leave values already in camelCase as camelCase.
    snakeCaseToCamelCase(str: string): string {
    ...
    }
    }
    interface UrlQueryParameterProcessor<T> {
        process(name: string, value: string): [string, T];
    }

    Type Parameters

    • T

    Implemented by

    Index

    Methods

    Methods

    • A method that processes a URL query parameter.

      Parameters

      • name: string

        The name of the parameter to process.

      • value: string

        The value of the parameter to process.

      Returns [string, T]

      Returns a tuple containing the [name, processedValue].