File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -57,18 +57,24 @@ module.exports = function (source) {
5757
5858  // Create routes 
5959  for  ( var  prop  in  db . object )  { 
60-     if  ( _ . isPlainObject ( db . object [ prop ] ) )  { 
60+     var  val  =  db . object [ prop ] 
61+ 
62+     if  ( _ . isPlainObject ( val ) )  { 
6163      router . use ( '/'  +  prop ,  singular ( db ,  prop ) ) 
6264      continue 
6365    } 
6466
65-     if  ( _ . isArray ( db . object [ prop ] ) )  { 
67+     if  ( _ . isArray ( val ) )  { 
6668      router . use ( '/'  +  prop ,  plural ( db ,  prop ) ) 
6769      continue 
6870    } 
6971
70-     throw  new  Error ( 'Unsupported type' ) 
72+     var  msg  = 
73+       'Type of "'  +  prop  +  '" ('  +  typeof  val  +  ') '  + 
74+       ( _ . isObject ( source )  ? ''  : 'in '  +  source )  +  ' is not supported. '  + 
75+       'Use objects or arrays of objects.' 
7176
77+     throw  new  Error ( msg ) 
7278  } 
7379
7480  router . use ( function  ( req ,  res )  { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments