Class ContextConditionAnd

Condition that applies if all conditions apply

Example

const condition = new ContextConditionAnd([
new ContextConditionPath("/api/:id"),
new ContextConditionMethod("GET"),
]);

@see {@link ContextCondition}
@see {@link ContextConditionAndJson}

Hierarchy

Constructors

Properties

conditions: ContextCondition[]

Conditions that are chained together

Methods

  • Check if the condition is equal to another condition

    Parameters

    Returns boolean

    Whether the conditions are equal

    Example

    const condition = new ContextConditionAnd([
    new ContextConditionPath("/api/:id"),
    new ContextConditionMethod("GET"),
    ]);

    const other = new ContextConditionAnd([
    new ContextConditionPath("/api/:id"),
    new ContextConditionMethod("GET"),
    ]);

    const other2 = new ContextConditionAnd([
    new ContextConditionPath("/api/:id"),
    new ContextConditionMethod("POST"),
    ]);

    condition.equals(other) // true
    condition.equals(other2) // false

    See

    ContextCondition#equals

  • Get info about the condition (used for collecting info about conditions and squashing them together)

    Returns ConditionInfo

    Info about the condition (used for collecting info about conditions and squashing them together)

    Example

    const condition = new ContextConditionAnd([
    new ContextConditionPath("/api/:id"),
    new ContextConditionMethod("GET"),
    ]);
    const info = condition.info(); // { path: "/api/:id" , method: "GET", path2: undefined }

    See

    ContextCondition#infoJson

  • Parse the condition (used for routing and sub-routing)

    Parameters

    • req: Request

      The request to parse

    Returns ConditionParseResult

    The result of the parsing

    Example

    const condition = new ContextConditionAnd([
    new ContextConditionPath("/api/:id"),
    new ContextConditionMethod("GET"),
    ]);
    const result = condition.parse({ method: "GET", path: "/api/123", params: {} });
    result.applies // true
    result.parameters() // { id: "123" }
    result.subRequest({ method: "GET", path: "/api/123", params: {} }) // { method: "GET", path: "", params: { id: "123" } }

    See

    ConditionParseResult

Generated using TypeDoc