chore(clean): pass all lint, typecheck and build checks with zero errors
Deploy Canina / deploy (push) Successful in 35s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 6s

This commit is contained in:
parsa aghaei committed 2026-09-02 10:57:21 +03:30
1 parent 6fa1f2c906
commit a7d842ba10
19 files changed
+5185 -5110

No files matched your search

+40 -13
View File
@@ -69,13 +69,14 @@ function buildTorobProductSpec(product: {
category?: { name?: string } | null;
}): Record<string, string> {
const spec: Record<string, string> = {
'برند': 'کنینا (Canina Pharma Germany)',
برند: 'کنینا (Canina Pharma Germany)',
'کشور سازنده': 'آلمان',
'ضمانت': 'اصالت ۱۰۰٪ کالای آلمانی و سلامت فیزیکی',
ضمانت: 'اصالت ۱۰۰٪ کالای آلمانی و سلامت فیزیکی',
};
if (product.suitableFor) {
spec['گونه هدف'] = product.suitableFor === 'هر دو' ? 'سگ و گربه' : product.suitableFor;
spec['گونه هدف'] =
product.suitableFor === 'هر دو' ? 'سگ و گربه' : product.suitableFor;
}
const numSize = Number(product.packageSize);
@@ -101,14 +102,22 @@ export class TorobController {
constructor(private readonly prisma: PrismaService) {}
@Get('products')
@ApiOperation({ summary: 'دریافت محصولات جهت وب‌سرویس خودکار ترب (Torob API)' })
@ApiOperation({
summary: 'دریافت محصولات جهت وب‌سرویس خودکار ترب (Torob API)',
})
async getTorobProducts(
@Query('page') pageQuery?: string,
@Query('page_size') pageSizeQuery?: string,
) {
const page = Math.max(1, parseInt(pageQuery || '1', 10));
const pageSize = Math.min(100, Math.max(10, parseInt(pageSizeQuery || '100', 10)));
const baseUrl = (process.env.FRONTEND_URL || 'https://canina.ir').replace(/\/$/, '');
const pageSize = Math.min(
100,
Math.max(10, parseInt(pageSizeQuery || '100', 10)),
);
const baseUrl = (process.env.FRONTEND_URL || 'https://canina.ir').replace(
/\/$/,
'',
);
const whereCondition = {
noIndex: false,
@@ -134,7 +143,7 @@ export class TorobController {
const slug = product.slug || product.artNo || product.id;
const pageUrl = `${baseUrl}/shop/${slug}`;
const productId = String(product.artNo || product.id || slug);
const title = buildTorobProductTitle(product);
const spec = buildTorobProductSpec(product);
@@ -142,8 +151,15 @@ export class TorobController {
const rawEn = (product.nameEn || '').trim();
const numSize = Number(product.packageSize);
const unit = (product.unit || '').trim();
const sizeStr = numSize && numSize > 0 ? (unit ? `${numSize} ${unit}` : `${numSize}`) : '';
let subtitle = rawEn.startsWith('Canina') ? rawEn : `Canina ${rawEn}`.trim();
const sizeStr =
numSize && numSize > 0
? unit
? `${numSize} ${unit}`
: `${numSize}`
: '';
let subtitle = rawEn.startsWith('Canina')
? rawEn
: `Canina ${rawEn}`.trim();
if (sizeStr && !subtitle.includes(sizeStr)) {
subtitle = `${subtitle} - ${sizeStr}`;
}
@@ -151,12 +167,16 @@ export class TorobController {
const rawImage = product.ogImage || product.imageUrl || '';
let imageLink = '';
if (rawImage) {
const cleanImage = rawImage.trim()
const cleanImage = rawImage
.trim()
.replace(/^https?:\/\/api\.canina\.ir/i, '')
.replace(/^https?:\/\/localhost:\d+/i, '')
.replace(/^https?:\/\/127\.0\.0\.1:\d+/i, '');
if (cleanImage.startsWith('http://') || cleanImage.startsWith('https://')) {
if (
cleanImage.startsWith('http://') ||
cleanImage.startsWith('https://')
) {
imageLink = cleanImage;
} else {
const cleanPath = cleanImage.replace(/^\/?(api\/)?(uploads\/)?/, '');
@@ -164,7 +184,11 @@ export class TorobController {
}
}
const isInStock = product.stockStatus !== 'DISCONTINUED' && String(product.stockStatus || '').toLowerCase().includes('in');
const isInStock =
product.stockStatus !== 'DISCONTINUED' &&
String(product.stockStatus || '')
.toLowerCase()
.includes('in');
const price = Number(product.priceValue || 0);
const oldPrice = Number(product.priceValue || 0);
@@ -179,7 +203,10 @@ export class TorobController {
availability: isInStock ? 'instock' : 'outofstock',
image_link: imageLink,
guarantee: 'ضمانت اصالت ۱۰۰٪ کمپانی Canina آلمان و اصالت کالا',
category_name: product.category?.name || product.categorySlug || 'مکمل حیوانات خانگی',
category_name:
product.category?.name ||
product.categorySlug ||
'مکمل حیوانات خانگی',
spec,
};
});