feat(frontend): TanStack Query 기반 apis 레이어 추가

- auth/negotiation 도메인별 api/keys/queries/mutations/type 5파일 구조
- axios 인스턴스: access token 주입, 434 만료 시 refresh 자동 재발급(단일 비행)
  후 원요청 재시도, 433/435/1203(TOKEN_REVOKED) 시 세션 종료 처리
- HTTP 200 + result.success=false 비즈니스 에러를 ApiError 로 변환,
  에러코드별 한국어 메시지 맵(getApiErrorMessage) 제공
- 토큰 localStorage 저장소(tokenStorage)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
민헌andClaude Opus 4.8 committed 2026-06-18 13:12:07 +09:00
1 parent 2480a47efe
commit a867daa98f
16 files changed
+629

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
// 인증 엔드포인트 호출 함수 (순수 HTTP 레이어, React 의존 없음).
// refresh_token 재발급은 http.ts 인터셉터가 자동 처리하므로 여기서 노출하지 않는다.
import { http } from '@/apis/http'
import type {
CreateAccountRequest,
CreateAccountResponse,
LoginRequest,
LoginResponse,
LogoutResponse,
MeResponse,
} from './auth.type'
export const authApi = {
/** POST /v1/auth/login — ID/PW 로 로그인, access/refresh 토큰 발급 */
login: async (body: LoginRequest): Promise<LoginResponse> => {
const res = await http.post<LoginResponse>('/v1/auth/login', body)
return res.data
},
/** POST /v1/auth/create — 신규 공급사 유저 계정 생성 */
createAccount: async (body: CreateAccountRequest): Promise<CreateAccountResponse> => {
const res = await http.post<CreateAccountResponse>('/v1/auth/create', body)
return res.data
},
/** GET /v1/auth/me — 현재 로그인 유저 정보 (access token 필요) */
me: async (): Promise<MeResponse> => {
const res = await http.get<MeResponse>('/v1/auth/me')
return res.data
},
/** POST /v1/auth/logout — 서버측 토큰 폐기(단일 세션) */
logout: async (): Promise<LogoutResponse> => {
const res = await http.post<LogoutResponse>('/v1/auth/logout')
return res.data
},
}