Tagged: events

Event emitters with success and fail methods for node.js

When it comes to node.js you hear a lot of hype, good and bad, so I’ve finally decided to take the plunge and investigate for myself what the fuss is about. So far it’s been interesting.

I’m not really building anything in particular right now, I’m just playing with different tech stacks to see how things are done. One of the things that I found I liked, while experimenting with node modules, is the syntax success and fail for callback registration. Something like this:

module.doSomething()
      .success(function() { })
      .fail(function() { });

Using this kind of syntax I wanted to have a basic user authentication forwarder that I could wrap route calls in such that only logged in users could call the route. Non logged in users would automatically be forwarded to a twitter oauth route for auto login (done using everyauth).

The first step was to create a custom … Read more