src/server/router.js
function methodLoader(modules) {
  return function(req, res, next) {
    if (req.path === '/') return next();

    var path = req.path.substr(1).split('/');
    var currModule = modules;
    var isLastIndex, p, method;

    debug('Looking for isomorphine entity in: ' + path.join('.'));

    for (var i = 0, len = path.length; i < len; i++) {
      isLastIndex = i === (len - 1);
      p = path[i];

      // Expect a function when last index
      if (isLastIndex && isES6Function(currModule[p])) {
        method = getES6Function(currModule[p]);
      }

      // Expect an object when not last index
      else if (!isLastIndex && isObject(currModule[p])) {
        currModule = currModule[p];
      }

      // Return a 404 if the entity was not found
      else {
        return next(createError(404, 'No method found at this path'));
      }
    }

    // Reference the serverside method in req
    debug('Entity found');
    req.serversideMethod = method;

    next();
  };
}
function methodLoader(modules) {
  return function(req, res, next) {
    if (req.path === '/') return next();

    var path = req.path.substr(1).split('/');
    var currModule = modules;
    var isLastIndex, p, method;

    debug('Looking for isomorphine entity in: ' + path.join('.'));

    for (var i = 0, len = path.length; i < len; i++) {
      isLastIndex = i === (len - 1);
      p = path[i];

      // Expect a function when last index
      if (isLastIndex && isES6Function(currModule[p])) {
        method = getES6Function(currModule[p]);
      }

      // Expect an object when not last index
      else if (!isLastIndex && isObject(currModule[p])) {
        currModule = currModule[p];
      }

      // Return a 404 if the entity was not found
      else {
        return next(createError(404, 'No method found at this path'));
      }
    }

    // Reference the serverside method in req
    debug('Entity found');
    req.serversideMethod = method;

    next();
  };
}
function methodLoader ( modules ) { return function ( req , res , next ) { if ( req . path === '/' ) return next ( ) ; var path = req . path . substr ( 1 ) . split ( '/' ) ; var currModule = modules ; var isLastIndex , p , method ; debug ( 'Looking for isomorphine entity in: ' + path . join ( '.' ) ) ; for ( var i = 0 , len = path . length ; i < len ; i ++ ) { isLastIndex = i === ( len - 1 ) ; p = path [ i ] ; // Expect a function when last index if ( isLastIndex && isES6Function ( currModule [ p ] ) ) { method = getES6Function ( currModule [ p ] ) ; } // Expect an object when not last index else if ( ! isLastIndex && isObject ( currModule [ p ] ) ) { currModule = currModule [ p ] ; } // Return a 404 if the entity was not found else { return next ( createError ( 404 , 'No method found at this path' ) ) ; } } // Reference the serverside method in req debug ( 'Entity found' ) ; req . serversideMethod = method ; next ( ) ; } ; }
Maps the parameter "entity" to the actual server-side entity.

@param {Object}  modules  The entities available in this api.
@returns {Function}       Middleware function that maps the :entity param
with the real entity, and exposes it in req.
Maps the parameter entity to the actual server - side entity .