diff --git a/BE/src/auth/auth.controller.ts b/BE/src/auth/auth.controller.ts index 88c7ad5..fbb629e 100644 --- a/BE/src/auth/auth.controller.ts +++ b/BE/src/auth/auth.controller.ts @@ -15,6 +15,7 @@ import { Request, Response } from 'express'; import { ConfigService } from '@nestjs/config'; import { AuthService } from './auth.service'; import { AuthCredentialsDto } from './dto/auth-credentials.dto'; +import { OptionalAuthGuard } from './optional-auth-guard'; @Controller('/api/auth') export class AuthController { @@ -83,13 +84,14 @@ export class AuthController { @ApiOperation({ summary: '로그인 상태 확인 API' }) @Get('/check') - @UseGuards(AuthGuard('jwt')) + @UseGuards(OptionalAuthGuard) @ApiResponse({ status: 200, description: '로그인 상태 조회 성공', example: { isLogin: true }, }) - check() { + check(@Req() req: Request) { + if (!req.user) return { isLogin: false }; return { isLogin: true }; } diff --git a/BE/src/common/websocket/base-socket.domain-service.ts b/BE/src/common/websocket/base-socket.domain-service.ts index 13f000f..f215824 100644 --- a/BE/src/common/websocket/base-socket.domain-service.ts +++ b/BE/src/common/websocket/base-socket.domain-service.ts @@ -47,11 +47,12 @@ export class BaseSocketDomainService implements OnModuleInit { if (data.length < 2) { const json = JSON.parse(data[0]); - if (json.body) + if (json.body) { this.logger.log( `한국투자증권 웹소켓 연결: ${json.body.msg1}`, json.header.tr_id, ); + } if (json.header.tr_id === 'PINGPONG') this.socket.pong(JSON.stringify(json)); return; diff --git a/BE/src/stock/trade/history/stock-trade-history.service.ts b/BE/src/stock/trade/history/stock-trade-history.service.ts index 34d077b..198e9ab 100644 --- a/BE/src/stock/trade/history/stock-trade-history.service.ts +++ b/BE/src/stock/trade/history/stock-trade-history.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@nestjs/common'; +import { Injectable, InternalServerErrorException } from '@nestjs/common'; import { KoreaInvestmentDomainService } from '../../../common/koreaInvestment/korea-investment.domain-service'; import { InquireCCNLApiResponse } from './interface/Inquire-ccnl.interface'; import { TodayStockTradeHistoryOutputDto } from './dto/today-stock-trade-history-output.dto'; @@ -35,7 +35,12 @@ export class StockTradeHistoryService { queryParams, ); - await this.stockPriceSocketService.subscribeByCode(stockCode); + try { + await this.stockPriceSocketService.subscribeByCode(stockCode); + } catch (e) { + throw new InternalServerErrorException(e); + } + return this.formatTodayStockTradeHistoryData(response.output); } diff --git a/README.md b/README.md index b55a23c..969d460 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@