diff --git a/documentation/classes/CreateChatRoomDto.html b/documentation/classes/CreateChatRoomDto.html new file mode 100644 index 0000000..96ad082 --- /dev/null +++ b/documentation/classes/CreateChatRoomDto.html @@ -0,0 +1,400 @@ + + +
+ + ++
+ src/chatrooms/DTOs/create-chat-room.dto.ts
+
+ Properties+ |
+
| + + | +
| + + + + name + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @IsString()
+ |
+
|
+ Defined in src/chatrooms/DTOs/create-chat-room.dto.ts:7
+ |
+
| + + + + + Optional + type + + + | +
+ Type : ChatRoomType
+
+ |
+
|
+ Decorators :
+ +
+ @IsEnum(ChatRoomType)
+ |
+
| + + | +
| + + + + + + userIds + + + | +
+ Type : number[]
+
+ |
+
|
+ Decorators :
+ +
+ @IsArray()
+ |
+
| + + | +
import { IsString, IsEnum, IsArray, IsUUID, IsOptional, IsNumber } from 'class-validator';
+import { ChatRoomType } from '../enums/chatroomType';
+import { Type } from 'class-transformer';
+
+export class CreateChatRoomDto {
+ @IsString()
+ name: string;
+
+ @IsEnum(ChatRoomType)
+ @IsOptional()
+ type?: ChatRoomType;
+
+
+ @IsArray()
+ @IsNumber({}, { each: true })
+ @Type(() => Number)
+ userIds: number[];
+}
+ +
+ src/auth/guard/access-token/access-token.guard.ts
+
+
+
CreateUserDto class representing the user creation request payload.
+ + + + + + +
+ Properties+ |
+
| + + | +
| + + + + + + + Optional + confirmpassword + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'string', example: '@Password123', description: 'Password should contain numbers, alphabets, and uppercase and should be the same as the password.'})
+ |
+
| + + | +
|
+ Confirm password field, must match the password. + |
+
| + + + + + + + email + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'string', example: 'fatimaaminu@mail.com', description: 'Email field'})
+ |
+
| + + | +
|
+ Email field (must be unique). + |
+
| + + + + + + + firstName + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'string', example: 'Fatima', description: 'First name field'})
+ |
+
| + + | +
|
+ First name of the user. + |
+
| + + + + + + + Optional + googleId + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'string', example: 'poiuytrdspoiuytrewazxcvbnmml;poiuytrdsdcvbnm]', description: 'This is autogenerated from Google when you sign up with Google.'})
+ |
+
| + + | +
|
+ Google ID (used for OAuth authentication). + |
+
| + + + + + + + lastName + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'string', example: 'Aminu', description: 'Last name field'})
+ |
+
| + + | +
|
+ Last name of the user. + |
+
| + + + + + + + Optional + password + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'string', example: '@Password123', description: 'Password should contain numbers, alphabets, and uppercase.'})
+ |
+
| + + | +
|
+ Password field with specific validation rules. + |
+
| + + + + + + + Optional + userRole + + + | +
+ Type : userRole
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({enum: userRole, example: undefined, description: 'User role (default is USER if not provided).'})
+ |
+
| + + | +
|
+ User role (default is USER if not provided). + |
+
import {
+ IsString,
+ IsEmail,
+ IsNotEmpty,
+ IsEnum,
+ IsOptional,
+ Validate,
+ MaxLength,
+ Matches,
+ ValidatorConstraint,
+ ValidatorConstraintInterface,
+ ValidationArguments,
+} from 'class-validator';
+import { ApiProperty } from '@nestjs/swagger';
+import { Column } from 'typeorm';
+import { userRole } from '../Enums/userRole.enum';
+import { Transform } from 'class-transformer';
+
+/**
+ * ValidatorConstraint: Custom validation class to ensure that
+ * the confirmPassword field matches the password field.
+ */
+@ValidatorConstraint({ name: 'MatchPasswords', async: false })
+/**
+ * MatchPasswordsConstraint class that implements ValidatorConstraintInterface
+ */
+
+/**MatchPasswordConstraint implementing ValidatorConstraintInterface */
+class MatchPasswordsConstraint implements ValidatorConstraintInterface {
+ validate(confirmPassword: string, args: ValidationArguments): boolean {
+ const object = args.object as CreateUserDto;
+
+ /** Ensure password is present before checking match */
+ if (!object.password) return false;
+ return confirmPassword === object.password;
+ }
+
+ defaultMessage(args: ValidationArguments): string {
+ return 'Password and confirm password do not match';
+ }
+}
+
+/**
+ * CreateUserDto class representing the user creation request payload.
+ */
+
+export class CreateUserDto {
+ /**
+ * First name of the user.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'Fatima',
+ description: 'First name field',
+ })
+ @IsString()
+ @IsNotEmpty()
+ @MaxLength(100)
+ firstName: string;
+
+ /**
+ * Last name of the user.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'Aminu',
+ description: 'Last name field',
+ })
+ @IsString()
+ @IsOptional()
+ @MaxLength(100)
+ lastName: string;
+
+ /**
+ * Email field (must be unique).
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'fatimaaminu@mail.com',
+ description: 'Email field',
+ })
+ @IsEmail()
+ @MaxLength(150)
+ @Column({ unique: true, length: 150 })
+ email: string;
+
+ /**
+ * Password field with specific validation rules.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: '@Password123',
+ description: 'Password should contain numbers, alphabets, and uppercase.',
+ })
+ @IsString()
+ @MaxLength(225)
+ @Matches(
+ /^(?=.*[!@#$%^&])(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9!@#$%^&*]{8,16}$/,
+ {
+ message:
+ 'Password must include at least one uppercase letter, one lowercase letter, one number, and one special character.',
+ },
+ )
+ password?: string;
+
+ /**
+ * Confirm password field, must match the password.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: '@Password123',
+ description:
+ 'Password should contain numbers, alphabets, and uppercase and should be the same as the password.',
+ })
+ @IsString()
+ @MaxLength(225)
+ @Validate(MatchPasswordsConstraint)
+ confirmpassword?: string;
+
+ /**
+ * User role (default is USER if not provided).
+ */
+ @ApiProperty({
+ enum: userRole,
+ example: userRole.USER,
+ description: 'User role (default is USER if not provided).',
+ })
+ @IsEnum(userRole)
+ @IsOptional()
+ @Transform(({ value }) => value ?? userRole.USER)
+ userRole?: userRole;
+
+ /**
+ * Google ID (used for OAuth authentication).
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'poiuytrdspoiuytrewa\zxcvbnmml;poiuytrdsdcvbnm]',
+ description: 'This is autogenerated from Google when you sign up with Google.',
+ })
+ @IsString()
+ @IsOptional()
+ @MaxLength(225)
+ googleId?: string;
+}
+
+ +
+ src/users/DTOs/create-user.dto.ts
+
+
+
DTO for creating a user.
+ + + + + + +
+ Properties+ |
+
| + + | +
| + + + + + + + + chatRooms + + + | +
+ Type : ChatRoom[]
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'array', required: true, items: undefined})
+ |
+
|
+ Defined in src/users/DTOs/create-user.dto.ts:159
+ |
+
| + + + + + + + Optional + confirmpassword + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'string', example: '@Password123', description: 'Must contain numbers, alphabets, uppercase letters, and match the password'})
+ |
+
|
+ Defined in src/users/DTOs/create-user.dto.ts:121
+ |
+
|
+ Confirm password field, must match the password. + |
+
| + + + + + + + email + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'string', example: 'fatimaaminu@mail.com', description: 'Email field'})
+ |
+
|
+ Defined in src/users/DTOs/create-user.dto.ts:89
+ |
+
|
+ Email field (must be unique). + |
+
| + + + + + + + firstName + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'string', example: 'Fatima', description: 'First name field'})
+ |
+
|
+ Defined in src/users/DTOs/create-user.dto.ts:63
+ |
+
|
+ First name of the user. + |
+
| + + + + + + + Optional + googleId + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'string', example: 'poiuytrdspoiuytrewazxcvbnmml;poiuytrdsdcvbnm]', description: 'This is auto-generated from Google when you sign up with Google'})
+ |
+
|
+ Defined in src/users/DTOs/create-user.dto.ts:146
+ |
+
|
+ Google ID (used for OAuth authentication). + |
+
| + + + + + + + lastName + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'string', example: 'Aminu', description: 'Last name field'})
+ |
+
|
+ Defined in src/users/DTOs/create-user.dto.ts:76
+ |
+
|
+ Last name of the user. + |
+
| + + + + + + + Optional + password + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({type: 'string', example: '@Password123', description: 'Password should contain a number, alphabets, and an uppercase letter'})
+ |
+
|
+ Defined in src/users/DTOs/create-user.dto.ts:108
+ |
+
|
+ Password field with specific validation rules. + |
+
| + + + + + + + Optional + userRole + + + | +
+ Type : userRole
+
+ |
+
|
+ Decorators :
+ +
+ @ApiProperty({enum: userRole, description: 'Role of the user'})
+ |
+
|
+ Defined in src/users/DTOs/create-user.dto.ts:133
+ |
+
|
+ User role (default is USER if not provided). + |
+
import {
+ IsString,
+ IsEmail,
+ IsNotEmpty,
+ IsEnum,
+ IsOptional,
+ Validate,
+ MaxLength,
+ Matches,
+ ValidatorConstraint,
+ ValidatorConstraintInterface,
+ ValidationArguments,
+ IsArray,
+ ValidateNested,
+} from 'class-validator';
+import { ApiProperty } from '@nestjs/swagger';
+import { Column } from 'typeorm';
+import { userRole } from '../Enums/userRole.enum';
+import { Transform, Type } from 'class-transformer';
+import { ChatRoom } from 'src/chatrooms/chatroom.entity';
+
+// custum validation to compare passwords
+
+@ValidatorConstraint({ name: 'MatchPasswords', async: false })
+export class MatchPasswordsConstraint implements ValidatorConstraintInterface {
+ /**
+ * Validates whether the confirmPassword field matches the password field.
+ * @param confirmPassword - The confirm password input.
+ * @param args - Validation arguments.
+ * @returns Boolean indicating if passwords match.
+ */
+ validate(confirmPassword: string, args: ValidationArguments): boolean {
+ const object = args.object as CreateUserDto;
+ if (!object.password) return false; // Ensure password is present
+ return confirmPassword === object.password;
+ }
+
+ /**
+ * Returns the default error message for password mismatch.
+ * @param args - Validation arguments.
+ * @returns Error message string.
+ */
+ defaultMessage(args: ValidationArguments): string {
+ return 'Password and confirm password do not match';
+ }
+}
+
+/**
+ * DTO for creating a user.
+ */
+export class CreateUserDto {
+ /**
+ * First name of the user.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'Fatima',
+ description: 'First name field',
+ })
+ @IsString()
+ @IsNotEmpty()
+ @MaxLength(100)
+ firstName: string;
+
+ /**
+ * Last name of the user.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'Aminu',
+ description: 'Last name field',
+ })
+ @IsString()
+ @IsOptional()
+ @MaxLength(100)
+ lastName: string;
+
+ /**
+ * Email field (must be unique).
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'fatimaaminu@mail.com',
+ description: 'Email field',
+ })
+ @IsEmail()
+ @MaxLength(150)
+ @Column({ unique: true, length: 150 })
+ email: string;
+
+ /**
+ * Password field with specific validation rules.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: '@Password123',
+ description: 'Password should contain a number, alphabets, and an uppercase letter',
+ })
+ @IsString()
+ @MaxLength(225)
+ @Matches(
+ /^(?=.*[!@#$%^&])(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9!@#$%^&*]{8,16}$/,
+ {
+ message:
+ 'Password must include at least one uppercase letter, one lowercase letter, one number, and one special character.',
+ },
+ )
+ password?: string;
+
+ /**
+ * Confirm password field, must match the password.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: '@Password123',
+ description: 'Must contain numbers, alphabets, uppercase letters, and match the password',
+ })
+ @IsString()
+ @MaxLength(225)
+ @Validate(MatchPasswordsConstraint)
+ confirmpassword?: string;
+
+ /**
+ * User role (default is USER if not provided).
+ */
+ @ApiProperty({
+ enum: userRole,
+ description: 'Role of the user',
+ })
+ @IsEnum(userRole)
+ @IsOptional()
+ @Transform(({ value }) => value ?? userRole.USER)
+ userRole?: userRole;
+
+ /**
+ * Google ID (used for OAuth authentication).
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'poiuytrdspoiuytrewa\zxcvbnmml;poiuytrdsdcvbnm]',
+ description: 'This is auto-generated from Google when you sign up with Google',
+ })
+ @IsString()
+ @IsOptional()
+ @MaxLength(225)
+ googleId?: string;
+
+ @ApiProperty({
+ type: 'array',
+ required: true,
+ items: {
+ type: 'Chatroom',
+ },
+ })
+ @IsNotEmpty()
+ @IsArray()
+ @ValidateNested({ each: true })
+ @Type(() => ChatRoom)
+ chatRooms: ChatRoom[];
+}
+
+ +
+ src/users/DTOs/patch-user.dto.ts
+
+
+
using the patch to edit part of the data, the partialtype makes everything optional
+ + + ++
+ PartialType(CreateUserDto)
+
+ Properties+ |
+
+
|
+
| + + + + + id + + + | +
+ Type : number
+
+ |
+
|
+ Decorators :
+ +
+ @IsInt()
+ |
+
|
+ Defined in src/users/DTOs/patch-user.dto.ts:12
+ |
+
|
+ unique identifier id + |
+
import { IsEmail, IsInt, IsNotEmpty, IsString } from "class-validator";
+import { PartialType } from "@nestjs/mapped-types";
+import { CreateUserDto } from "./create-user.dto";
+
+
+/**using the patch to edit part of the data, the partialtype makes everything optional */
+export class EditUserDto extends PartialType(CreateUserDto) {
+ /**unique identifier id */
+ @IsInt()
+ @IsNotEmpty()
+ id: number;
+}
+
+
+ +
+ src/users/DTOs/getUserparamdto.ts
+
+
+
Get users paramsdto class
+ + + + + + +
+ Properties+ |
+
+
|
+
| + + + + + Optional + id + + + | +
+ Type : number
+
+ |
+
|
+ Decorators :
+ +
+ @IsInt()
+ |
+
|
+ Defined in src/users/DTOs/getUserparamdto.ts:10
+ |
+
|
+ Unique identifier id + |
+
import { IsOptional,IsInt } from "class-validator";
+import { Type } from 'class-transformer';
+
+/**Get users paramsdto class */
+export class GetuserParamDto {
+
+ /**Unique identifier id */
+ @IsInt()
+ @Type (() => Number )
+ id?:number
+
+}
+ +
+ src/auth/social/dtos/google-token.dto.ts
+
+
+
class for GoogleTokendto
+ + + + + + +
+ Properties+ |
+
+
|
+
| + + + + token + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @IsNotEmpty()
+ |
+
|
+ Defined in src/auth/social/dtos/google-token.dto.ts:8
+ |
+
|
+ The Token of type string + |
+
import {IsNotEmpty} from 'class-validator'
+
+/**class for GoogleTokendto */
+export class GoogleTokenDto {
+
+ /**The Token of type string */
+ @IsNotEmpty()
+ token: string
+}
+ +
+ src/auth/guard/access-token/access-token.guard.ts
+
+
+
ValidatorConstraint: Custom validation class to ensure that +the confirmPassword field matches the password field.
+ + + + ++
+ ValidatorConstraintInterface
+
+ Methods+ |
+
+
|
+
| + + + defaultMessage + + + | +||||||
+defaultMessage(args: ValidationArguments)
+ |
+ ||||||
| + + | +||||||
|
+
+
+ Parameters :
+
+
+
+ Returns :
+ string
+
+
+
+
+ |
+
| + + + validate + + + | +|||||||||
+validate(confirmPassword: string, args: ValidationArguments)
+ |
+ |||||||||
| + + | +|||||||||
|
+
+
+ Parameters :
+
+
+
+ Returns :
+ boolean
+
+
+
+
+ |
+
import {
+ IsString,
+ IsEmail,
+ IsNotEmpty,
+ IsEnum,
+ IsOptional,
+ Validate,
+ MaxLength,
+ Matches,
+ ValidatorConstraint,
+ ValidatorConstraintInterface,
+ ValidationArguments,
+} from 'class-validator';
+import { ApiProperty } from '@nestjs/swagger';
+import { Column } from 'typeorm';
+import { userRole } from '../Enums/userRole.enum';
+import { Transform } from 'class-transformer';
+
+/**
+ * ValidatorConstraint: Custom validation class to ensure that
+ * the confirmPassword field matches the password field.
+ */
+@ValidatorConstraint({ name: 'MatchPasswords', async: false })
+/**
+ * MatchPasswordsConstraint class that implements ValidatorConstraintInterface
+ */
+
+/**MatchPasswordConstraint implementing ValidatorConstraintInterface */
+class MatchPasswordsConstraint implements ValidatorConstraintInterface {
+ validate(confirmPassword: string, args: ValidationArguments): boolean {
+ const object = args.object as CreateUserDto;
+
+ /** Ensure password is present before checking match */
+ if (!object.password) return false;
+ return confirmPassword === object.password;
+ }
+
+ defaultMessage(args: ValidationArguments): string {
+ return 'Password and confirm password do not match';
+ }
+}
+
+/**
+ * CreateUserDto class representing the user creation request payload.
+ */
+
+export class CreateUserDto {
+ /**
+ * First name of the user.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'Fatima',
+ description: 'First name field',
+ })
+ @IsString()
+ @IsNotEmpty()
+ @MaxLength(100)
+ firstName: string;
+
+ /**
+ * Last name of the user.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'Aminu',
+ description: 'Last name field',
+ })
+ @IsString()
+ @IsOptional()
+ @MaxLength(100)
+ lastName: string;
+
+ /**
+ * Email field (must be unique).
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'fatimaaminu@mail.com',
+ description: 'Email field',
+ })
+ @IsEmail()
+ @MaxLength(150)
+ @Column({ unique: true, length: 150 })
+ email: string;
+
+ /**
+ * Password field with specific validation rules.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: '@Password123',
+ description: 'Password should contain numbers, alphabets, and uppercase.',
+ })
+ @IsString()
+ @MaxLength(225)
+ @Matches(
+ /^(?=.*[!@#$%^&])(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9!@#$%^&*]{8,16}$/,
+ {
+ message:
+ 'Password must include at least one uppercase letter, one lowercase letter, one number, and one special character.',
+ },
+ )
+ password?: string;
+
+ /**
+ * Confirm password field, must match the password.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: '@Password123',
+ description:
+ 'Password should contain numbers, alphabets, and uppercase and should be the same as the password.',
+ })
+ @IsString()
+ @MaxLength(225)
+ @Validate(MatchPasswordsConstraint)
+ confirmpassword?: string;
+
+ /**
+ * User role (default is USER if not provided).
+ */
+ @ApiProperty({
+ enum: userRole,
+ example: userRole.USER,
+ description: 'User role (default is USER if not provided).',
+ })
+ @IsEnum(userRole)
+ @IsOptional()
+ @Transform(({ value }) => value ?? userRole.USER)
+ userRole?: userRole;
+
+ /**
+ * Google ID (used for OAuth authentication).
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'poiuytrdspoiuytrewa\zxcvbnmml;poiuytrdsdcvbnm]',
+ description: 'This is autogenerated from Google when you sign up with Google.',
+ })
+ @IsString()
+ @IsOptional()
+ @MaxLength(225)
+ googleId?: string;
+}
+
+ +
+ src/users/DTOs/create-user.dto.ts
+
+
+ ValidatorConstraintInterface
+
+ Methods+ |
+
+
|
+
| + + + defaultMessage + + + | +||||||||
+defaultMessage(args: ValidationArguments)
+ |
+ ||||||||
|
+ Defined in src/users/DTOs/create-user.dto.ts:43
+ |
+ ||||||||
|
+ Returns the default error message for password mismatch. +
+ Parameters :
+
+
+
+ Returns :
+ string
+
+
+
+ Error message string. + + |
+
| + + + validate + + + | +||||||||||||
+validate(confirmPassword: string, args: ValidationArguments)
+ |
+ ||||||||||||
|
+ Defined in src/users/DTOs/create-user.dto.ts:32
+ |
+ ||||||||||||
|
+ Validates whether the confirmPassword field matches the password field. +
+ Parameters :
+
+
+
+ Returns :
+ boolean
+
+
+
+ Boolean indicating if passwords match. + + |
+
import {
+ IsString,
+ IsEmail,
+ IsNotEmpty,
+ IsEnum,
+ IsOptional,
+ Validate,
+ MaxLength,
+ Matches,
+ ValidatorConstraint,
+ ValidatorConstraintInterface,
+ ValidationArguments,
+ IsArray,
+ ValidateNested,
+} from 'class-validator';
+import { ApiProperty } from '@nestjs/swagger';
+import { Column } from 'typeorm';
+import { userRole } from '../Enums/userRole.enum';
+import { Transform, Type } from 'class-transformer';
+import { ChatRoom } from 'src/chatrooms/chatroom.entity';
+
+// custum validation to compare passwords
+
+@ValidatorConstraint({ name: 'MatchPasswords', async: false })
+export class MatchPasswordsConstraint implements ValidatorConstraintInterface {
+ /**
+ * Validates whether the confirmPassword field matches the password field.
+ * @param confirmPassword - The confirm password input.
+ * @param args - Validation arguments.
+ * @returns Boolean indicating if passwords match.
+ */
+ validate(confirmPassword: string, args: ValidationArguments): boolean {
+ const object = args.object as CreateUserDto;
+ if (!object.password) return false; // Ensure password is present
+ return confirmPassword === object.password;
+ }
+
+ /**
+ * Returns the default error message for password mismatch.
+ * @param args - Validation arguments.
+ * @returns Error message string.
+ */
+ defaultMessage(args: ValidationArguments): string {
+ return 'Password and confirm password do not match';
+ }
+}
+
+/**
+ * DTO for creating a user.
+ */
+export class CreateUserDto {
+ /**
+ * First name of the user.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'Fatima',
+ description: 'First name field',
+ })
+ @IsString()
+ @IsNotEmpty()
+ @MaxLength(100)
+ firstName: string;
+
+ /**
+ * Last name of the user.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'Aminu',
+ description: 'Last name field',
+ })
+ @IsString()
+ @IsOptional()
+ @MaxLength(100)
+ lastName: string;
+
+ /**
+ * Email field (must be unique).
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'fatimaaminu@mail.com',
+ description: 'Email field',
+ })
+ @IsEmail()
+ @MaxLength(150)
+ @Column({ unique: true, length: 150 })
+ email: string;
+
+ /**
+ * Password field with specific validation rules.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: '@Password123',
+ description: 'Password should contain a number, alphabets, and an uppercase letter',
+ })
+ @IsString()
+ @MaxLength(225)
+ @Matches(
+ /^(?=.*[!@#$%^&])(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9!@#$%^&*]{8,16}$/,
+ {
+ message:
+ 'Password must include at least one uppercase letter, one lowercase letter, one number, and one special character.',
+ },
+ )
+ password?: string;
+
+ /**
+ * Confirm password field, must match the password.
+ */
+ @ApiProperty({
+ type: 'string',
+ example: '@Password123',
+ description: 'Must contain numbers, alphabets, uppercase letters, and match the password',
+ })
+ @IsString()
+ @MaxLength(225)
+ @Validate(MatchPasswordsConstraint)
+ confirmpassword?: string;
+
+ /**
+ * User role (default is USER if not provided).
+ */
+ @ApiProperty({
+ enum: userRole,
+ description: 'Role of the user',
+ })
+ @IsEnum(userRole)
+ @IsOptional()
+ @Transform(({ value }) => value ?? userRole.USER)
+ userRole?: userRole;
+
+ /**
+ * Google ID (used for OAuth authentication).
+ */
+ @ApiProperty({
+ type: 'string',
+ example: 'poiuytrdspoiuytrewa\zxcvbnmml;poiuytrdsdcvbnm]',
+ description: 'This is auto-generated from Google when you sign up with Google',
+ })
+ @IsString()
+ @IsOptional()
+ @MaxLength(225)
+ googleId?: string;
+
+ @ApiProperty({
+ type: 'array',
+ required: true,
+ items: {
+ type: 'Chatroom',
+ },
+ })
+ @IsNotEmpty()
+ @IsArray()
+ @ValidateNested({ each: true })
+ @Type(() => ChatRoom)
+ chatRooms: ChatRoom[];
+}
+
+ +
+ src/common/pagination/Interfaces/paginatedInterface.ts
+
+ Properties+ |
+
| + + | +
| + + + data + + + | +
+ Type : T[]
+
+ |
+
| + + | +
| + + + link + + + | +
+ Type : literal type
+
+ |
+
| + + | +
| + + + meta + + + | +
+ Type : literal type
+
+ |
+
| + + | +
export class Paginated <T> {
+ data:T[];
+ meta: {
+ itemsPerPage:number,
+ totalItems: number,
+ currentPage:number,
+ totalPage:number,
+ };
+ link:
+ {
+ first: string,
+ last:string,
+ current: string,
+ previous:string,
+ next:string,
+ }
+
+}
+ +
+ src/common/pagination/pagination-query.dto.ts
+
+ Properties+ |
+
| + + | +
| + + + + + Optional + limit + + + | +
+ Type : number
+
+ |
+
+ Default value : 2
+ |
+
|
+ Decorators :
+ +
+ @IsOptional()
+ |
+
| + + | +
| + + + + + Optional + page + + + | +
+ Type : number
+
+ |
+
+ Default value : 1
+ |
+
|
+ Decorators :
+ +
+ @IsOptional()
+ |
+
| + + | +
import { IsOptional, IsPositive } from "class-validator";
+
+
+export class PaginationQueryDto {
+
+ @IsOptional()
+ @IsPositive()
+ limit?:number = 2;
+
+ @IsOptional()
+ @IsPositive()
+ page?:number = 1;
+
+}
+ +
+ src/auth/dtos/refreshTokenDto.ts
+
+
+
refresh tokendto class
+ + + + + + +
+ Properties+ |
+
+
|
+
| + + + + + refreshToken + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @IsString()
+ |
+
|
+ Defined in src/auth/dtos/refreshTokenDto.ts:9
+ |
+
|
+ refreshToken of type string + |
+
import { IsNotEmpty, IsString, } from "class-validator";
+
+/**refresh tokendto class */
+export class RefreshTokenDto {
+
+ /**refreshToken of type string */
+ @IsString()
+ @IsNotEmpty()
+ refreshToken: string
+}
+ +
+ src/auth/dtos/userDto.ts
+
+
+
signinDto class
+ + + + + + +
+ Properties+ |
+
| + + | +
| + + + + + email + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @IsEmail()
+ |
+
|
+ Defined in src/auth/dtos/userDto.ts:8
+ |
+
|
+ A unique email address of the user example:Rukky@gmail.com + |
+
| + + + + + password + + + | +
+ Type : string
+
+ |
+
|
+ Decorators :
+ +
+ @IsString()
+ |
+
|
+ Defined in src/auth/dtos/userDto.ts:13
+ |
+
|
+ password of the user + |
+
import { IsEmail, IsNotEmpty, IsString } from "class-validator";
+
+/**signinDto class */
+export class SignInDto {
+ /**A unique email address of the user example:Rukky@gmail.com */
+ @IsEmail()
+ @IsNotEmpty()
+ email: string;
+
+ /**password of the user */
+ @IsString()
+ @IsNotEmpty()
+ password: string;
+}
+ +
+ src/chatrooms/DTOs/update-chat-room.dto.ts
+
+
import { PartialType } from '@nestjs/mapped-types';
+import { CreateChatRoomDto } from './create-chat-room.dto';
+
+export class UpdateChatRoomDto extends PartialType(CreateChatRoomDto) {}
+ +
+ src/web-socket/websocketEvents/websocket.gateway.ts
+
+ Methods+ |
+
+
|
+
| + + + + handleMessage + + + | +|||||||||
+
+ handleMessage(client: any, payload: any)
+ |
+ |||||||||
|
+ Decorators :
+ + @SubscribeMessage('message')
+ |
+ |||||||||
| + + | +|||||||||
|
+
+
+ Parameters :
+
+
+
+ Returns :
+ string
+
+
+
+
+ |
+
import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets';
+
+@WebSocketGateway()
+export class WebsocketGateway {
+ @SubscribeMessage('message')
+ handleMessage(client: any, payload: any): string {
+ return 'Hello world!';
+ }
+}
+