Skip to content

Conversation

six-standard
Copy link
Member

@six-standard six-standard commented Feb 16, 2025

채널톡 버튼을 추가하고, 헤더 로고를 클릭하면 내 통계(메인) 페이지로 이동할 수 있게 수정하였습니다.
(그리고 커밋을 잘못 날려서 중간에 reset 후 dev 대신 main에 날렸습니다.. 해당 부분까지 반영해서 PR 올립니다...)

Summary by CodeRabbit

  • New Features

    • 채널톡 서비스를 통합해 실시간 고객 지원 및 채팅 기능을 강화했습니다.
    • 헤더 상호작용이 개선되어, 클릭 시 메인 페이지로의 전환이 원활해졌습니다.
    • 새로운 ChannelTalkProvider 컴포넌트를 추가하여 채널톡 서비스의 통합을 지원합니다.
    • 새로운 환경 변수 NEXT_PUBLIC_CHANNELTALK_PLUGIN_KEY가 추가되었습니다.
  • Refactor

    • 인증 및 데이터 요청 처리 과정을 단순화해 전반적인 사용자 경험을 향상시켰습니다.
    • 입력 필드 동작과 링크 생성 로직을 정리하여 UI 일관성을 높였습니다.
    • 오류 처리 로직을 개선하여 더 구체적인 오류 메시지를 제공하도록 했습니다.

username 관련 오류 및 SSR 렌더린 관련 오류로 추정되는 오류 수정
Copy link

Copy link

coderabbitai bot commented Feb 16, 2025

"""

Walkthrough

이번 PR은 새로운 의존성 추가와 인증 쿠키 처리 방식, 레이아웃 구성 및 타입 정의 수정 등 여러 코드를 갱신하였습니다.
특히, package.json에 "@channel.io/channel-web-sdk-loader" 패키지가 추가되었고, 인증 API 호출 시 쿠키 처리 방식이 getCookieForAuth에서 직접 cookies().toString()을 사용하는 방식으로 변경되었습니다.
또한, ChannelTalkProvider 컴포넌트가 추가되어 레이아웃 내에서 채널톡 서비스가 초기화되도록 구성되었으며, 일부 컴포넌트의 타입 및 변수 처리 방식이 개선되었습니다.

Changes

파일 변경 내용
package.json "@channel.io/channel-web-sdk-loader": "^2.0.0" 의존성 추가
src/app/(with-tracker)/(auth-required)/layout.tsx, src/app/(with-tracker)/(auth-required)/main/page.tsx 인증 쿠키 처리 방식 수정: 기존 getCookieForAuth 제거, Cookie: cookies().toString() 직접 전달
src/app/layout.tsx ChannelTalkProvider 컴포넌트 추가 및 레이아웃 구조 변경, 관련 import 추가
src/components/auth-required/header/Section.tsx, src/components/auth-required/header/index.tsx children 타입 정의를 React.ReactNode로 단순화; 첫번째 Section의 clickType 변경("none""function") 및 action 추가
src/components/auth-required/main/Section/Graph.tsx useQueryClient 훅 및 관련 maxDate 로직 제거
src/components/auth-required/main/Section/index.tsx username 추출 시 optional chaining 사용 및 URL 변수 분리
src/components/common/ChannelTalkProvider.tsx, src/components/common/index.ts 채널톡 서비스 통합을 위한 ChannelTalkProvider 컴포넌트 신규 추가 및 export
src/apis/dashboard.request.ts postListpostSummary 함수에서 props 매개변수 제거
src/apis/instance.request.ts instance 함수에서 쿠키 헤더 처리 로직 추가
src/apis/user.request.ts me 함수에서 매개변수 제거
src/errors/main.error.ts 새로운 오류 클래스 UserNameNotFound 추가
src/errors/fetch.error.ts 새로운 오류 클래스 EnvNotFoundError 추가

Sequence Diagram(s)

sequenceDiagram
    participant CP as ChannelTalkProvider
    participant E as 환경변수
    participant Loader as ChannelTalk SDK Loader
    participant Service as 채널톡 서비스

    CP->>E: CHANNELTALK_PLUGIN_KEY 확인
    alt 키 존재
      CP->>Loader: 키 전달 및 스크립트 로드 호출
      Loader->>Service: 채널톡 스크립트 로드 및 초기화
      Service-->>CP: 초기화 완료 응답
    else 키 없음
      CP-->>CP: 에러 발생 (환경변수 누락)
    end
Loading
sequenceDiagram
    participant P as Page Function
    participant C as cookies() 함수
    participant API as API Endpoint

    P->>C: cookies().toString() 호출
    C-->>P: 쿠키 문자열 반환
    P->>API: { headers: { Cookie: "쿠키 문자열" } } 전달
    API-->>P: 응답 반환
Loading

Suggested labels

bug

Suggested reviewers

  • HA0N1
  • BDlhj

Poem

나는 토끼, 코드를 쫓아 뛰노네,
새로운 패키지, 당근처럼 반짝이네.
쿠키는 부드럽게 한 줄로 쌓이고,
ChannelTalk과 함께 길을 밝혀줘.
코드 숲 속, 오류는 멀리 보내고,
함께 달리는 우리, 즐거움 가득하네!
"""

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.

