docs: complete swagger annotations for auth, home, blogs and wiki endpoints

This commit is contained in:
پارسا آقایی 2026-06-12 23:30:22 +03:30
parent e09adc03c3
commit 24137beb32
4 changed files with 39 additions and 3 deletions

View File

@ -97,6 +97,8 @@ export class AuthController {
@Post('register')
@HttpCode(HttpStatus.CREATED)
@ApiOperation({ summary: 'ثبت‌نام با ایمیل/موبایل و رمز عبور' })
@ApiOkResponse({ description: 'کاربر با موفقیت ثبت‌نام شد' })
@ApiBadRequestResponse({ description: 'اطلاعات ثبت‌نام نامعتبر است یا کاربر از قبل وجود دارد' })
register(@Body() registerDto: RegisterDto) {
return this.authService.register(registerDto);
}
@ -104,6 +106,8 @@ export class AuthController {
@Post('login')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'ورود با موبایل و رمز عبور' })
@ApiOkResponse({ description: 'ورود موفق به همراه توکن دسترسی' })
@ApiBadRequestResponse({ description: 'نام کاربری یا رمز عبور اشتباه است' })
login(@Body() loginDto: LoginDto) {
return this.authService.login(loginDto);
}
@ -111,6 +115,8 @@ export class AuthController {
@Post('admin-login')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'ورود ادمین به پنل مدیریت' })
@ApiOkResponse({ description: 'ورود موفق ادمین به همراه توکن' })
@ApiBadRequestResponse({ description: 'اطلاعات ورود ادمین اشتباه است' })
adminLogin(@Body() body: any) {
return this.authService.adminLogin(body);
}

View File

@ -1,16 +1,27 @@
import { Controller, Get, Param } from '@nestjs/common';
import { Controller, Get, Param, HttpStatus } from '@nestjs/common';
import { BlogsService } from './blogs.service';
import { ApiTags, ApiOperation, ApiResponse, ApiOkResponse, ApiNotFoundResponse } from '@nestjs/swagger';
@ApiTags('Blogs - مجله سلامت')
@Controller('blogs')
@ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: 'خطای داخلی سرور'
})
export class BlogsController {
constructor(private readonly blogsService: BlogsService) {}
@Get()
@ApiOperation({ summary: 'دریافت لیست مقالات مجله سلامت' })
@ApiOkResponse({ description: 'لیست مقالات منتشر شده' })
findAll() {
return this.blogsService.findAll();
}
@Get(':slug')
@ApiOperation({ summary: 'دریافت مقاله با اسلاگ (Slug)' })
@ApiOkResponse({ description: 'اطلاعات کامل مقاله' })
@ApiNotFoundResponse({ description: 'مقاله یافت نشد' })
findOne(@Param('slug') slug: string) {
return this.blogsService.findOneBySlug(slug);
}

View File

@ -1,11 +1,19 @@
import { Controller, Get } from '@nestjs/common';
import { Controller, Get, HttpStatus } from '@nestjs/common';
import { HomeService } from './home.service';
import { ApiTags, ApiOperation, ApiResponse, ApiOkResponse } from '@nestjs/swagger';
@ApiTags('Home - صفحه اصلی')
@Controller('home')
@ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: 'خطای داخلی سرور'
})
export class HomeController {
constructor(private readonly homeService: HomeService) {}
@Get()
@ApiOperation({ summary: 'دریافت اطلاعات صفحه اصلی' })
@ApiOkResponse({ description: 'اطلاعات ویترین، بنرها، پرفروش‌ترین‌ها، وبلاگ و غیره' })
getHomeData() {
return this.homeService.getHomeData();
}

View File

@ -1,16 +1,27 @@
import { Controller, Get, Param } from '@nestjs/common';
import { Controller, Get, Param, HttpStatus } from '@nestjs/common';
import { WikiService } from './wiki.service';
import { ApiTags, ApiOperation, ApiResponse, ApiOkResponse, ApiNotFoundResponse } from '@nestjs/swagger';
@ApiTags('Wiki - دانشنامه ترکیبات')
@Controller('wiki')
@ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: 'خطای داخلی سرور'
})
export class WikiController {
constructor(private readonly wikiService: WikiService) {}
@Get()
@ApiOperation({ summary: 'دریافت تمام کلمات دانشنامه' })
@ApiOkResponse({ description: 'لیست تمامی ترکیبات علمی' })
findAll() {
return this.wikiService.findAll();
}
@Get(':key')
@ApiOperation({ summary: 'دریافت ترکیب علمی با کلید' })
@ApiOkResponse({ description: 'اطلاعات کامل ترکیب علمی' })
@ApiNotFoundResponse({ description: 'ترکیب علمی یافت نشد' })
findOne(@Param('key') key: string) {
return this.wikiService.findOneByKey(key);
}