Housekeeping

This commit is contained in:
Mathew Kurian 2014-12-23 13:10:46 -06:00
parent 36812999c8
commit 496f4c5993
2 changed files with 10 additions and 8 deletions

View file

@ -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.");
});
});

View file

@ -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;
});