Skip to content

[Dev 77] Axios, Zustand 초기 세팅 #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 16, 2025
Merged

[Dev 77] Axios, Zustand 초기 세팅 #88

merged 6 commits into from
Feb 16, 2025

Conversation

ChaeYubin
Copy link
Contributor

@ChaeYubin ChaeYubin commented Feb 14, 2025

📑 작업 개요

  • Axios instance 생성
  • Zustand 설치

✨ 작업 이유

  • 공용으로 사용할 api instance 필요
  • zustand 설치

📌 작업 내용

  • .env.localNEXT_PUBLIC_SERVER_ADDRESS로 서버 주소용 변수 만들어서 사용해주시면 됩니다.
  • zustand 설치했고 store 디렉토리 생성해두었습니다.

🤝🏻 해당 부분을 중점적으로 리뷰해주세요!

services/endpoint.ts에서 서버로 보낼 요청들의 엔드포인트를 모아서 관리하면 어떨까요? 현재 만들어둔 파일이 예시입니다!
혹시 더 좋은 방법이 있다면 알려주세요🙂

🎟️ 관련 이슈

close: #87

Summary by CodeRabbit

  • 새로운 기능

    • 사용자 인증, 목표 조회, 할 일 데이터 처리 등 서버 통신을 강화하기 위해 새로운 API 클라이언트와 엔드포인트 구성이 추가되었습니다.
  • 코드 정비

    • 내부 종속성 및 개발 도구 관리가 업데이트되어 코드 품질과 성능이 향상되었습니다.
    • @tanstack/react-query-devtoolszustand 패키지가 추가되었습니다.

@ChaeYubin ChaeYubin self-assigned this Feb 14, 2025
Copy link

coderabbitai bot commented Feb 14, 2025

Walkthrough

이번 PR은 package.json에서 lint-staged 명령어 수정과 의존성 관리 변경을 수행합니다. @tanstack/react-query-devtoolszustand 패키지가 추가되었으며, TypeScript 관련 패키지가 devDependencies에 재추가되었습니다. 또한, 환경 변수 기반의 baseURL과 함께 credentials를 포함하는 Axios 클라이언트를 생성하는 새로운 파일과, API 엔드포인트를 구조화한 상수를 포함하는 파일이 도입되었습니다.

Changes

파일 변경 내용
package.json lint-staged 명령어에서 . 제거; @tanstack/react-query-devtools가 dependencies에 추가되고 devDependencies에서 제거됨; zustand 추가; ts-jest, ts-node, typescript가 devDependencies에 재추가됨.
src/lib/axios.ts 새로운 Axios 클라이언트 인스턴스(apiClient) 생성 파일 추가. baseURL은 NEXT_PUBLIC_SERVER_ADDRESS 환경 변수를 사용하며, 요청 시 credentials 포함.
src/services/endPoint.ts API 엔드포인트들을 구조화한 apiEndPoint 상수 추가 (auth: login, signUp; goal: getGoals; todo: getTodos).
src/services/endpoint.ts API 엔드포인트들을 구조화한 ENDPOINT 상수 추가 (AUTH: LOGIN, SIGNUP; GOAL: 여러 엔드포인트; TODO: 여러 엔드포인트).

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant A as apiClient (Axios)
    participant S as Server
    C->>A: API 요청 (엔드포인트 사용)
    A->>S: HTTP 요청 전송
    S-->>A: 응답 반환
    A-->>C: 응답 전달
Loading

Suggested reviewers

  • hvrain
  • xorms571

Poem

나는 깡총깡총, 토끼의 발걸음으로
코드 숲에서 새로운 길을 찾아나서네.
axios와 endpoint가 만나는 곳에
빛나는 변화의 꽃들이 피어나고,
작은 발자국마다 꿈이 남아
모두에게 즐거운 소식을 전하리라! 🐰

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/services/endPoint.ts (1)

1-12: API 엔드포인트 구조가 잘 정리되어 있습니다!

전반적인 구조가 기능별로 잘 구분되어 있어 관리하기 좋습니다.

다만 몇 가지 개선사항을 제안드립니다:

  1. API 버전 관리를 위해 경로에 버전을 추가하는 것이 좋습니다.
  2. 엔드포인트 경로의 명명 규칙을 일관되게 유지하는 것이 좋습니다.

다음과 같이 수정하는 것을 고려해보세요:

 export const apiEndPoint = {
   auth: {
-    login: "/auth/login",
-    signUp: "/auth/signup",
+    login: "/v1/auth/login",
+    signUp: "/v1/auth/sign-up",
   },
   goal: {
-    getGoals: "/goals",
+    getGoals: "/v1/goals",
   },
   todo: {
-    getTodos: "/todos",
+    getTodos: "/v1/todos",
   },
 };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca87054 and 81f7c95.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • package.json (3 hunks)
  • src/lib/axios.ts (1 hunks)
  • src/services/endPoint.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/lib/axios.ts
🔇 Additional comments (1)
package.json (1)

76-78: TypeScript 관련 패키지들이 적절하게 추가되었습니다.

ts-jest, ts-node, typescript 패키지들이 devDependencies에 올바르게 추가되었습니다.

Copy link
Contributor

@typeYu typeYu left a comment

Choose a reason for hiding this comment

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

고생하셨습니다

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/services/endpoint.ts (2)

2-5: API 버전 관리 도입을 고려해보세요.

현재 엔드포인트에 버전 정보가 없습니다. API 버전 관리를 위해 다음과 같은 구조를 제안드립니다:

  AUTH: {
-   LOGIN: "/api/login",
-   SIGNUP: "/api/signup",
+   LOGIN: "/api/v1/login",
+   SIGNUP: "/api/v1/signup",
  },

6-12: ID 타입 안전성 강화를 제안드립니다.

목표(goal) ID의 타입이 number로 지정되어 있습니다. 더 명확한 타입 정의를 위해 다음과 같은 개선을 고려해보세요:

type GoalId = number;

// 사용 예시:
GET_BY_ID: (id: GoalId) => `/api/goals/${id}`,

이렇게 하면:

  1. ID의 의미가 더 명확해집니다
  2. 추후 ID 형식 변경 시 용이합니다
  3. 타입 재사용이 가능합니다
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2c3d87 and 07c3086.

📒 Files selected for processing (1)
  • src/services/endpoint.ts (1 hunks)
🔇 Additional comments (1)
src/services/endpoint.ts (1)

1-1: 타입 안전성이 잘 보장된 구조입니다!

as const 사용으로 타입 안전성이 보장되며, 계층적 구조가 명확합니다.

Also applies to: 17-17

Copy link
Contributor

@xorms571 xorms571 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!

@ChaeYubin ChaeYubin merged commit 5e9d98a into dev Feb 16, 2025
1 check passed
@ChaeYubin ChaeYubin deleted the DEV-77 branch March 3, 2025 02:55
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.

[DEV-77] Axios, Zustand 초기 세팅
3 participants