Options
All
  • Public
  • Public/Protected
  • All
Menu

giuseppe-version-plugin

Index

Type aliases

VersionRouter

VersionRouter: GiuseppeRoute & object

Router "route". Does the magic to route to the correct versioned route. Contains no real (i.e. empty) route function, since the configured middleware will redirect anyway.

VersionedRoutes

VersionedRoutes: object

Type that contains a hash for url <-> routes / router matching. An url contains the various routes that are versioned and one router that does the magic to get to a specific route.

Type declaration

Variables

VERSION_KEY

VERSION_KEY: "giuseppe:RouteVersions" = "giuseppe:RouteVersions"

Reflect metadata key for routing versions.

Functions

Version

  • Version(versionInformation?: object): FunctionMethodDecorator
  • Route modificator. Does modify the current route to react only to certain (configured) versions. If a route contains this modificator, a router is injected that checks for the configured version header.

    A route version can contain a "from" version, "until" version and a configurable header name.

    If the route version cannot be parsed by the system, v1 is the default. If no matching route with a given version is found, 404 is returned.

    export

    Parameters

    • Default value versionInformation: object = {}
      • Optional from?: undefined | number
      • Optional headerName?: undefined | string
      • Optional until?: undefined | number

    Returns FunctionMethodDecorator

doRouteVersionsOverlap

getVersionHash

  • getVersionHash(route: string, from: number, until: number): string
  • Creates a unique hash for given version information. Is generally used to register the different versions of a route so that no conflicts exist in express.

    export

    Parameters

    • route: string
    • from: number
    • until: number

    Returns string

    A sha256 hash of the route information.

isInvalid

  • isInvalid(value: number | undefined): boolean
  • Checks if a given version number is valid. A version is valid if:

    • It is a number
    • It is not floating point (e.g. 1.5)
    • It is bigger or equal than 1
    export

    Parameters

    • value: number | undefined

    Returns boolean

isVersionRouter

  • isVersionRouter(route: GiuseppeRoute): boolean
  • Typeguard that checks if a given route is a version-router (i.e. a route that'll never hit it's function since the middleware will route to another function).

    export

    Parameters

    • route: GiuseppeRoute

    Returns boolean

isVersionedRoute

  • isVersionedRoute(route: GiuseppeRoute): boolean
  • Typeguard that checks if a given route is a versioned route (i.e. already contains information about from and until versions).

    export

    Parameters

    • route: GiuseppeRoute

    Returns boolean

Generated using TypeDoc