API Docs for: 0.8.3
Show:

MojitoRouter Class

The Routing component of Mojito.

Constructor

MojitoRouter

(
  • store
)
private

Parameters:

  • store Object

    The resource store for the router to use.

Methods

_createEngine

(
  • callback
)
protected async

Attaches view engine yui module to render a view. This is usually needed when running in the client side and loading mojits on demand.

Parameters:

  • callback Function

blend

(
  • base
  • extension
)
Object

Blends a source base object and an overlay object to create a new object containing the recursively merged values of the two. This is similar to performing a copy and then a mergeRecursive operation but is intended to be more performant by avoiding duplicate work.

Parameters:

  • base Object

    The base object. Properties in this object may be overwritten by those in overlay.

  • extension Object

    The "overlay" object. Properties in this object are always found in the result.

Returns:

Object: A new object containing the blended values.

blend3

(
  • lowest
  • medium
  • highest
)
Object

Blends three objects to create a new object containing the recursively merged values of the them all. This is similar to performing copy()s and then mergeRecursive()s but is intended to be more performant by avoiding duplicate work.

The type of the "highest" parameter always dictates type of results.

Parameters:

  • lowest Object

    The lowest priority object. Properties in this object may be overwritten by those in medium and highest.

  • medium Object

    The medium priority object. Properties in this object may be overwritten by those in highest.

  • highest Object

    The highest priority object. Properties in this object are always found in the results.

Returns:

Object: A new object containing the blended values.

createKey

(
  • obj
)
String

Given an object, generate a key that can be used for cache lookup

Parameters:

  • obj Object

Returns:

String:

findClosestLang

(
  • want
  • have
)
String

Parameters:

  • want String

    the desired language code

  • have Object

    an object whose keys are available language codes and whose values are true (for all keys that exist)

Returns:

String: closest matching language code, or an empty string if none match

getRoute

(
  • method
  • url
  • routeMaker
)
Object

Finds a route for a given method+URL

Parameters:

  • method String

    The HTTP method.

  • url String

    The URL to find a route for.

  • routeMaker RouteMaker

    The route maker.

Returns:

Object: The route.

mergeRecursive

(
  • dest
  • src
  • typeMatch
)

Recursively merge properties of two objects

Parameters:

  • dest Object

    The destination object.

  • src Object

    The source object.

  • typeMatch Boolean

    Only replace if src and dest types are the same type if true.

metaMerge

(
  • to
  • from
  • clobber
)
private

Used to merge meta objects into each other. Special consideration for certain headers values like 'content-type'.

Parameters:

  • to Object

    The target object.

  • from Object

    The source object.

  • clobber Boolean

    True to overwrite existing properties.