@six-standard six-standard requested a review from Nuung February 16, 2025 08:21
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: 4

🔭 Outside diff range comments (1)
src/components/auth-required/main/Section/Graph.tsx (1)

80-98: 🛠️ Refactor suggestion

날짜 제한 제거에 대한 검토 필요

최대 날짜 제한이 제거되었습니다. 이로 인해 사용자가 미래 날짜를 선택할 수 있게 되어 잘못된 데이터를 조회할 수 있습니다.

현재 날짜를 최대값으로 설정하는 것을 제안합니다:

<Input
  size={isMBI ? 'SMALL' : 'MEDIUM'}
  form="SMALL"
  value={type.end}
  min={type.start ? type.start : releasedAt.split('T')[0]}
+ max={new Date().toISOString().split('T')[0]}
  onChange={(e) => setType({ ...type, end: e.target.value })}
  placeholder="종료 날짜"
  type="date"
/>
🧹 Nitpick comments (4)
src/components/common/ChannelTalkProvider.tsx (1)

22-22: 컴포넌트 언마운트 시 정리(cleanup) 로직 추가 필요

Channel Talk 서비스의 적절한 정리를 위해 cleanup 함수를 추가하는 것이 좋습니다.

-  useEffect(() => ChannelTalkServiceLoader(), []);
+  useEffect(() => {
+    ChannelTalkServiceLoader();
+    return () => {
+      ChannelService.shutdown();
+    };
+  }, []);
src/app/(with-tracker)/(auth-required)/layout.tsx (1)

19-19: 타입 안전성 개선 제안

쿠키 헤더 처리에 대한 타입 안전성을 개선할 수 있습니다.

-      await me({ headers: { Cookie: cookies().toString() } }),
+      await me({ 
+        headers: { 
+          Cookie: cookies().toString() 
+        } satisfies Record<string, string>
+      }),
src/app/layout.tsx (1)

26-29: 성능 최적화 제안

ToastContainer는 ChannelTalkProvider 외부에 위치할 수 있습니다. 이렇게 하면 불필요한 리렌더링을 방지할 수 있습니다.

           <QueryProvider>
+            <ToastContainer autoClose={2000} />
             <ChannelTalkProvider>
-              <ToastContainer autoClose={2000} />
               {children}
             </ChannelTalkProvider>
src/components/auth-required/main/Section/index.tsx (1)

16-17: URL 생성 로직 개선 제안

URL 생성 로직을 별도 변수로 분리한 것은 좋은 개선이지만, 재사용성을 위해 유틸리티 함수로 추출하는 것을 고려해보세요.

다음과 같은 유틸리티 함수 생성을 제안합니다:

