function loadMiddlewareFilters(filters) {

  var result = [],
      index,
      num = filters.length,
      filter,
      modulePath,
      middleware;

  function startsWith(string, searchString, position) {
    position = position || 0;
    return string.indexOf(searchString, position) === position;
  }

  for (index = 0; index < num; index++ ) {
    filter = filters[index];

    // Check filter has required properties
    if (!filter.id) {
      throw new InvalidConfiguration(InvalidConfiguration.INVALID_FILTER_MESSAGE + " Filter at index " + index + " has no 'id' property.");
    }
    if (!filter.path) {
      throw new InvalidConfiguration(InvalidConfiguration.INVALID_FILTER_MESSAGE + " Filter at index " + index + " has no 'path' property.");
    }

    // Determine module path depending on if it must be loaded from 'filters' folder
    // or node modules.
    modulePath = filter.path;
    if (startsWith(filter.path, ".")) {
      modulePath = path.join(basePath, filter.path);
    }

    // Load filter module and initialize middleware filter
    middleware = require(modulePath).init(filter.id, filter.config);

    result.push({
      id: filter.id,
      path: modulePath,
      config: filter.config,
      middleware: middleware
    });
  }

  return result;
}
function loadMiddlewareFilters(filters) {

  var result = [],
      index,
      num = filters.length,
      filter,
      modulePath,
      middleware;

  function startsWith(string, searchString, position) {
    position = position || 0;
    return string.indexOf(searchString, position) === position;
  }

  for (index = 0; index < num; index++ ) {
    filter = filters[index];

    
    if (!filter.id) {
      throw new InvalidConfiguration(InvalidConfiguration.INVALID_FILTER_MESSAGE + " Filter at index " + index + " has no 'id' property.");
    }
    if (!filter.path) {
      throw new InvalidConfiguration(InvalidConfiguration.INVALID_FILTER_MESSAGE + " Filter at index " + index + " has no 'path' property.");
    }

    
    
    modulePath = filter.path;
    if (startsWith(filter.path, ".")) {
      modulePath = path.join(basePath, filter.path);
    }

    
    middleware = require(modulePath).init(filter.id, filter.config);

    result.push({
      id: filter.id,
      path: modulePath,
      config: filter.config,
      middleware: middleware
    });
  }

  return result;
}
function loadMiddlewareFilters ( filters ) { var result = [ ] , index , num = filters . length , filter , modulePath , middleware ; function startsWith ( string , searchString , position ) { position = position || 0 ; return string . indexOf ( searchString , position ) === position ; } for ( index = 0 ; index < num ; index ++ ) { filter = filters [ index ] ; // Check filter has required properties if ( ! filter . id ) { throw new InvalidConfiguration ( InvalidConfiguration . INVALID_FILTER_MESSAGE + " Filter at index " + index + " has no 'id' property." ) ; } if ( ! filter . path ) { throw new InvalidConfiguration ( InvalidConfiguration . INVALID_FILTER_MESSAGE + " Filter at index " + index + " has no 'path' property." ) ; } // Determine module path depending on if it must be loaded from 'filters' folder // or node modules. modulePath = filter . path ; if ( startsWith ( filter . path , "." ) ) { modulePath = path . join ( basePath , filter . path ) ; } // Load filter module and initialize middleware filter middleware = require ( modulePath ) . init ( filter . id , filter . config ) ; result . push ( { id : filter . id , path : modulePath , config : filter . config , middleware : middleware } ) ; } return result ; }
Loads the modules associated to each filter and returns an array of middlewares.

@private
@param  {Array} filters Array with filters configuration
@returns {Array<object>} Array with filter's configuration plus a middleware
object referencing the loaded filter's module.
Loads the modules associated to each filter and returns an array of middlewares .