Add public catalog APIs, website slots, featured slots, and int category/product IDs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-09-27 18:30:36 +03:30
co-authored by Cursor
parent 15dd3597f0
commit 835c8a0ac1
25 changed files with 1399 additions and 41 deletions
+33 -3
View File
@@ -1,4 +1,4 @@
import { Controller, Get, Param, Query } from '@nestjs/common';
import { Controller, Get, Param, ParseIntPipe, Query } from '@nestjs/common';
import { PublicService } from './public.service';
@Controller('public')
@@ -19,23 +19,53 @@ export class PublicController {
@Query('minPrice') minPrice?: number,
@Query('maxPrice') maxPrice?: number,
) {
const parsedCategoryId =
categoryId !== undefined && categoryId !== ''
? Number(categoryId)
: undefined;
return this.publicService.listProducts({
storeId,
storeSlug,
name,
categoryId,
categoryId:
parsedCategoryId !== undefined && Number.isFinite(parsedCategoryId)
? parsedCategoryId
: undefined,
minPrice,
maxPrice,
});
}
@Get('products/:id')
findProduct(@Param('id') id: string) {
findProduct(@Param('id', ParseIntPipe) id: number) {
return this.publicService.findProduct(id);
}
@Get('categories')
listCategories(@Query('storeSlug') storeSlug?: string) {
return this.publicService.listCategories(storeSlug);
}
@Get('search')
search(
@Query('q') q?: string,
@Query('storeSlug') storeSlug?: string,
@Query('limit') limit?: number,
) {
return this.publicService.search({
q,
storeSlug,
limit: limit !== undefined ? Number(limit) : undefined,
});
}
@Get('blogs')
listBlogs(@Query('storeSlug') storeSlug?: string) {
return this.publicService.listBlogs(storeSlug);
}
@Get('website-slots')
listWebsiteSlots(@Query('storeSlug') storeSlug?: string) {
return this.publicService.listWebsiteSlots(storeSlug);
}
}