Documentation
    Preparing search index...

    Store class is used to store a list of routes, along side with their tokens to match the URLs.

    const store = new Store()

    store.add({
    pattern: 'posts/:id',
    handler: function onRoute () {},
    middleware: [],
    matchers: {
    id: '^[0-9]$+'
    },
    meta: {},
    methods: ['GET']
    })

    store.match('posts/1', 'GET')
    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    usingDomains: boolean = false

    A flag to know if routes for explicit domains have been registered

    tree: StoreRoutesTree = ...

    Tree of registered routes and their matchit tokens

    Methods

    • Add a route to the store

      store.add({
      pattern: 'post/:id',
      methods: ['GET'],
      matchers: {},
      meta: {},
      handler: function handler () {
      }
      })

      Parameters

      • route: RouteJSON

        The route to add to the store

      Returns this

      Current RoutesStore instance for method chaining

    • Matches the url, method and optionally domain to pull the matching route. null is returned when unable to match the URL against registered routes.

      The domain parameter has to be a registered pattern and not the fully qualified runtime domain. You must call matchDomain first to fetch the pattern for qualified domain

      Parameters

      • url: string

        The URL to match

      • method: string

        HTTP method

      • shouldDecodeParam: boolean

        Whether to decode parameters

      • Optionaldomain: { tokens: MatchItRouteToken[]; hostname: string }

        Optional domain tokens and hostname

      Returns null | MatchedRoute

      Matched route or null if no match found