// utils/urlUtil.ts
export const createVelogPostUrl = (username: string | undefined, slug: string) => 
  `${process.env.NEXT_PUBLIC_VELOG_URL}/@${username || ''}/${slug}`;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6fc9c58 and 8e8cea9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • package.json (1 hunks)
  • src/app/(with-tracker)/(auth-required)/layout.tsx (1 hunks)
  • src/app/(with-tracker)/(auth-required)/main/page.tsx (2 hunks)
  • src/app/layout.tsx (2 hunks)
  • src/components/auth-required/header/Section.tsx (1 hunks)
  • src/components/auth-required/header/index.tsx (1 hunks)
  • src/components/auth-required/main/Section/Graph.tsx (1 hunks)
  • src/components/auth-required/main/Section/index.tsx (2 hunks)
  • src/components/common/ChannelTalkProvider.tsx (1 hunks)
  • src/components/common/index.ts (1 hunks)
🔇 Additional comments (4)
src/components/common/index.ts (1)

1-1: 코드가 깔끔하고 일관성이 있습니다!

새로운 ChannelTalkProvider 컴포넌트의 export가 기존 패턴을 잘 따르고 있습니다.

src/components/auth-required/header/Section.tsx (1)

27-27: 타입 정의 개선 승인

children 타입을 React.ReactNode로 단순화한 것은 좋은 변경사항입니다. 실제 사용 패턴에 더 잘 부합하며 타입 안정성을 향상시킵니다.

Also applies to: 33-33

src/components/auth-required/header/index.tsx (1)

65-68: 로고 클릭 시 메인 통계 페이지로 이동하는 기능이 잘 구현되었습니다!

PR 목표에 맞게 헤더 로고를 클릭하면 사용자의 메인 통계 페이지로 이동하도록 구현되었습니다.

package.json (1)

16-16:

✅ Verification successful

Channel Talk SDK 버전을 확인해주세요.

현재 설치된 버전이 최신 안정 버전인지 확인이 필요합니다.


🌐 Web query:

What is the latest stable version of @channel.io/channel-web-sdk-loader?

💡 Result:

The latest stable version of @channel.io/channel-web-sdk-loader is v2.0.0, released approximately 4-5 months ago (around October 2024)[4][10]. This version introduced breaking changes including:

  • Removal of deprecated openSupportBot interface
  • Addition of new openWorkflow method
  • Updates to the setPage interface[10]

Key indicators confirming this as the latest stable release:

  1. Official npm registry lists v2.0.0 as "latest"[4][8]
  2. GitHub releases show v2.0.0 as most recent with full changelog[10]
  3. No newer versions appear in package manager listings or release notes[9]

For implementation details:

// Installation via npm/yarn/pnpm
npm install @channel.io/channel-web-sdk-loader@2.0.0

// Usage pattern remains consistent with previous versions
import * as ChannelService from '@channel.io/channel-web-sdk-loader';
ChannelService.loadScript();
ChannelService.boot({ pluginKey: 'YOUR_PLUGIN_KEY' })[1][7]

Citations:


최신 안정 버전 적용 확인됨

현재 package.json에 설정된 "@channel.io/channel-web-sdk-loader": "^2.0.0" 버전은 최신 안정 버전인 2.0.0과 일치합니다. 추가 업데이트나 수정 사항은 없습니다.

Copy link
Member

@Nuung Nuung left a comment

Choose a reason for hiding this comment

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

좋았던 점

  1. import 가지치기와 전체적으로 type 강화된 조건들이 깔끔하고 좋았어요!
  2. 환경변수 미리 업데이트 주셔서 감사요! 근데 sample 에도 추가해주세요!!

아쉬운 점

(SLACK 에서 공유드린 것들 정리차)

  1. headers: { Cookie: cookies().toString() } 반복
  2. @${username || ''} 이 절대 빈 값을 수 없는데, URL 을 억지로라도 만드는게 맞는지?

@Nuung Nuung added the enhancement New feature or request label Feb 16, 2025
@six-standard six-standard requested a review from Nuung February 16, 2025 09:12
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 (3)
.env.sample (1)

7-7: 새 환경 변수 추가 확인
새 환경 변수 NEXT_PUBLIC_CHANNELTALK_PLUGIN_KEY가 채널톡 초기화를 위한 키 정보를 제공하는 용도로 올바르게 추가되었습니다. 실제 배포 시 유효한 키로 대체되어야 하며, 가독성을 위해 주석으로 해당 변수의 용도와 사용 방법을 간단히 기재하는 것도 고려해보면 좋겠습니다.

src/errors/main.error.ts (1)

