This commit is contained in:
2026-04-16 17:21:48 +03:00
parent c8fa4c442d
commit c8e7e4e927
116 changed files with 3720 additions and 4197 deletions
+25 -25
View File
@@ -1,30 +1,30 @@
import { Controller, Post, Body, HttpCode } from '@nestjs/common';
import { I18n, I18nContext } from 'nestjs-i18n';
import { ApiTags, ApiOperation, ApiOkResponse } from '@nestjs/swagger';
import { AuthService } from './auth.service';
import { Controller, Post, Body, HttpCode } from "@nestjs/common";
import { I18n, I18nContext } from "nestjs-i18n";
import { ApiTags, ApiOperation, ApiOkResponse } from "@nestjs/swagger";
import { AuthService } from "./auth.service";
import {
RegisterDto,
LoginDto,
RefreshTokenDto,
TokenResponseDto,
} from './dto/auth.dto';
import { Public } from '../../common/decorators';
} from "./dto/auth.dto";
import { Public } from "../../common/decorators";
import {
ApiResponse,
createSuccessResponse,
} from '../../common/types/api-response.type';
} from "../../common/types/api-response.type";
@ApiTags('Auth')
@Controller('auth')
@ApiTags("Auth")
@Controller("auth")
export class AuthController {
constructor(private readonly authService: AuthService) {}
@Post('register')
@Post("register")
@Public()
@HttpCode(200)
@ApiOperation({ summary: 'Register a new user' })
@ApiOperation({ summary: "Register a new user" })
@ApiOkResponse({
description: 'User registered successfully',
description: "User registered successfully",
type: TokenResponseDto,
})
async register(
@@ -32,28 +32,28 @@ export class AuthController {
@I18n() i18n: I18nContext,
): Promise<ApiResponse<TokenResponseDto>> {
const result = await this.authService.register(dto);
return createSuccessResponse(result, i18n.t('auth.registered'), 201);
return createSuccessResponse(result, i18n.t("auth.registered"), 201);
}
@Post('login')
@Post("login")
@Public()
@HttpCode(200)
@ApiOperation({ summary: 'Login with email and password' })
@ApiOkResponse({ description: 'Login successful', type: TokenResponseDto })
@ApiOperation({ summary: "Login with email and password" })
@ApiOkResponse({ description: "Login successful", type: TokenResponseDto })
async login(
@Body() dto: LoginDto,
@I18n() i18n: I18nContext,
): Promise<ApiResponse<TokenResponseDto>> {
const result = await this.authService.login(dto);
return createSuccessResponse(result, i18n.t('auth.login_success'));
return createSuccessResponse(result, i18n.t("auth.login_success"));
}
@Post('refresh')
@Post("refresh")
@Public()
@HttpCode(200)
@ApiOperation({ summary: 'Refresh access token' })
@ApiOperation({ summary: "Refresh access token" })
@ApiOkResponse({
description: 'Token refreshed successfully',
description: "Token refreshed successfully",
type: TokenResponseDto,
})
async refreshToken(
@@ -61,18 +61,18 @@ export class AuthController {
@I18n() i18n: I18nContext,
): Promise<ApiResponse<TokenResponseDto>> {
const result = await this.authService.refreshToken(dto.refreshToken);
return createSuccessResponse(result, i18n.t('auth.refresh_success'));
return createSuccessResponse(result, i18n.t("auth.refresh_success"));
}
@Post('logout')
@Post("logout")
@HttpCode(200)
@ApiOperation({ summary: 'Logout and invalidate refresh token' })
@ApiOkResponse({ description: 'Logout successful' })
@ApiOperation({ summary: "Logout and invalidate refresh token" })
@ApiOkResponse({ description: "Logout successful" })
async logout(
@Body() dto: RefreshTokenDto,
@I18n() i18n: I18nContext,
): Promise<ApiResponse<null>> {
await this.authService.logout(dto.refreshToken);
return createSuccessResponse(null, i18n.t('auth.logout_success'));
return createSuccessResponse(null, i18n.t("auth.logout_success"));
}
}