Sign-up Implementation

Let’s apply what we’ve learned about the signup process, and learn how to test an API.

We’ll start implementing the sign-up functionality and all of its logic, which includes the following:

  • Encrypting the password.

  • Validating the data.

  • Updating the database with the new user.

  • Creating the JWT token for that user.

Let’s move directly to the implementation details:

  1. Navigate to the controllers directory and make a new file named user.js.

    cd controllers
    touch user.js
    
  2. Install the bcrypt and jsonwebtoken packages.

    • The bcrypt package helps encrypt the user password before storing it in the database.

    • The jsonwebtoken package allows us to generate a ...