Skip to content

Conversation

@jjamming
Copy link
Contributor

🚀 연관된 이슈

📌 작업 내용

  • axios 인스턴스 생성
  • api 응답 타입 생성
  • tanstack qeury 설치 및 query provider 세팅
  • api 엔드포인트 상수화

📸 추가 자료

.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR sets up the foundation for API communication by integrating axios and TanStack Query. It replaces the previous fetch-based approach with a centralized axios instance configuration, adds request/response interceptors for development logging, and establishes API endpoint constants for consistent URL management.

  • Configured axios instance with base URL, timeout, and development logging interceptors
  • Integrated TanStack Query with QueryClientProvider and devtools for data fetching management
  • Standardized API endpoint definitions as parameterized functions with proper URL encoding

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/utils/interceptor.ts Implements development logging interceptor for axios requests/responses
src/utils/instance.ts Creates and configures the axios instance with base URL and headers
src/lib/queryClient.ts Sets up TanStack Query client with caching and retry strategies
src/lib/apis/types.ts Defines TypeScript interfaces for API responses and error handling
src/constants/api.ts Updates API endpoints to include new endpoints with proper path prefixes
src/_BacktestingPage/apis/searchAsset.ts Removes old fetch-based implementation (migrating to axios)
src/App.tsx Integrates QueryClientProvider and React Query devtools
package.json Adds axios and TanStack Query dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

indexPeriod: (marketType: "KOSPI" | "KOSDAQ", startDate?: string, endDate?: string) =>
`/api/index/period/${marketType}?startDate=${startDate}&endDate=${endDate}`,
indexCurrent: () => `/api/index/current`,
searchAsset: (keyword: string) => `/api/stock?keyword=${keyword}`,
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The keyword parameter is not URL encoded, which could lead to malformed URLs or security issues if the keyword contains special characters. Use encodeURIComponent(keyword) as was done in the previous implementation.

Suggested change
searchAsset: (keyword: string) => `/api/stock?keyword=${keyword}`,
searchAsset: (keyword: string) => `/api/stock?keyword=${encodeURIComponent(keyword)}`,

Copilot uses AI. Check for mistakes.
Comment on lines 4 to 9
indexPeriod: (marketType: "KOSPI" | "KOSDAQ", startDate?: string, endDate?: string) =>
`/api/index/period/${marketType}?startDate=${startDate}&endDate=${endDate}`,
indexCurrent: () => `/api/index/current`,
searchAsset: (keyword: string) => `/api/stock?keyword=${keyword}`,
stockData: (stockcode: string, startDate?: string, endDate?: string) =>
`/api/stock/${stockcode}?startDate=${startDate}&endDate=${endDate}`,
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to indexPeriod, when startDate or endDate are undefined, the query parameters will include 'undefined' as string values. Optional query parameters should be conditionally included or filtered out when undefined.

Suggested change
indexPeriod: (marketType: "KOSPI" | "KOSDAQ", startDate?: string, endDate?: string) =>
`/api/index/period/${marketType}?startDate=${startDate}&endDate=${endDate}`,
indexCurrent: () => `/api/index/current`,
searchAsset: (keyword: string) => `/api/stock?keyword=${keyword}`,
stockData: (stockcode: string, startDate?: string, endDate?: string) =>
`/api/stock/${stockcode}?startDate=${startDate}&endDate=${endDate}`,
indexPeriod: (marketType: "KOSPI" | "KOSDAQ", startDate?: string, endDate?: string) => {
const params = [
startDate !== undefined ? `startDate=${encodeURIComponent(startDate)}` : null,
endDate !== undefined ? `endDate=${encodeURIComponent(endDate)}` : null,
].filter(Boolean).join('&');
return `/api/index/period/${marketType}` + (params ? `?${params}` : '');
},
indexCurrent: () => `/api/index/current`,
searchAsset: (keyword: string) => `/api/stock?keyword=${keyword}`,
stockData: (stockcode: string, startDate?: string, endDate?: string) => {
const params = [
startDate !== undefined ? `startDate=${encodeURIComponent(startDate)}` : null,
endDate !== undefined ? `endDate=${encodeURIComponent(endDate)}` : null,
].filter(Boolean).join('&');
return `/api/stock/${stockcode}` + (params ? `?${params}` : '');
},

Copilot uses AI. Check for mistakes.
queries: {
// 기본 staleTime: 5분 (5분 동안은 fresh한 데이터로 간주)
staleTime: 1000 * 60 * 5,
// 기본 cacheTime: 10분 (10분 동안 캐시 유지)
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions 'cacheTime' but the property is 'gcTime'. While this is the correct property name in TanStack Query v5 (renamed from cacheTime in v4), the comment should be updated to match: '기본 gcTime: 10분 (10분 동안 캐시 유지)' for clarity and consistency.

Suggested change
// 기본 cacheTime: 10분 (10분 동안 캐시 유지)
// 기본 gcTime: 10분 (10분 동안 캐시 유지)

Copilot uses AI. Check for mistakes.
@jjamming jjamming merged commit 64d9bfc into develop Nov 14, 2025
1 check passed
@jjamming jjamming deleted the chore/#28-axios-setting branch November 14, 2025 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants