Sign-up Implementation
Let’s apply what we’ve learned about the signup process, and learn how to test an API.
We'll cover the following...
We'll cover the following...
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:
-
Navigate to the
controllersdirectory and make a new file nameduser.js.cd controllers touch user.js -
Install the
bcryptandjsonwebtokenpackages.-
The
bcryptpackage helps encrypt the user password before storing it in the database. -
The
jsonwebtokenpackage allows us to generate a signed JWT token. ...
-