3-7: 에러 메시지를 더 자세하게 작성하면 좋을 것 같습니다.

현재 에러 메시지가 단순히 'username not found'로 되어있는데, 사용자나 개발자가 더 쉽게 이해할 수 있도록 상세한 메시지를 추가하면 좋을 것 같습니다.

다음과 같이 수정하는 것을 제안드립니다:

-    super('username not found', 'UserNameNotFound');
+    super('사용자 이름을 찾을 수 없습니다. 로그인이 필요하거나 계정이 존재하지 않을 수 있습니다.', 'UserNameNotFound');
src/apis/dashboard.request.ts (1)

10-15: URL 생성 로직을 개선하면 좋을 것 같습니다.

URL 파라미터 구성 시 타입 안정성과 유지보수성을 높일 수 있는 방법이 있습니다.

다음과 같은 개선사항을 제안드립니다:

+const createPostListUrl = (baseUrl: string, params: { sort: SortType; cursor?: string }) => {
+  const searchParams = new URLSearchParams();
+  if (params.cursor) searchParams.set('cursor', params.cursor);
+  searchParams.set('asc', params.sort.asc.toString());
+  searchParams.set('sort', params.sort.sort);
+  return `${baseUrl}?${searchParams.toString()}`;
+};

 export const postList = async (sort: SortType, cursor?: string) =>
   await instance<null, PostListDto>(
-    cursor
-      ? `${PATHS.POSTS}?cursor=${cursor}&asc=${sort.asc}&sort=${sort.sort}`
-      : `${PATHS.POSTS}?asc=${sort.asc}&sort=${sort.sort}`,
+    createPostListUrl(PATHS.POSTS, { sort, cursor })
   );

이렇게 수정하면 다음과 같은 장점이 있습니다:

  1. URL 파라미터 생성 로직이 분리되어 관리가 용이
  2. URLSearchParams를 사용하여 안전한 URL 인코딩
  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 372c957 and af8fad6.

📒 Files selected for processing (11)
  • .env.sample (1 hunks)
  • src/apis/dashboard.request.ts (1 hunks)
  • src/apis/instance.request.ts (1 hunks)
  • src/apis/user.request.ts (2 hunks)
  • src/app/(with-tracker)/(auth-required)/layout.tsx (1 hunks)
  • src/app/(with-tracker)/(auth-required)/main/Content.tsx (1 hunks)
  • src/app/(with-tracker)/(auth-required)/main/page.tsx (1 hunks)
  • src/components/auth-required/header/index.tsx (2 hunks)
  • src/components/auth-required/main/Section/index.tsx (2 hunks)
  • src/errors/index.ts (1 hunks)
  • src/errors/main.error.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/app/(with-tracker)/(auth-required)/layout.tsx
  • src/components/auth-required/header/index.tsx
🧰 Additional context used
🧠 Learnings (1)
src/app/(with-tracker)/(auth-required)/main/page.tsx (1)
Learnt from: six-standard
PR: Check-Data-Out/velog-dashboard-v2-fe#13
File: src/app/(with-tracker)/(auth-required)/main/page.tsx:28-28
Timestamp: 2025-02-16T08:28:38.561Z
Learning: In Next.js server components, using `cookies().toString()` is the proper way to handle cookie transmission on the server side, as it's internal to the server and designed for server component usage.
🔇 Additional comments (8)
src/errors/index.ts (1)

1-2: 에러 모듈 구조가 잘 구성되어 있습니다!

에러 타입들을 중앙에서 관리하고 재사용할 수 있도록 구성된 점이 좋습니다.

src/apis/user.request.ts (1)

18-18:

❓ Verification inconclusive

인증 처리 방식 변경에 대한 검증이 필요합니다.

me 함수에서 인증 관련 파라미터가 제거되었습니다. 이 변경으로 인해 인증이 올바르게 처리되는지 확인이 필요합니다.

다음 사항들을 확인해주세요:

  1. 인증이 필요한 API 호출 시 쿠키가 올바르게 전달되는지
  2. 인증되지 않은 사용자의 요청이 적절히 처리되는지
  3. 세션 만료 시 적절한 에러 처리가 이루어지는지

🏁 Script executed:

