feat: complete testing, security, dynamic content, and devops overhaul

This commit is contained in:
parsa committed 2026-05-27 02:00:14 +03:30
1 parent 467532713c
commit 40ff169dc2
52 files changed
+3918 -104

No files matched your search

+73 -6
View File
@@ -2,25 +2,92 @@ import { Controller, Post, Body, HttpCode, HttpStatus } from '@nestjs/common';
import { AuthService } from './auth.service';
import { SendOtpDto } from './dto/send-otp.dto';
import { VerifyOtpDto } from './dto/verify-otp.dto';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { ApiTags, ApiOperation, ApiResponse, ApiOkResponse, ApiBadRequestResponse } from '@nestjs/swagger';
@ApiTags('Auth')
@ApiTags('Auth - احراز هویت')
@Controller('auth')
@ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: 'خطای داخلی سرور',
schema: {
example: {
success: false,
message: 'خطای ناشناخته در سرور رخ داده است',
code: 'SERVER_ERROR',
details: {}
}
}
})
export class AuthController {
constructor(private readonly authService: AuthService) {}
@Post('send-otp')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'ارسال کد تایید پیامکی' })
@ApiResponse({ status: 200, description: 'کد با موفقیت ارسال شد' })
@ApiOperation({ summary: 'ارسال کد تایید پیامکی (OTP)' })
@ApiOkResponse({
description: 'کد با موفقیت ارسال شد (کد تایید در پاسخ بازگردانده می‌شود)',
schema: {
example: {
success: true,
message: 'کد تایید ارسال شد',
code: '12345'
}
}
})
@ApiBadRequestResponse({
description: 'فرمت شماره تلفن همراه نامعتبر است',
schema: {
example: {
success: false,
message: 'شماره موبایل نامعتبر است',
code: 'BAD_REQUEST',
details: {
message: ['شماره موبایل نامعتبر است']
}
}
}
})
sendOtp(@Body() sendOtpDto: SendOtpDto) {
return this.authService.sendOtp(sendOtpDto);
}
@Post('verify-otp')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'تایید کد پیامکی و ورود/ثبت‌نام' })
@ApiResponse({ status: 200, description: 'ورود موفق به همراه توکن' })
@ApiOperation({ summary: 'تایید کد پیامکی و ورود/ثبت‌نام کاربر' })
@ApiOkResponse({
description: 'ورود موفق به همراه توکن دسترسی JWT و اطلاعات کاربر',
schema: {
example: {
success: true,
data: {
user: {
id: 'd8c4e428-cd2f-4c55-bfa3-dfa312bb6480',
firstName: 'کاربر',
lastName: 'جدید',
email: '09123456789@temp.local',
mobile: '09123456789',
role: 'User_PetOwner',
walletBalance: '0.00',
charityDonationTotal: '0.00',
createdAt: '2026-05-26T15:20:00.000Z',
updatedAt: '2026-05-26T15:20:00.000Z'
},
accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
}
}
}
})
@ApiBadRequestResponse({
description: 'کد تایید اشتباه یا منقضی شده است',
schema: {
example: {
success: false,
message: 'کد تایید اشتباه است',
code: 'OTP_INVALID',
details: {}
}
}
})
verifyOtp(@Body() verifyOtpDto: VerifyOtpDto) {
return this.authService.verifyOtp(verifyOtpDto);
}