lib/app/app-maker.js
function validateRouteDefinition(routeDef) {
  var expectedKeys = ['route', 'type', 'module', 'path'];
  var expectedTypes = ['static', 'module'];
  var expectedTypeMap = {
    'static': 'path',
    'module': 'module'
  };

  var keys = Object.keys(routeDef);
  var EXPECTED_NUMBER_OF_PROPERTIES = 3;
  //Handle warnings first;
  if (routeDef.route && routeDef.route.substr(0, 1) !== '/') {
    log.warn('Route path does not start with a slash:', routeDef.route);
  }

  if(keys.length !== EXPECTED_NUMBER_OF_PROPERTIES) {
    throw new Error('Route definition does not contain all required properties');
  }

  _.map(keys, function compareAgainstExpected(key) {
    if (expectedKeys.indexOf(key) === -1) {
      throw new Error('Unexpected property found in route definition.  Please check the spelling');
    }
  });

  if (expectedTypes.indexOf(routeDef.type) === -1) {
    throw new Error('Unknown type of route.  Please check your configuration');
  }

  if (keys.indexOf(expectedTypeMap[routeDef.type]) === -1) {
    throw new Error('Route type ' + routeDef.type + ' requires ' + expectedTypeMap[routeDef.type] + ' to be defined');
  }

  return true;
}
function validateRouteDefinition(routeDef) {
  var expectedKeys = ['route', 'type', 'module', 'path'];
  var expectedTypes = ['static', 'module'];
  var expectedTypeMap = {
    'static': 'path',
    'module': 'module'
  };

  var keys = Object.keys(routeDef);
  var EXPECTED_NUMBER_OF_PROPERTIES = 3;
  //Handle warnings first;
  if (routeDef.route && routeDef.route.substr(0, 1) !== '/') {
    log.warn('Route path does not start with a slash:', routeDef.route);
  }

  if(keys.length !== EXPECTED_NUMBER_OF_PROPERTIES) {
    throw new Error('Route definition does not contain all required properties');
  }

  _.map(keys, function compareAgainstExpected(key) {
    if (expectedKeys.indexOf(key) === -1) {
      throw new Error('Unexpected property found in route definition.  Please check the spelling');
    }
  });

  if (expectedTypes.indexOf(routeDef.type) === -1) {
    throw new Error('Unknown type of route.  Please check your configuration');
  }

  if (keys.indexOf(expectedTypeMap[routeDef.type]) === -1) {
    throw new Error('Route type ' + routeDef.type + ' requires ' + expectedTypeMap[routeDef.type] + ' to be defined');
  }

  return true;
}
function validateRouteDefinition ( routeDef ) { var expectedKeys = [ 'route' , 'type' , 'module' , 'path' ] ; var expectedTypes = [ 'static' , 'module' ] ; var expectedTypeMap = { 'static' : 'path' , 'module' : 'module' } ; var keys = Object . keys ( routeDef ) ; var EXPECTED_NUMBER_OF_PROPERTIES = 3 ; //Handle warnings first; if ( routeDef . route && routeDef . route . substr ( 0 , 1 ) !== '/' ) { log . warn ( 'Route path does not start with a slash:' , routeDef . route ) ; } if ( keys . length !== EXPECTED_NUMBER_OF_PROPERTIES ) { throw new Error ( 'Route definition does not contain all required properties' ) ; } _ . map ( keys , function compareAgainstExpected ( key ) { if ( expectedKeys . indexOf ( key ) === - 1 ) { throw new Error ( 'Unexpected property found in route definition.  Please check the spelling' ) ; } } ) ; if ( expectedTypes . indexOf ( routeDef . type ) === - 1 ) { throw new Error ( 'Unknown type of route.  Please check your configuration' ) ; } if ( keys . indexOf ( expectedTypeMap [ routeDef . type ] ) === - 1 ) { throw new Error ( 'Route type ' + routeDef . type + ' requires ' + expectedTypeMap [ routeDef . type ] + ' to be defined' ) ; } return true ; }
Validate the incoming route configurations are valie.
@param routeDef
@example
{
'route': '/alwaysStartWithSlash',
'type': 'static' || 'module',
'module' || 'path': 'filePath'
}
@return true if valid otherwise throw an error.
Validate the incoming route configurations are valie .