Add published user products to the storefront sitemap.

Expose /sitemap-user-products.xml when customer_products is enabled, invalidate on listing mutations, and proxy the new path from nginx provision scripts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-27 07:16:05 +03:30
co-authored by Cursor
parent fb04425df7
commit 0d9c2fd8ea
14 changed files with 144 additions and 5 deletions
+8 -1
View File
@@ -2,6 +2,7 @@ import { Module } from '@nestjs/common';
import { AuthModule } from '../auth/auth.module';
import { CategoriesModule } from '../categories/categories.module';
import { MediaModule } from '../media/media.module';
import { SitemapModule } from '../sitemap/sitemap.module';
import { TenantModule } from '../tenant/tenant.module';
import { UserProductsAdminController } from './user-products.admin.controller';
import { UserProductsController } from './user-products.controller';
@@ -9,7 +10,13 @@ import { PublicUserProductsController } from './user-products.public.controller'
import { UserProductsService } from './user-products.service';
@Module({
imports: [AuthModule, CategoriesModule, MediaModule, TenantModule],
imports: [
AuthModule,
CategoriesModule,
MediaModule,
TenantModule,
SitemapModule,
],
controllers: [
UserProductsController,
UserProductsAdminController,
@@ -26,6 +26,7 @@ import {
UserProductTechnicalValueDto,
} from './dto/user-product.dto';
import { TenantService } from '../tenant/tenant.service';
import { SitemapService } from '../sitemap/sitemap.service';
function slugify(value: string): string {
return (
@@ -109,6 +110,7 @@ export class UserProductsService {
private readonly technicalFormService: CategoryTechnicalFormService,
private readonly mediaService: MediaService,
private readonly tenant: TenantService,
private readonly sitemap: SitemapService,
) {}
async listPublic(host: string, query: ListPublicUserProductsDto) {
@@ -404,6 +406,8 @@ export class UserProductsService {
include: userProductAdminListInclude,
});
await this.sitemap.invalidateForBusiness(businessId);
return {
message: 'User product created successfully',
product: withUser
@@ -621,6 +625,8 @@ export class UserProductsService {
}
await this.mediaService.deleteUnused(businessId, dropped);
await this.sitemap.invalidateForBusiness(businessId);
return {
message: 'User product updated successfully',
product: this.serializeAdminListItem(updated, category ?? undefined),
@@ -680,6 +686,8 @@ export class UserProductsService {
await this.mediaService.deleteUnused(businessId, mediaIds);
await this.sitemap.invalidateForBusiness(businessId);
return { message: 'User product deleted successfully' };
}
@@ -879,6 +887,8 @@ export class UserProductsService {
updated.id,
]);
await this.sitemap.invalidateForBusiness(businessId);
return {
message: 'User product status updated successfully',
product: this.serializeAdminListItem(
@@ -961,6 +971,8 @@ export class UserProductsService {
await tx.userProduct.delete({ where: { id: productId } });
});
await this.sitemap.invalidateForBusiness(businessId);
return { message: 'User product deleted successfully' };
}