From 496f4c5993f8a66c41864825bdc785f7d47bd8e3 Mon Sep 17 00:00:00 2001 From: Mathew Kurian Date: Tue, 23 Dec 2014 13:10:46 -0600 Subject: [PATCH] Housekeeping --- herokuapp/app.js | 10 ++++++---- herokuapp/public/js/index.js | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/herokuapp/app.js b/herokuapp/app.js index 6112aa3..61a3b09 100644 --- a/herokuapp/app.js +++ b/herokuapp/app.js @@ -7,6 +7,7 @@ app = express(); console.addLogger('log', 'green'); + console.addLogger('err', 'red'); // port app.set('port', (process.env.PORT || 5000)); @@ -46,8 +47,8 @@ var tag = req.param('tag'); var msg = req.param('msg'); - if (typeof msg === 'undefined') { - return res.status(400).send('`msg` param not defined'); + if (!msg) { + return res.status(400).send('Param `msg` not defined'); } try { @@ -63,11 +64,12 @@ console.tag(tag).log(msg); } - res.status(200).send("server logged message"); + res.status(200).send("Server logged message"); }); req.on('close', function(err){ - res.status(400).json(err); + console.err(err); + res.status(400).json("Server read stream closed unexpectedly. Check console."); }); }); diff --git a/herokuapp/public/js/index.js b/herokuapp/public/js/index.js index 62707a6..fb9e8a4 100644 --- a/herokuapp/public/js/index.js +++ b/herokuapp/public/js/index.js @@ -17,10 +17,10 @@ $.post("/", { tag : tag, msg : msg - }, function(/*data*/){ - alert("Message sent"); - }).fail(function(/*err*/) { - alert( "Message error" ); + }, function(data){ + alert(data); + }).fail(function(err) { + alert(err.responseText); }).always(function() { _submit = false; });