From 8e6d01f2a9691211172754084a46793f41ed50d3 Mon Sep 17 00:00:00 2001 From: kyeah Date: Sat, 7 Sep 2024 12:13:05 -0600 Subject: [PATCH] feat: get other profile at home --- src/domain/home/home.controller.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/domain/home/home.controller.ts b/src/domain/home/home.controller.ts index 956d590..f5b59b6 100644 --- a/src/domain/home/home.controller.ts +++ b/src/domain/home/home.controller.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Get, Put, UseGuards } from '@nestjs/common'; +import { Body, Controller, Get, Param, Put, UseGuards } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { AuthGuard } from '@nestjs/passport'; import { HomeService } from './home.service'; @@ -6,11 +6,17 @@ import { JwtPayload } from 'src/interfaces/auth'; import { HomeInfoResponseDto, likeHomeAnswerDto } from './dtos'; import { User } from 'src/decorators/accessUser.decorator'; import { Docs } from 'src/decorators/swagger/home.decorator'; +import { OtherProfileDocs } from 'src/decorators/swagger/blurting.decorator'; +import { BlurtingProfileDto } from '../blurting/dtos'; +import { BlurtingService } from '../blurting/blurting.service'; @Controller('home') @ApiTags('home') export class HomeController { - constructor(private readonly homeService: HomeService) {} + constructor( + private readonly homeService: HomeService, + private readonly blurtingService: BlurtingService, + ) {} @Get('/') @UseGuards(AuthGuard('access')) @@ -42,6 +48,17 @@ export class HomeController { return await this.homeService.getRandomUsers(id); } + @UseGuards(AuthGuard('access')) + @Get('/profile/:other') + @OtherProfileDocs() + async getBlurtingProfile( + @User() userPayload: JwtPayload, + @Param('other') other: number, + ): Promise { + const { id } = userPayload; + return this.blurtingService.getProfile(id, other); + } + @Get('/version') @UseGuards(AuthGuard('access')) @Docs('version')