diff --git a/apps/backend/src/public-api/routes/v1/public.integrations.controller.ts b/apps/backend/src/public-api/routes/v1/public.integrations.controller.ts index af9913e7..74185e59 100644 --- a/apps/backend/src/public-api/routes/v1/public.integrations.controller.ts +++ b/apps/backend/src/public-api/routes/v1/public.integrations.controller.ts @@ -1,5 +1,12 @@ import { - Body, Controller, Get, HttpException, Post, UploadedFile, UseInterceptors + Body, + Controller, + Get, + HttpException, + Post, + Query, + UploadedFile, + UseInterceptors, } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { GetOrgFromRequest } from '@gitroom/nestjs-libraries/user/org.from.request'; @@ -15,6 +22,7 @@ import { PostsService } from '@gitroom/nestjs-libraries/database/prisma/posts/po import { FileInterceptor } from '@nestjs/platform-express'; import { UploadFactory } from '@gitroom/nestjs-libraries/upload/upload.factory'; import { MediaService } from '@gitroom/nestjs-libraries/database/prisma/media/media.service'; +import { GetPostsDto } from '@gitroom/nestjs-libraries/dtos/posts/get.posts.dto'; @ApiTags('Public API') @Controller('/public/v1') @@ -34,7 +42,7 @@ export class PublicIntegrationsController { @UploadedFile('file') file: Express.Multer.File ) { if (!file) { - throw new HttpException({msg: 'No file provided'}, 400); + throw new HttpException({ msg: 'No file provided' }, 400); } const getFile = await this.storage.uploadFile(file); @@ -45,6 +53,19 @@ export class PublicIntegrationsController { ); } + @Get('/posts') + async getPosts( + @GetOrgFromRequest() org: Organization, + @Query() query: GetPostsDto + ) { + const posts = await this._postsService.getPosts(org.id, query); + + return { + posts, + // comments, + }; + } + @Post('/posts') @CheckPolicies([AuthorizationActions.Create, Sections.POSTS_PER_MONTH]) createPost( diff --git a/libraries/nestjs-libraries/src/dtos/posts/get.posts.dto.ts b/libraries/nestjs-libraries/src/dtos/posts/get.posts.dto.ts index 258fa694..b228b821 100644 --- a/libraries/nestjs-libraries/src/dtos/posts/get.posts.dto.ts +++ b/libraries/nestjs-libraries/src/dtos/posts/get.posts.dto.ts @@ -27,7 +27,7 @@ export class GetPostsDto { @Type(() => Number) @IsNumber() - @Max(52) + @Max(12) @Min(1) month: number;