35 lines
990 B
TypeScript
35 lines
990 B
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Param,
|
|
ParseUUIDPipe,
|
|
Query,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { SchemaPipe } from '../common/validation.pipe';
|
|
import { Public } from '../identity/access.decorator';
|
|
import { StorefrontStore } from './storefront.store';
|
|
import { StorefrontGuard } from './storefront.guard';
|
|
import { catalogQuery, type CatalogQuery } from './catalog.schemas';
|
|
|
|
@Public()
|
|
@UseGuards(StorefrontGuard)
|
|
@Controller('storefront/:organizationId/products')
|
|
export class StorefrontController {
|
|
constructor(private readonly storefront: StorefrontStore) {}
|
|
@Get()
|
|
list(
|
|
@Param('organizationId', ParseUUIDPipe) organizationId: string,
|
|
@Query(new SchemaPipe(catalogQuery)) query: CatalogQuery,
|
|
) {
|
|
return this.storefront.list(organizationId, query);
|
|
}
|
|
@Get(':id')
|
|
get(
|
|
@Param('organizationId', ParseUUIDPipe) organizationId: string,
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
) {
|
|
return this.storefront.get(organizationId, id);
|
|
}
|
|
}
|