diff --git a/src/modules/decks/dto/get-all-decks.dto.ts b/src/modules/decks/dto/get-all-decks.dto.ts
index 9b8282d..ae503dd 100644
--- a/src/modules/decks/dto/get-all-decks.dto.ts
+++ b/src/modules/decks/dto/get-all-decks.dto.ts
@@ -1,15 +1,20 @@
import { ApiHideProperty } from '@nestjs/swagger'
-import { IsUUID } from 'class-validator'
+import { Type } from 'class-transformer'
+import { IsNumber, IsOptional, IsUUID } from 'class-validator'
import { PaginationDto } from '../../../infrastructure/common/pagination/pagination.dto'
import { IsOptionalOrEmptyString, IsOrderBy } from '../../../infrastructure/decorators'
export class GetAllDecksDto extends PaginationDto {
- @IsOptionalOrEmptyString()
- minCardsCount?: string
+ @IsOptional()
+ @Type(() => Number)
+ @IsNumber()
+ minCardsCount?: number
- @IsOptionalOrEmptyString()
- maxCardsCount?: string
+ @IsOptional()
+ @Type(() => Number)
+ @IsNumber()
+ maxCardsCount?: number
/** Search by deck name */
@IsOptionalOrEmptyString()
diff --git a/src/modules/users/services/users.service.ts b/src/modules/users/services/users.service.ts
index 410af2a..304f5bb 100644
--- a/src/modules/users/services/users.service.ts
+++ b/src/modules/users/services/users.service.ts
@@ -6,7 +6,10 @@ import { UsersRepository } from '../infrastructure/users.repository'
@Injectable()
export class UsersService {
- constructor(private usersRepository: UsersRepository, private emailService: MailerService) {}
+ constructor(
+ private usersRepository: UsersRepository,
+ private emailService: MailerService
+ ) {}
private logger = new Logger(UsersService.name)
@@ -32,7 +35,7 @@ export class UsersService {
email,
name,
verificationToken,
- html = `Hello, ##name##!
Please confirm your email by clicking on the link below:
Confirm email. If it doesn't work, copy and paste the following link in your browser:
http://localhost:3000/confirm-email/##token##`,
+ html,
subject = 'E-mail confirmation',
}: {
email: string
@@ -41,7 +44,11 @@ export class UsersService {
html?: string
subject?: string
}) {
- const htmlFinal = html.replaceAll('##token##', verificationToken)?.replaceAll('##name##', name)
+ const htmlFinal = this.prepareHtml(
+ html ?? this.defaultConfirmationHtml,
+ name,
+ verificationToken
+ )
try {
await this.emailService.sendMail({
@@ -70,9 +77,11 @@ export class UsersService {
subject?: string
passwordRecoveryToken: string
}) {
- const htmlFinal =
- html?.replace('##token##', passwordRecoveryToken)?.replace('##name##', name) ||
- `Hello ${name}!
To recover your password follow this link:
Confirm email. If it doesn't work, copy and paste the following link in your browser:
http://localhost:3000/confirm-email/${passwordRecoveryToken} `
+ const htmlFinal = this.prepareHtml(
+ html ?? this.defaultRecoveryHtml,
+ name,
+ passwordRecoveryToken
+ )
try {
await this.emailService.sendMail({
@@ -91,4 +100,28 @@ export class UsersService {
public async generateHash(password: string) {
return await bcrypt.hash(password, 10)
}
+
+ private prepareHtml(html: string, name: string, token: string) {
+ return html.replaceAll('##token##', token)?.replaceAll('##name##', name)
+ }
+
+ private defaultConfirmationHtml = `
+ Hello, ##name##!
+
+ Please confirm your email by clicking on the link below:
+
+ Confirm email.
+ If it doesn't work, copy and paste the following link in your browser:
+
+ http://localhost:3000/confirm-email/##token##`
+
+ private defaultRecoveryHtml = `
+ Hello, ##name##!
+
+ To recover your password follow the link below:
+
+ Recover password.
+ If it doesn't work, copy and paste the following link in your browser:
+
+ http://localhost:3000/recover-password/##token##`
}