35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Param,
|
|
ParseUUIDPipe,
|
|
Query,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { Public } from '../identity/access.decorator';
|
|
import { StorefrontGuard } from '../catalog/storefront.guard';
|
|
import { SchemaPipe } from '../common/validation.pipe';
|
|
import { pageSchema, type PageInput } from '../identity/identity.schemas';
|
|
import { blogSlugSchema } from './blog.schemas';
|
|
import { BlogReadStore } from './blog-read.store';
|
|
@Public()
|
|
@UseGuards(StorefrontGuard)
|
|
@Controller('storefront/:organizationId/blog')
|
|
export class PublicBlogController {
|
|
constructor(private readonly articles: BlogReadStore) {}
|
|
@Get()
|
|
list(
|
|
@Param('organizationId', ParseUUIDPipe) organizationId: string,
|
|
@Query(new SchemaPipe(pageSchema)) page: PageInput,
|
|
) {
|
|
return this.articles.publicList(organizationId, page);
|
|
}
|
|
@Get(':slug')
|
|
get(
|
|
@Param('organizationId', ParseUUIDPipe) organizationId: string,
|
|
@Param('slug', new SchemaPipe(blogSlugSchema)) slug: string,
|
|
) {
|
|
return this.articles.publicGet(organizationId, slug);
|
|
}
|
|
}
|