Major refactor. Add error handlers everywhere.

This commit is contained in:
Berkeley Martinez
2014-12-23 08:48:28 -08:00
parent e921b637cc
commit 86fcfe8296
18 changed files with 1431 additions and 1529 deletions

View File

@@ -5,19 +5,19 @@
exports.index = function(req, res) {
if (req.user) {
ch = req.user.challengesHash;
if (req.user.challengesHash[0] > 0) {
var max = Object.keys(ch).reduce(function(max,key){
return (max === undefined || ch[key] > ch[max]) ? +key : max;
});
nextChallenge = max + 1;
res.redirect("challenges/" + nextChallenge);
} else {
res.redirect("challenges/0");
}
} else {
res.render('home', {
title: 'Learn to Code and Become a Software Engineer'
ch = req.user.challengesHash;
if (req.user.challengesHash[0] > 0) {
var max = Object.keys(ch).reduce(function(max, key) {
return (max === undefined || ch[key] > ch[max]) ? +key : max;
});
nextChallenge = max + 1;
res.redirect('challenges/' + nextChallenge);
} else {
res.redirect('challenges/0');
}
} else {
res.render('home', {
title: 'Learn to Code and Become a Software Engineer'
});
}
};
};