#!/bin/bash
# Description: Check for authentication handling in the codebase

# Search for cookie handling in instance.request.ts
echo "Checking instance.request.ts for cookie handling:"
rg -A 5 "cookie" "src/**/instance.request.ts"

# Search for authentication error handling
echo "Checking for authentication error handling:"
rg -A 5 "401|unauthorized|unauthenticated" "src/**/*.ts"

Length of output: 429


[검증 필요] 인증 처리 관련 상세 확인

현재 제공된 쉘 스크립트 결과에서 instance.request.ts 파일 및 인증 에러 처리 관련 검색 결과가 나오지 않아, 현재 코드 베이스 내에서 인증 쿠키 전달이나 예외 처리 로직의 위치를 확정하지 못했습니다.
따라서 아래 사항들을 추가로 수동 혹은 별도의 스크립트로 확인해 주시기 바랍니다:

  • 인증 관련 모듈 확인:

    • me 함수가 사용하는 instance가 정의된 파일(또는 모듈)에서 쿠키 전달 및 인증 로직이 구현되어 있는지 확인
    • 인증 실패(401, unauthorized 등) 시의 에러 핸들링 로직이 존재하는지 검토
  • 기능 테스트:

    • 인증이 필요한 API 호출 시 실제로 쿠키가 올바르게 전달되어 요청이 성공하는지
    • 인증되지 않은 사용자의 요청에 대해 적절한 에러 메시지/응답이 반환되는지 테스트

해당 사항들이 예상대로 작동하는지 수동으로 확인해 주시고, 필요시 추가 스크립트를 사용하여 상세 검증을 진행해 주세요.

src/apis/dashboard.request.ts (1)

17-18: LGTM! postSummary 함수가 잘 정리되었습니다.

인증 처리 로직이 제거되어 함수가 더 간단해졌습니다.

src/app/(with-tracker)/(auth-required)/main/page.tsx (1)

26-29: API 호출 단순화가 잘 이루어졌습니다!

서버 컴포넌트에서 쿠키 처리를 단순화한 변경이 적절합니다.

src/apis/instance.request.ts (2)

63-66: 서버/클라이언트 환경 분기 처리가 잘 구현되었습니다!

window 객체를 통한 환경 감지와 동적 임포트를 활용한 구현이 깔끔합니다.


71-76: 쿠키 헤더 조건부 추가가 적절합니다!

서버 환경에서만 쿠키 헤더를 추가하는 로직이 잘 구현되었습니다.

src/components/auth-required/main/Section/index.tsx (1)

18-20: 사용자 이름 유효성 검사 추가가 적절합니다!

UserNameNotFound 에러를 통한 명확한 에러 처리가 구현되었습니다.

src/app/(with-tracker)/(auth-required)/main/Content.tsx (1)

43-43: 쿼리 함수 호출 단순화가 잘 이루어졌습니다!

불필요한 async 래퍼를 제거하여 코드가 더 명확해졌습니다.

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/errors/main.error.ts (1)

4-7: 에러 메시지를 더 자세하게 작성하면 좋을 것 같습니다.

현재 에러 메시지가 간단한 영문으로만 되어 있습니다. 사용자 경험 향상을 위해 다음과 같은 개선을 제안드립니다:

-    super('username not found', 'UserNameNotFound');
+    super('사용자 이름을 찾을 수 없습니다', 'UserNameNotFound');

또는 영문과 한글을 모두 포함하는 방식도 고려해 보세요:

-    super('username not found', 'UserNameNotFound');
+    super('사용자 이름을 찾을 수 없습니다 (username not found)', 'UserNameNotFound');
src/errors/fetch.error.ts (1)

21-29: 환경 변수 검증 시점에 대한 제안

애플리케이션 시작 시점에 모든 필수 환경 변수를 한 번에 검증하는 것을 고려해보세요. 이는 런타임 중에 발생할 수 있는 환경 변수 관련 오류를 미리 방지할 수 있습니다.

예시 구현을 위한 새로운 유틸리티 함수를 제안드립니다:

