Options
All
  • Public
  • Public/Protected
  • All
Menu

Module storage/conversion/ConversionUtil

Index

Functions

Const matchingMediaType

  • matchingMediaType(mediaA: string, mediaB: string): boolean
  • Checks if the given two media types/ranges match each other. Takes wildcards into account.

    Parameters

    • mediaA: string

      Media type to match.

    • mediaB: string

      Media type to match.

    Returns boolean

    True if the media type patterns can match each other.

Const matchingTypes

  • Filters media types based on the given preferences. Based on RFC 7231 - Content negotiation. Will add a default internal/*;q=0 to the preferences to prevent accidental use of internal types. Since more specific media ranges override less specific ones, this will be ignored if there is a specific internal type preference.

    throws

    BadRequestHttpError If the type preferences are undefined or if there are duplicate preferences.

    Parameters

    • preferences: RepresentationPreferences

      Preferences for output type.

    • types: string[]

      Media types to compare to the preferences.

    Returns RepresentationPreference[]

    The weighted and filtered list of matching types.

Const validateRequestArgs

  • Runs some standard checks on the input request:

    • Checks if there is a content type for the input.
    • Checks if the input type is supported by the parser.
    • Checks if the parser can produce one of the preferred output types.

    Parameters

    • request: RepresentationConverterArgs

      Incoming arguments.

    • supportedIn: string[]

      Media types that can be parsed by the converter.

    • supportedOut: string[]

      Media types that can be produced by the converter.

    Returns void