Module: userController

Handles user-related operations such as registration.
Source:

Methods

(async, static) loginUser(req, res) → {Promise.<void>}

The function `loginUser` handles user login by validating input, retrieving user data from the database, comparing the password, generating a JWT token, and sending a response.
Parameters:
Name Type Description
req Object The HTTP request object, containing information about the incoming request.
Properties
Name Type Description
body Object The body of the request, containing user login data.
Properties
Name Type Description
email string The email of the user.
password string The password of the user.
res Object The HTTP response object, used to send the response back to the client.
Source:
Throws:
- Throws an error if validation fails or if there is an issue with database interaction.
Type
Error
Returns:
- A promise that resolves to sending a response to the client.
Type
Promise.<void>

(async, static) refreshToken(req, res) → {Promise.<void>}

The function `refreshToken` handles refreshing a JWT token by verifying the refresh token, generating a new JWT token, and sending a response.
Parameters:
Name Type Description
req Object The HTTP request object, containing information about the incoming request.
Properties
Name Type Description
body Object The body of the request, containing the refresh token.
Properties
Name Type Description
token string The refresh token to be verified.
res Object The HTTP response object, used to send the response back to the client.
Source:
Throws:
- Throws an error if the refresh token is missing or invalid.
Type
Error
Returns:
- A promise that resolves to sending a response to the client.
Type
Promise.<void>

(async, static) registerUser(req, res) → {Promise.<void>}

The function `registerUser` handles user registration by validating input, hashing the password, inserting user data into a database, generating a JWT token, and sending a response.
Parameters:
Name Type Description
req Object The HTTP request object, containing information about the incoming request.
Properties
Name Type Description
body Object The body of the request, containing user registration data.
Properties
Name Type Description
name string The name of the user.
email string The email of the user.
password string The password of the user.
res Object The HTTP response object, used to send the response back to the client.
Source:
Throws:
- Throws an error if validation fails or if there is an issue with database interaction.
Type
Error
Returns:
- A promise that resolves to sending a response to the client.
Type
Promise.<void>