Letting Users in the Door

With all the bricks in place, we can add the authenticate Application. Node.js has good authentication libraries, such as Passport,[54] but we’re not going to use them. Using one could be the topic of its own dedicated tutorial, and we want to keep the focus on microservices here.

In any case, let’s dive into the authenticate Application. It needs to do three main things:

  • Present a login form
  • Log users out
  • Handle login requests

As always, let’s start with the top-level function:

 function​ build ({ db, messageStore }) {
 const​ queries = createQueries({ db })
 const​ actions = createActions({ messageStore, queries })
 const​ handlers = createHandlers({ actions })
 

Get Practical Microservices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.