Talk delivered at London Node User Group on 22nd October 2014. Talk covers my personal pain points, issues I've encountered with Node and some suggested alternatives
5. My main pain points & agenda
• Modules + NPM
• Project St ructure
• Async
• Er ror Handl ing
6. Disclaimer
Examples are not a ref lect ion on the
developer / team/company. Based on
problems I ’ v e c a u s e d mysel f or st ruggled
wi th. JavaScr ipt is very subject ive…b l a h
b l a h b l a h… I f y o u ’ r e d o i n g i t r i g h t t h e n
*amazing* ! I ’ m n o t .
Love, Ben x
It’s all about having a good time. If you do blah blah blah you’re going to have a bad time.
getTweetsFor("domenic") // promise-returning function
.then(function (tweets) {
var shortUrls = parseTweetsForUrls(tweets);
var mostRecentShortUrl = shortUrls[0];
return expandUrlUsingTwitterApi(mostRecentShortUrl); // promise-returning function
})
.then(httpGet) // promise-returning function
.then(
function (responseBody) {
console.log("Most recent link text:", responseBody);
},
function (error) {
console.error("Error with the twitterverse:", error);
}
);
app.post('/users', function *(request) {
var user = new User(request.params);
if (yield user.save()) {
return JSON.stringify(user);
} else {
return 422;
}
});
process.on('uncaughtException', function(err) {
// handle the error safely
console.log(err);
});
try {
var files = yield readdir(dir)
} catch (er) {
console.error('something happened whilst reading the directory')
}