Node Application Patterns: Building an Authentication Module


Rob Conery teaches Node JS

Welcome to Part 4 of this review of the Pluralsight course Node Application Patterns by Rob Conery

Rob has been working in the technology field full time since 1998 as a DBA and then a web developer.

His original focus was the Microsoft ASP.NET stack, building tools like Subsonic and the first Micro-ORM: Massive. He co-founded the online training site with James Avery and co-host This Developer’s Life with Scott Hanselman.

Tekpub was bought out by Pluralsight and he worked there for two years. He is currently working on a new book called The Imposters Handbook.

Node Applications Patterns is the final course in the Node JS learning path.

In the previous module we took our time, and as we built a registration module we saw the patterns and pitfalls that can arise during Node development.

In this module we do it all again with the authentication module, but this time at a faster speed.

Building an Authentication Module at Full Speed

Again, in Real Time

Electronic music plays for the majority of this lesson as we see Rob code the authentication module.

I thought this was fast music, but then I realized that I was listening at 1.7x speed! Watch and listen at a pace that suits your mood.

Debugging Evented Code

At the end of the last clip, Rob runs into a wall: somehow the Registration module has broken! But we were only working on the Authentication module.

If we comment out our authentication tests, we see the Registration tests pass again, so the authentication test code is breaking the registration tests.

Rob gives a good general rule of thumb:

If you see something in JavaScript that absolutely does not make sense, it’s an asynchronous problem

(Also Wes Higbee’s Reasoning About Asynchronous JavaScript may help you)

We see the Mocha error:

Uncaught Error: done() called multiple times

We need to remember to use a new instance for each block when subscribing to events, however this one was even more simple – a second done call in the describe block!

Some more debugging digs up the fact that we have a missing assignment.

With this fixed, more music plays for the rest of this lesson.

Right now, there’s just one more module to go, and it’s a short one. We’re going to integrate our module into a web app.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s