Browse Source

hapi-mysql validation fixes

Valentin Agachi 11 years ago
parent
commit
71befa41bc
1 changed files with 4 additions and 4 deletions
  1. 4 4
      hapi/app.js

+ 4 - 4
hapi/app.js

@@ -80,10 +80,10 @@ if (cluster.isMaster) {
 	server.route({
 		method: 'GET',
 		path: '/mysql-orm/{queries?}',
-		handler: function(req){
+		handler: function(req, reply){
 			if (windows) return req.reply(Hapi.error.internal('Not supported on windows'));
 
-			var queries = req.params.queries || 1,
+			var queries = isNaN(req.params.queries) ? 1 : parseInt(req.params.queries, 10),
 				queryFunctions = [];
 
 			queries = Math.min(Math.max(queries, 1), 500);
@@ -95,10 +95,10 @@ if (cluster.isMaster) {
 			}
 
 			async.parallel(queryFunctions, function(err, results){
-				if (queries == 1) {
+				if (!req.params.queries) {
 					results = results[0];
 				}
-				req.reply(results).header('Server', 'hapi');
+				reply(results).header('Server', 'hapi');
 			});
 		}
 	});