test: comprehensive test suites and quality gates pass across backend, storefront and admin
- Backend (NestJS): 82 suites, 641 tests passing; 0 ESLint errors; 0 tsc errors. Hardened SSL cert/key matching, SSRF IP pinning, and eBank validation. - Admin Panel (Vite/React): 48 suites, 300 tests passing; 0 ESLint errors; 0 tsc errors. Full coverage across all pages and settings. - Storefront (Next.js): 62 suites, 368 tests passing; 0 ESLint errors; 0 tsc errors. - Fixed unmount lifecycle guards, promise error handling, and component edge cases.
This commit is contained in:
1 parent
1e73715169
commit
ddbf1ca026
439 files changed
+32911
-6107
No files matched your search
@@ -10,36 +10,36 @@ import {
|
||||
Query,
|
||||
UseGuards,
|
||||
Request,
|
||||
} from '@nestjs/common';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { BlogsService } from './blogs.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
} from "@nestjs/common";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { BlogsService } from "./blogs.service";
|
||||
import { JwtAuthGuard } from "../auth/jwt-auth.guard";
|
||||
import {
|
||||
ApiTags,
|
||||
ApiBearerAuth,
|
||||
ApiOperation,
|
||||
ApiQuery,
|
||||
} from '@nestjs/swagger';
|
||||
import { PaginationDto } from '../common/dto/pagination.dto';
|
||||
} from "@nestjs/swagger";
|
||||
import { PaginationDto } from "../common/dto/pagination.dto";
|
||||
|
||||
import { RolesGuard } from '../common/guards/roles.guard';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
import { RolesGuard } from "../common/guards/roles.guard";
|
||||
import { Roles } from "../common/decorators/roles.decorator";
|
||||
|
||||
@ApiTags('Admin - مدیریت مقالات (بلاگ)')
|
||||
@ApiTags("Admin - مدیریت مقالات (بلاگ)")
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin', 'SUPER_ADMIN')
|
||||
@Controller('admin/blogs')
|
||||
@Roles("Admin", "SUPER_ADMIN")
|
||||
@Controller("admin/blogs")
|
||||
export class BlogsController {
|
||||
constructor(private readonly blogsService: BlogsService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'لیست مقالات' })
|
||||
@ApiQuery({ name: 'page', required: false })
|
||||
@ApiQuery({ name: 'limit', required: false })
|
||||
@ApiQuery({ name: 'search', required: false })
|
||||
@ApiQuery({ name: 'status', required: false })
|
||||
@ApiQuery({ name: 'categoryId', required: false })
|
||||
@ApiOperation({ summary: "لیست مقالات" })
|
||||
@ApiQuery({ name: "page", required: false })
|
||||
@ApiQuery({ name: "limit", required: false })
|
||||
@ApiQuery({ name: "search", required: false })
|
||||
@ApiQuery({ name: "status", required: false })
|
||||
@ApiQuery({ name: "categoryId", required: false })
|
||||
async getBlogs(
|
||||
@Query()
|
||||
query: PaginationDto & {
|
||||
@@ -51,74 +51,74 @@ export class BlogsController {
|
||||
return this.blogsService.getBlogs(query);
|
||||
}
|
||||
|
||||
@Get('authors')
|
||||
@ApiOperation({ summary: 'لیست کاربران برای انتخاب به عنوان نویسنده' })
|
||||
@Get("authors")
|
||||
@ApiOperation({ summary: "لیست کاربران برای انتخاب به عنوان نویسنده" })
|
||||
async getAuthors() {
|
||||
const data = await this.blogsService.getAuthors();
|
||||
return { success: true, data };
|
||||
}
|
||||
|
||||
@Get('categories')
|
||||
@ApiOperation({ summary: 'لیست دستهبندیهای وبلاگ' })
|
||||
@Get("categories")
|
||||
@ApiOperation({ summary: "لیست دستهبندیهای وبلاگ" })
|
||||
async getBlogCategories() {
|
||||
const data = await this.blogsService.getBlogCategories();
|
||||
return { success: true, data };
|
||||
}
|
||||
|
||||
@Post('categories')
|
||||
@ApiOperation({ summary: 'ایجاد دستهبندی جدید برای وبلاگ' })
|
||||
@Post("categories")
|
||||
@ApiOperation({ summary: "ایجاد دستهبندی جدید برای وبلاگ" })
|
||||
async createBlogCategory(@Body() body: Prisma.BlogCategoryCreateInput) {
|
||||
const data = await this.blogsService.createBlogCategory(body);
|
||||
return { success: true, data };
|
||||
}
|
||||
|
||||
@Put('categories/:id')
|
||||
@ApiOperation({ summary: 'ویرایش دستهبندی وبلاگ' })
|
||||
@Put("categories/:id")
|
||||
@ApiOperation({ summary: "ویرایش دستهبندی وبلاگ" })
|
||||
async updateBlogCategory(
|
||||
@Param('id') id: string,
|
||||
@Param("id") id: string,
|
||||
@Body() body: Prisma.BlogCategoryUpdateInput,
|
||||
) {
|
||||
const data = await this.blogsService.updateBlogCategory(id, body);
|
||||
return { success: true, data };
|
||||
}
|
||||
|
||||
@Delete('categories/:id')
|
||||
@ApiOperation({ summary: 'حذف دستهبندی وبلاگ' })
|
||||
async deleteBlogCategory(@Param('id') id: string) {
|
||||
@Delete("categories/:id")
|
||||
@ApiOperation({ summary: "حذف دستهبندی وبلاگ" })
|
||||
async deleteBlogCategory(@Param("id") id: string) {
|
||||
await this.blogsService.deleteBlogCategory(id);
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@Get('tags')
|
||||
@ApiOperation({ summary: 'لیست تگهای وبلاگ' })
|
||||
@Get("tags")
|
||||
@ApiOperation({ summary: "لیست تگهای وبلاگ" })
|
||||
async getBlogTags() {
|
||||
const data = await this.blogsService.getBlogTags();
|
||||
return { success: true, data };
|
||||
}
|
||||
|
||||
@Post('tags')
|
||||
@ApiOperation({ summary: 'ایجاد تگ جدید برای وبلاگ' })
|
||||
@Post("tags")
|
||||
@ApiOperation({ summary: "ایجاد تگ جدید برای وبلاگ" })
|
||||
async createBlogTag(@Body() body: { name: string; slug?: string }) {
|
||||
const data = await this.blogsService.createBlogTag(body);
|
||||
return { success: true, data };
|
||||
}
|
||||
|
||||
@Delete('tags/:id')
|
||||
@ApiOperation({ summary: 'حذف تگ وبلاگ' })
|
||||
async deleteBlogTag(@Param('id') id: string) {
|
||||
@Delete("tags/:id")
|
||||
@ApiOperation({ summary: "حذف تگ وبلاگ" })
|
||||
async deleteBlogTag(@Param("id") id: string) {
|
||||
await this.blogsService.deleteBlogTag(id);
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'دریافت مشخصات یک مقاله' })
|
||||
async getBlogById(@Param('id') id: string) {
|
||||
@Get(":id")
|
||||
@ApiOperation({ summary: "دریافت مشخصات یک مقاله" })
|
||||
async getBlogById(@Param("id") id: string) {
|
||||
const data = await this.blogsService.getBlogById(id);
|
||||
return { success: true, data };
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'ایجاد مقاله جدید' })
|
||||
@ApiOperation({ summary: "ایجاد مقاله جدید" })
|
||||
async createBlog(
|
||||
@Body() body: any,
|
||||
@Request() req: { user: { id: string } },
|
||||
@@ -127,31 +127,31 @@ export class BlogsController {
|
||||
return { success: true, data };
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
@ApiOperation({ summary: 'ویرایش مقاله' })
|
||||
async updateBlog(@Param('id') id: string, @Body() body: any) {
|
||||
@Put(":id")
|
||||
@ApiOperation({ summary: "ویرایش مقاله" })
|
||||
async updateBlog(@Param("id") id: string, @Body() body: any) {
|
||||
const data = await this.blogsService.updateBlog(id, body);
|
||||
return { success: true, data };
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: 'حذف مقاله' })
|
||||
async deleteBlog(@Param('id') id: string) {
|
||||
@Delete(":id")
|
||||
@ApiOperation({ summary: "حذف مقاله" })
|
||||
async deleteBlog(@Param("id") id: string) {
|
||||
await this.blogsService.deleteBlog(id);
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
// Blog Comments endpoints
|
||||
@Get('comments')
|
||||
@ApiOperation({ summary: 'لیست نظرات مقالات' })
|
||||
@Get("comments")
|
||||
@ApiOperation({ summary: "لیست نظرات مقالات" })
|
||||
@ApiQuery({
|
||||
name: 'status',
|
||||
name: "status",
|
||||
required: false,
|
||||
description: 'PENDING | APPROVED | REJECTED',
|
||||
description: "PENDING | APPROVED | REJECTED",
|
||||
})
|
||||
@ApiQuery({ name: 'blogId', required: false })
|
||||
@ApiQuery({ name: 'page', required: false })
|
||||
@ApiQuery({ name: 'limit', required: false })
|
||||
@ApiQuery({ name: "blogId", required: false })
|
||||
@ApiQuery({ name: "page", required: false })
|
||||
@ApiQuery({ name: "limit", required: false })
|
||||
async getComments(
|
||||
@Query()
|
||||
query: {
|
||||
@@ -164,18 +164,18 @@ export class BlogsController {
|
||||
return this.blogsService.getComments(query);
|
||||
}
|
||||
|
||||
@Patch('comments/:id/status')
|
||||
@ApiOperation({ summary: 'تغییر وضعیت نظر (تأیید/رد)' })
|
||||
@Patch("comments/:id/status")
|
||||
@ApiOperation({ summary: "تغییر وضعیت نظر (تأیید/رد)" })
|
||||
async updateCommentStatus(
|
||||
@Param('id') id: string,
|
||||
@Body() body: { status: 'APPROVED' | 'REJECTED' },
|
||||
@Param("id") id: string,
|
||||
@Body() body: { status: "APPROVED" | "REJECTED" },
|
||||
) {
|
||||
return this.blogsService.updateCommentStatus(id, body.status);
|
||||
}
|
||||
|
||||
@Delete('comments/:id')
|
||||
@ApiOperation({ summary: 'حذف نظر' })
|
||||
async deleteComment(@Param('id') id: string) {
|
||||
@Delete("comments/:id")
|
||||
@ApiOperation({ summary: "حذف نظر" })
|
||||
async deleteComment(@Param("id") id: string) {
|
||||
await this.blogsService.deleteComment(id);
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user