Closed ashishkarki closed 2 months ago
id
, name
, email
, dob
, citizenship
, passportNumber
, and password
.email
is unique, non-empty, and properly formatted.UserService
class in NestJS, which handles user-related operations such as registering users.user.create
method was used to create new users in the database, with validation rules (e.g., checking for existing emails to prevent duplicates).RegisterUserDto
class with validation decorators like @IsNotEmpty()
, @IsEmail()
, @MinLength()
, and more for strong data validation.register
mutation to accept the RegisterUserDto
and register users in the database.OperationResult
DTO to return standardized responses with a status
(boolean) and message
(string). This response is sent back to the client after each operation, ensuring consistency in the API’s behavior.findUnique()
.OperationResult
containing the status of the operation and the user object in a formatted message.
Here’s what we’ll do next:
1. Create a User Service:
This will handle the logic for user registration, including creating a new user in the database.
2. Create a User Controller:
The controller will handle incoming HTTP requests and forward them to the service.
3. Create the DTO (Data Transfer Object):
The DTO will define the structure of the data being passed in for user registration.