Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Changed DTOs

Yevhenii Kulisidif69f2379bf1f
diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts
index f23d89dbb..3798d8659 100644
--- a/src/auth/auth.controller.ts
+++ b/src/auth/auth.controller.ts
@@ -14,7 +14,7 @@ import { I18nValidationExceptionFilter, I18n, I18nContext } from 'nestjs-i18n'
import { checkRateLimit } from 'src/common/utils'
import { UserService } from 'src/user/user.service'
import { AuthService } from './auth.service'
-import { RegisterDto } from './dtos'
+import { RegisterRequestDto, RegisterResponseDto } from './dtos'
@ApiTags('Auth')
@Controller({ path: 'auth', version: '1' })
@@ -36,15 +36,15 @@ export class AuthController {
@ApiOperation({ summary: 'Register a new user' })
@ApiCreatedResponse({
description: 'User registered',
- type: RegisterDto.Response,
+ type: RegisterResponseDto,
})
@Post('register')
public async register(
- @Body() body: RegisterDto.Request,
+ @Body() body: RegisterRequestDto,
@I18n() i18n: I18nContext,
@Headers() headers: unknown,
@Ip() requestIp: string,
- ): Promise<RegisterDto.Response> {
+ ): Promise<RegisterResponseDto> {
const ip =
headers['x-forwarded-for'] || headers['cf-connecting-ip'] || requestIp
diff --git a/src/auth/dtos/register.dto.ts b/src/auth/dtos/register.dto.ts
index 818fbafc5..936e7c226 100644
--- a/src/auth/dtos/register.dto.ts
+++ b/src/auth/dtos/register.dto.ts
@@ -1,20 +1,38 @@
+import { ApiProperty } from '@nestjs/swagger'
import { IsEmail, IsNotEmpty, IsBoolean } from 'class-validator'
import { IsPassword } from '../decorators'
-export namespace RegisterDto {
- export class Request {
- @IsEmail({}, { message: 'validation.isEmail' })
- public readonly email: string
+export class RegisterRequestDto {
+ @ApiProperty({
+ description: 'User email',
+ example: '[email protected]',
+ maxLength: 254,
+ minLength: 6,
+ })
+ @IsEmail({}, { message: 'validation.isEmail' })
+ public readonly email: string
- @IsPassword({ message: 'validation.isPassword' })
- public readonly password: string
+ @ApiProperty({
+ description: 'User password',
+ example: '%d7*c4W45p',
+ maxLength: 72,
+ minLength: 8,
+ })
+ @IsPassword({ message: 'validation.isPassword' })
+ public readonly password: string
- @IsNotEmpty({ message: 'validation.isNotEmpty' })
- @IsBoolean({ message: 'validation.isBoolean' })
- public readonly checkIfLeaked: boolean
- }
+ @ApiProperty({
+ description: 'Check if password is leaked',
+ example: true,
+ })
+ @IsNotEmpty({ message: 'validation.isNotEmpty' })
+ @IsBoolean({ message: 'validation.isBoolean' })
+ public readonly checkIfLeaked: boolean
+}
- export class Response {
- public readonly accessToken: string
- }
+export class RegisterResponseDto {
+ @ApiProperty({
+ description: 'Access token (JWT)',
+ })
+ public readonly accessToken: string
}