42 lines
1.2 KiB
TypeScript
42 lines
1.2 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 { pageSchema, type PageInput } from '../identity/identity.schemas';
|
|
import { SchemaPipe } from '../common/validation.pipe';
|
|
import { ForumPublicStore } from './forum-public.store';
|
|
@Public()
|
|
@UseGuards(StorefrontGuard)
|
|
@Controller('storefront/:organizationId/forum')
|
|
export class PublicForumController {
|
|
constructor(private readonly posts: ForumPublicStore) {}
|
|
@Get()
|
|
list(
|
|
@Param('organizationId', ParseUUIDPipe) org: string,
|
|
@Query(new SchemaPipe(pageSchema)) page: PageInput,
|
|
) {
|
|
return this.posts.list(org, page);
|
|
}
|
|
@Get(':id')
|
|
get(
|
|
@Param('organizationId', ParseUUIDPipe) org: string,
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
) {
|
|
return this.posts.get(org, id);
|
|
}
|
|
@Get(':id/replies')
|
|
replies(
|
|
@Param('organizationId', ParseUUIDPipe) org: string,
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
@Query(new SchemaPipe(pageSchema)) page: PageInput,
|
|
) {
|
|
return this.posts.replies(org, id, page);
|
|
}
|
|
}
|