// src/utils/env-validator.ts
export function validateRequiredEnvVars(requiredVars: string[]): void {
  const missingVars = requiredVars.filter(varName => !process.env[varName]);
  if (missingVars.length > 0) {
    throw new EnvNotFoundError(missingVars.join(", "));
  }
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between af8fad6 and d920968.

📒 Files selected for processing (4)
  • src/apis/instance.request.ts (2 hunks)
  • src/components/auth-required/main/Section/index.tsx (2 hunks)
  • src/errors/fetch.error.ts (1 hunks)
  • src/errors/main.error.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/auth-required/main/Section/index.tsx
  • src/apis/instance.request.ts
🔇 Additional comments (1)
src/errors/main.error.ts (1)

1-3: 구현이 잘 되어있습니다!

CustomError를 확장한 사용자 정의 에러 클래스의 구현이 명확하고 깔끔합니다. 클래스 이름이 용도를 잘 설명하고 있습니다.

Comment on lines +21 to +29
export class EnvNotFoundError extends CustomError {
constructor(message: string) {
super(
`${message}이(가) ENV에서 설정되지 않았습니다`,
'EnvNotFoundError',
0,
);
}
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

상태 코드와 에러 메시지 형식을 개선하세요.

상태 코드 0은 표준적이지 않으며, 일반적으로 환경 변수 관련 오류는 구성 오류로 간주됩니다.

다음과 같이 개선하는 것을 제안합니다:

 export class EnvNotFoundError extends CustomError {
   constructor(message: string) {
     super(
-      `${message}이(가) ENV에서 설정되지 않았습니다`,
+      `필수 환경 변수 '${message}'이(가) 설정되지 않았습니다.`,
       'EnvNotFoundError',
-      0,
+      500,
     );
   }
 }

변경사항:

  1. 상태 코드를 서버 구성 오류를 나타내는 500으로 변경
  2. 에러 메시지를 더 명확하고 구체적으로 개선
  3. 환경 변수 이름을 따옴표로 감싸서 가독성 향상
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export class EnvNotFoundError extends CustomError {
constructor(message: string) {
super(
`${message}이(가) ENV에서 설정되지 않았습니다`,
'EnvNotFoundError',
0,
);
}
}
export class EnvNotFoundError extends CustomError {
constructor(message: string) {
super(
`필수 환경 변수 '${message}'이(가) 설정되지 않았습니다.`,
'EnvNotFoundError',
500,
);
}
}

@six-standard six-standard merged commit ecb2d5a into main Feb 16, 2025
1 check passed
six-standard added a commit that referenced this pull request Feb 25, 2025
* [25.02.16 / TASK-118] Feature: 채널톡 추가 및 헤더 로고 클릭 동작 추가 (#13)

* hotfix: 일부 오류 수정
username 관련 오류 및 SSR 렌더린 관련 오류로 추정되는 오류 수정

* feat: 채널톡 추가 및 헤더 로고 동작 추가

* refactor: console.log 제거

* refactor: 메세지 내용 변경

* refactor: 코멘트 반영 겸 자잘한 오류 해결

* refactor: username 관련 코드 수정

* refactor: ENV 오류 전용 공통 오류 객체 추가

* hotfix: env 값 추가

* hotfix: env 관련 오류 해결

* hotfix: 구조분해 관련 오류 해결

* fix: useSearchParam > 제네릭 사용하여 타입 추론 정확히 하도록 수정

---------

Co-authored-by: 육기준 <dbrrl1127@gmail.com>
six-standard added a commit that referenced this pull request Feb 25, 2025
* [25.02.16 / TASK-118] Feature: 채널톡 추가 및 헤더 로고 클릭 동작 추가 (#13)

* hotfix: 일부 오류 수정
username 관련 오류 및 SSR 렌더린 관련 오류로 추정되는 오류 수정

* feat: 채널톡 추가 및 헤더 로고 동작 추가

* refactor: console.log 제거

* refactor: 메세지 내용 변경

* refactor: 코멘트 반영 겸 자잘한 오류 해결

* refactor: username 관련 코드 수정

* refactor: ENV 오류 전용 공통 오류 객체 추가

* hotfix: env 값 추가

* hotfix: env 관련 오류 해결

* hotfix: 구조분해 관련 오류 해결

* hotfix: 겹친 코드 제거
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants