Initial commit: Meshkee CMS API

NestJS backend with Prisma, Docker Compose for Postgres/Redis, and deploy docs for the production VM.
This commit is contained in:
Ali Reza
2026-07-21 17:52:36 +03:30
commit bb59d5e9ba
254 changed files with 37031 additions and 0 deletions
+176
View File
@@ -0,0 +1,176 @@
import {
Body,
Controller,
Delete,
Get,
Param,
Patch,
Post,
Put,
Query,
UseGuards,
} from '@nestjs/common';
import { AuthUser } from '../auth/auth.types';
import { CurrentUser } from '../auth/decorators/current-user.decorator';
import { RequireBusinessPermission } from '../auth/decorators/require-business-permission.decorator';
import { BusinessPermissionGuard } from '../auth/guards/business-permission.guard';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { CategoriesService } from './categories.service';
import { CategoryTechnicalFormService } from './category-technical-form.service';
import { CategoryTechnicalFormAiService } from './category-technical-form-ai.service';
import { CategoryAiService } from './category-ai.service';
import { CategoryVariationsService } from './category-variations.service';
import { CreateCategoryDto, ListCategoriesDto, UpdateCategoryDto } from './dto/category.dto';
import {
ReplaceCategoryTechnicalFormDto,
SuggestCategoryTechnicalFormDto,
} from './dto/category-technical-form.dto';
import { ReplaceCategoryVariationsDto } from './dto/category-variation.dto';
import { GenerateCategoriesDto } from './dto/category-ai.dto';
@Controller('businesses/:businessId/categories')
@UseGuards(JwtAuthGuard, BusinessPermissionGuard)
export class CategoriesController {
constructor(
private readonly service: CategoriesService,
private readonly variationsService: CategoryVariationsService,
private readonly technicalFormService: CategoryTechnicalFormService,
private readonly technicalFormAiService: CategoryTechnicalFormAiService,
private readonly categoryAiService: CategoryAiService,
) {}
@Get('color-presets')
@RequireBusinessPermission('categories.read')
listColorPresets() {
return this.variationsService.listColorPresets();
}
@Get()
@RequireBusinessPermission('categories.read')
list(
@Param('businessId') businessId: string,
@Query() query: ListCategoriesDto,
@CurrentUser() user: AuthUser,
) {
return this.service.list(businessId, query, user);
}
@Post('ai-generate')
@RequireBusinessPermission('categories.create')
generateWithAi(
@Param('businessId') businessId: string,
@Body() dto: GenerateCategoriesDto,
@CurrentUser() user: AuthUser,
) {
return this.categoryAiService.generateProductCategories(businessId, dto, user);
}
@Post()
@RequireBusinessPermission('categories.create')
create(
@Param('businessId') businessId: string,
@Body() dto: CreateCategoryDto,
@CurrentUser() user: AuthUser,
) {
return this.service.create(businessId, dto, user);
}
@Patch(':categoryId')
@RequireBusinessPermission('categories.update')
update(
@Param('businessId') businessId: string,
@Param('categoryId') categoryId: string,
@Body() dto: UpdateCategoryDto,
@CurrentUser() user: AuthUser,
) {
return this.service.update(businessId, categoryId, dto, user);
}
@Get(':categoryId/variations')
@RequireBusinessPermission('categories.read')
listVariations(
@Param('businessId') businessId: string,
@Param('categoryId') categoryId: string,
@CurrentUser() user: AuthUser,
) {
return this.variationsService.listForCategory(businessId, categoryId, user);
}
@Put(':categoryId/variations')
@RequireBusinessPermission('categories.update')
replaceVariations(
@Param('businessId') businessId: string,
@Param('categoryId') categoryId: string,
@Body() dto: ReplaceCategoryVariationsDto,
@CurrentUser() user: AuthUser,
) {
return this.variationsService.replaceForCategory(
businessId,
categoryId,
dto,
user,
);
}
@Get(':categoryId/technical-form')
@RequireBusinessPermission('categories.read')
getTechnicalForm(
@Param('businessId') businessId: string,
@Param('categoryId') categoryId: string,
@CurrentUser() user: AuthUser,
) {
return this.technicalFormService.getForCategory(businessId, categoryId, user);
}
@Put(':categoryId/technical-form')
@RequireBusinessPermission('categories.update')
replaceTechnicalForm(
@Param('businessId') businessId: string,
@Param('categoryId') categoryId: string,
@Body() dto: ReplaceCategoryTechnicalFormDto,
@CurrentUser() user: AuthUser,
) {
return this.technicalFormService.replaceForCategory(
businessId,
categoryId,
dto,
user,
);
}
@Post(':categoryId/technical-form/ai-suggest')
@RequireBusinessPermission('categories.update')
suggestTechnicalForm(
@Param('businessId') businessId: string,
@Param('categoryId') categoryId: string,
@Body() dto: SuggestCategoryTechnicalFormDto,
@CurrentUser() user: AuthUser,
) {
return this.technicalFormAiService.suggestForCategory(
businessId,
categoryId,
dto,
user,
);
}
@Delete(':categoryId')
@RequireBusinessPermission('categories.delete')
remove(
@Param('businessId') businessId: string,
@Param('categoryId') categoryId: string,
@CurrentUser() user: AuthUser,
) {
return this.service.remove(businessId, categoryId, user);
}
}
@Controller('tenants/:host/categories')
export class PublicCategoriesController {
constructor(private readonly service: CategoriesService) {}
@Get()
list(@Param('host') host: string, @Query() query: ListCategoriesDto) {
return this.service.listPublic(host, query);
}
}