Skip to content

Commit

Permalink
FIX :: 팁 검색 500 에러 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
soyeonkim0227 committed Jun 10, 2024
1 parent 6483ecf commit 0f0ce75
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/core/tip/tip.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
WriteTipRequest,
} from '../../presentation/tip/dto/tip.request';
import { Tip } from '../../domain/tip/tip.entity';
import { ForbiddenException, HttpException, Inject, NotFoundException } from '@nestjs/common';
import { ForbiddenException, HttpException, Inject } from '@nestjs/common';
import { ReadCurrentUserPort } from '../auth/port/auth.out.port';
import { ReadTipPort, SaveTipPort, UpdateTipPort } from './port/tip.out.port';

Expand Down
34 changes: 18 additions & 16 deletions src/presentation/tip/tip.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
BadRequestException,
Body,
Controller,
Get,
Expand All @@ -24,6 +25,7 @@ import {
SearchTipUseCase,
WriteTipUseCase,
} from '../../core/tip/port/tip.in.port';
import { SortType } from 'src/domain/post/post.entity';

@Controller('tip')
export class TipController {
Expand All @@ -40,6 +42,22 @@ export class TipController {
private readonly readRecommendedTipUseCase: ReadRecommendedTipUseCase,
) {}

@Get('/search')
async searchTip(
@Query() dto: SearchTipRequest,
@Headers('Authorization') token: string,
@Res() res: Response,
): Promise<Response> {
if (!token) {
throw new UnauthorizedException('Permission denied');
}

return res
.status(200)
.json({ tips: await this.searchTipUseCase.searchTip(dto, token) })
.send();
}

@Get('/recommend')
async readRecommended(@Res() res: Response): Promise<Response> {
return res
Expand Down Expand Up @@ -95,20 +113,4 @@ export class TipController {
.json(await this.readDetailTipUseCase.readDetail(tipId, token))
.sendStatus(200);
}

@Get('/search')
async searchTip(
@Headers('Authorization') token: string,
@Query() dto: SearchTipRequest,
@Res() res: Response,
): Promise<Response> {
if (!token) {
throw new UnauthorizedException('Permission denied');
}

return res
.status(200)
.json({ tips: await this.searchTipUseCase.searchTip(dto, token) })
.send();
}
}

0 comments on commit 0f0ce75

Please sign in to comment.