4.4. Build auth module

In this section, we will proceed to build the auth module.

Pre-setup

Before going further, we need to set up a few things as follows:

  1. Create the auth folder.
  2. In the auth folder, create constants, data-model, functions, helpers, and ports.
  3. In the constants folder, we will need to create files such as roles.ts, teams.ts, and index.ts.

Now open roles.ts and add the following code.

export const ROLES = {
  EMPLOYEE: {
    NAME: "employee",
    SCORE: 1,
  },
  ADMIN: {
    NAME: "admin",
    SCORE: 99,
  },
};

Open teams.ts and add the following code.

export const TEAMS = {
  MARKETING: {
    NAME: "marketing",
  },
  SALES: {
    NAME: "sales",
  },
};

4.4.1

And add the following code to index.ts.

export * from "./roles";
export * from "./teams";

After adding this code, we can also see that the import errors for ROLES and TEAMS in modules/pcustomer-management/ports have been resolved.

4.4.2

OK, the pre-setup step is done; now we will proceed to build this module step by step just like the potential customer management module.

Content

  1. Build the data model
  2. Build the helpers
  3. Build the functions
  4. Build the ports