The Auth micro app

The Auth micro app will handle authentications in different scenarios. It's going to be our main entry point to authenticate users, using stateful and stateless approaches.

Our core module already exposes middleware to check whether a user is authenticated or not, and authorization-related middleware. This functionality can be used in any module or micro app.

Defining the class

This is going to be our first micro app, so let's go through a few steps:

  1. Create a new micro app called apps/auth/index.js.
  2. Add the following base content:
    'use strict'
    
    const express = require('express');
    const router = express.Router();
    const Controller = require('./controller');
    
    class Auth {
    }
  3. Define the constructor:
     constructor(config, core, app) { this.core ...

Get Web Application Development with MEAN 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.