-
Notifications
You must be signed in to change notification settings - Fork 4
Refector/zod 스키마 모듈화 #166
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
The head ref may contain hidden characters: "refector/zod\uC2A4\uD0A4\uB9C8-\uBAA8\uB4C8\uD654"
Refector/zod 스키마 모듈화 #166
Changes from all commits
90c01c6
e3e7ad4
584c6cd
46cfc8d
4c71f86
092de44
21c988a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,212 @@ | ||
| This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
|  | ||
|
|
||
| ## Getting Started | ||
| ## **📑 목차** | ||
|
|
||
| First, run the development server: | ||
| > ***[프로젝트 소개](#프로젝트-소개)*** | ||
| > | ||
| > ***[개발 기간](#개발-기간)*** | ||
| > | ||
| > ***[개발자 소개](#개발자-소개)*** | ||
| > | ||
| > ***[상세 계획](#상세-계획)*** | ||
| > | ||
| > ***[User Flow](#User-Flow)*** | ||
| > | ||
| > ***[프로젝트 구조](#프로젝트-구조)*** | ||
| > | ||
| > ***[개발 환경](#개발-환경)*** | ||
| > | ||
| > ***[기술 스택](#기술-스택)*** | ||
| > | ||
| > ***[주요 기능](#주요-기능)*** | ||
| > | ||
| > ***[배포 및 실행 방법](#배포-및-실행-방법)*** | ||
| > | ||
| </br> | ||
|
|
||
| ## 🧑💻 <a name="프로젝트-소개"/>프로젝트 소개 | ||
|
|
||
| 이 프로젝트는 [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) 으로 시작된 [Next.js](https://nextjs.org/) 프로젝트입니다. | ||
|
|
||
| Coworkers는 팀을 구성해서 할 일을 만들고, 공유하고 소통하면서 업무를 효율적으로 할 수 있게 돕는 서비스입니다. | ||
|
|
||
| </br> | ||
|
|
||
| ## 🔗 링크 | ||
|
|
||
| [GitHub](https://github.com/team-collabor/coworkers) | ||
|
|
||
| [🎬 시연 영상](https://www.youtube.com/watch?v=sF21zWhRcss) | ||
|
|
||
| [🌐 배포 사이트](https://coworkers-colla.netlify.app) | ||
|
|
||
| </br> | ||
|
|
||
| ## 👨🏫 <a name="주요-기능"/>주요 기능 | ||
|
|
||
| |||| | ||
| |:---:|:---:|:---:| | ||
| |**랜딩 페이지**|**팀 페이지**|**할 일 페이지**| | ||
|
|
||
| |||| | ||
| |:---:|:---:|:---:| | ||
| |**자유 게시판**|**계정 설정 페이지**|**마이 히스토리 페이지**| | ||
|
|
||
| </br> | ||
|
|
||
| ## 🗓️ <a name="개발-기간"/>개발 기간 | ||
|
|
||
| ***10 / 7 (목) ~ 11 / 14 (목)*** | ||
|
|
||
| </br> | ||
|
|
||
| ## **👨👨👦👦 개발자 소개** | ||
|
|
||
| - **김우성** [@me92years](https://github.com/me92years) : 마이 히스토리 페이지 | ||
| - **이승현** [@leesh7048](https://github.com/leesh7048) : 자유게시판 페이지 | ||
| - **옥승현** [@SeungHyunOK](https://github.com/SeungHyunOK) : 렌딩페이지 및 계정 설정 페이지 | ||
| - **정원식** [@wonsik3686](https://github.com/wonsik3686) : 할 일 페이지 | ||
| - **정인재** [@Injaeeee](https://github.com/Injaeeee?pvs=4,) : 팀 페이지 | ||
|
|
||
| </br> | ||
|
|
||
| ## 📃 <a name="상세-계획"/>상세 계획과 일정 | ||
|
|
||
| [**📌 상세 계획**](https://www.notion.so/wonsik/11309277475d81549fe7ebf0e04dae7d,) | ||
|
|
||
| [**📝 상세 일정**](https://www.notion.so/wonsik/11309277475d810db53ec53c248f89d7,) | ||
|
|
||
| </br> | ||
|
|
||
| ## 💡 <a name="User-Flow"/>User Flow | ||
|
|
||
|  | ||
|
|
||
| </br> | ||
|
|
||
| ## 📁 <a name="프로젝트-구조"/>프로젝트 구조 | ||
|
|
||
| ```bash | ||
| npm run dev | ||
| # or | ||
| yarn dev | ||
| # or | ||
| pnpm dev | ||
| # or | ||
| bun dev | ||
| ``` | ||
| 📁wine/ | ||
| │ | ||
| ├── 📁public/ | ||
| │ ├── 📁images/ # 이미지 파일 폴더 | ||
| │ └── 📁ic_wine.svg ... | ||
| │ | ||
| ├── 📁constants/ | ||
| │ └── 📁auth/ | ||
| │ └── mediaQueryBreakPoint.ts | ||
| │ | ||
| ├── 📁src/ | ||
| │ └── 📁components/ # 재사용 가능한 컴포넌트 | ||
| │ └── 📁common/ # 공통 컴포넌트 | ||
| │ ├── 📁Button/ | ||
| │ │ └── Button.tsx | ||
| │ └── 📁Toast/ | ||
| │ └── Toast.tsx | ||
| │ | ||
| ├── 📁pages/ # Next.js page 라우팅 | ||
| │ │ └── 📁signin/ | ||
| │ │ └── index.tsx | ||
| │ │ └── 📁signup/ | ||
| │ │ └── index.tsx | ||
| │ │ └── 📁[id]/ # 팀 페이지에 들어갈 컴포넌트 모음 | ||
| │ │ │ ├── 📁editteam/ | ||
| │ │ │ │ └── index.tsx | ||
| │ │ └── index.tsx | ||
| │ │ └── index.tsx | ||
| │ │ └── _app.tsx | ||
| │ │ └── _404.tsx | ||
| │ │ | ||
| │ ├── 📁libs/ # 라이브러리 관련된 세팅 및 함수들 정리하는 폴더 | ||
| │ │ └── 📁axios/ # axios 관련 세팅 및 api 요청 함수 | ||
| │ │ └── axiosInstance.ts | ||
| │ │ └── 📁auth/ | ||
| │ │ └── 📁image/ | ||
| │ │ └── 📁review/ | ||
| │ │ └── 📁user/ | ||
| │ │ └── 📁wine/ | ||
| │ │ | ||
| │ ├── 📁contexts/ # 전역 상태 관리 | ||
| │ │ | ||
| │ ├── 📁hooks/ # 커스텀 React 훅 | ||
| │ │ | ||
| │ ├── 📁types/ # 타입 폴더 (DTO 혹은 전역적으로 사용되는 type 미리 정의) | ||
| │ │ # 컴포넌트 props의 경우에는 해당 컴포넌트 위치에 정의 | ||
| │ │ | ||
| │ ├── 📁styles/ # 스타일 관련 파일 모음 | ||
| │ │ └── global.css | ||
| │ │ | ||
| │ │ | ||
| │ └── 📁utils/ # 유틸리티 폴더 | ||
| │ | ||
| ├─ .gitignore | ||
| ├─ .env.local # 각자 환경에서 별도 생성 필요 | ||
| ├─ .eslintrc.json | ||
| ├─ .prettierrc.json | ||
| ├─ next.confing.mjs | ||
| ├─ tailwind.config.ts | ||
| ├─ tsconfig.json | ||
| │ | ||
| ...생략 | ||
| ``` | ||
|
|
||
| </br> | ||
|
|
||
| ## 💻 <a name="개발-환경"/>개발 환경 | ||
|
|
||
| |OS|IDE|Version Control|Package Manager|deploy|Community| | ||
| |:---:|:---:|:---:|:---:|:---:|:---:| | ||
| | | | |||| | ||
|
|
||
| </br> | ||
|
|
||
| ## ⚒ <a name="기술-스택"/>기술 스택 | ||
|
|
||
|  | ||
|  | ||
|  | ||
|  | ||
|  | ||
|
|
||
| </br> | ||
|
|
||
| ## 🚀 <a name="배포-및-실행-방법"/>배포 및 실행 방법 | ||
|
|
||
| **1. 프로젝트 클론** | ||
|
|
||
| `git clone https://github.com/Codeit-FE08-Part3-Team6/wine.git cd wine](https://github.com/team-collabor/coworkers.git` | ||
|
|
||
| **2. 의존성 설치** | ||
|
|
||
| 프로젝트에서 사용하는 패키지들을 설치합니다. | ||
|
|
||
| `npm install` | ||
|
|
||
| **3. 개발 서버 실행** | ||
|
|
||
| Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
| 다음 명령어를 실행하여 로컬 개발 환경에서 프로젝트를 실행할 수 있습니다. | ||
|
|
||
| You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. | ||
| `npm run dev` | ||
|
|
||
| [API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`. | ||
| 이후 브라우저에서 [http://localhost:3000](http://localhost:3000/) 으로 접속하여 개발 중인 웹 애플리케이션을 확인할 수 있습니다. | ||
|
|
||
| The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. | ||
| **4. 빌드 및 배포** | ||
|
|
||
| This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. | ||
| 프로덕션 환경에서 사용하기 위해 빌드할 때는 아래 명령어를 사용합니다. | ||
|
|
||
| ## Learn More | ||
| `npm run build` | ||
|
|
||
| To learn more about Next.js, take a look at the following resources: | ||
| 그 후, 아래 명령어로 빌드된 파일을 실제로 실행합니다. | ||
|
|
||
| - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
| - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
| `npm start` | ||
|
|
||
| You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
| **5. 배포** | ||
|
|
||
| ## Deploy on Vercel | ||
| 이 프로젝트는 netlify을 사용하여 배포할 수 있습니다. | ||
|
|
||
| The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
| GitHub와 연동된 netlify 계정을 통해 자동으로 배포되며, 코드를 push하면 자동으로 배포 프로세스가 진행됩니다. | ||
|
|
||
| Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. | ||
| [**배포 사이트**](https://wine-nine-xi.vercel.app/?pvs=4%5D(https://coworkers-colla.netlify.app/,) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { PostGroupRequest } from '@/types/dto/requests/group.request.types'; | ||
| import { z } from 'zod'; | ||
|
|
||
| export const teamSchema: z.ZodSchema<PostGroupRequest> = z.object({ | ||
| name: z | ||
| .string() | ||
| .min(1, { message: '팀 이름은 필수 입력입니다.' }) | ||
| .max(30, { message: '팀 이름은 30글자 이하로 입력해주세요.' }), | ||
| image: z.string().min(1), | ||
| }); | ||
|
|
||
| export const attendTeamSchema = z.object({ | ||
| link: z.string().min(1, { message: '팀 링크를 입력해주세요.' }), | ||
| }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 코드는 TypesScript와 Zod 라이브러리를 사용하여 그룹 요청을 검증하는 스키마를 정의하고 있습니다. 이 코드 조각은 주로 입력 유효성을 확인하고 있습니다. 그러나 몇 가지 개선 사항이 있습니다:
이러한 개선 사항을 고려하여 코드를 더욱 견고하게 만들 수 있습니다. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import Button, { | |
| } from '@/components/common/Button/Button'; | ||
| import Input from '@/components/common/Input'; | ||
| import ProfileInput from '@/components/Team/ProfileInput'; | ||
| import { teamSchema } from '@/constants/formSchemas/teamSchema'; | ||
| import { useToast } from '@/hooks/useToast'; | ||
| import { usePatchTeamMutation, useTeamQuery } from '@/queries/groups.queries'; | ||
| import { groupsQueryKeys } from '@/queries/keys/groups.key'; | ||
|
|
@@ -24,15 +25,6 @@ import Head from 'next/head'; | |
| import { useRouter } from 'next/router'; | ||
| import { useEffect, useState } from 'react'; | ||
| import { useForm } from 'react-hook-form'; | ||
| import { z } from 'zod'; | ||
|
|
||
| const teamSchema: z.ZodSchema<PostGroupRequest> = z.object({ | ||
| name: z | ||
| .string() | ||
| .min(1, { message: '팀 이름은 필수 입력입니다.' }) | ||
| .max(30, { message: '팀 이름은 30글자 이하로 입력해주세요.' }), | ||
| image: z.string().min(1), | ||
| }); | ||
|
|
||
| export default function EditTeam() { | ||
| const router = useRouter(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 코드 패치에서는 기존의 teamSchema 정의를 상수로 불러오는 방식에서 외부 모듈에서 teamSchema를 가져오도록 변경했습니다. 코드의 구조적인 변경이 없으며 코드베이스의 관리성이 높아지는 장점이 있습니다. 개선 제안:
잠재적 버그 리스크:
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import Button, { | |
| } from '@/components/common/Button/Button'; | ||
| import Input from '@/components/common/Input'; | ||
| import ProfileInput from '@/components/Team/ProfileInput'; | ||
| import { teamSchema } from '@/constants/formSchemas/teamSchema'; | ||
| import { useRedirect } from '@/hooks/useRedirect'; | ||
| import { useTeamMutation } from '@/queries/groups.queries'; | ||
| import { useUploadImageMutation } from '@/queries/uploadImage.query'; | ||
|
|
@@ -18,15 +19,6 @@ import Head from 'next/head'; | |
| import { useRouter } from 'next/router'; | ||
| import { useState } from 'react'; | ||
| import { useForm } from 'react-hook-form'; | ||
| import { z } from 'zod'; | ||
|
|
||
| const teamSchema: z.ZodSchema<PostGroupRequest> = z.object({ | ||
| name: z.string().min(1, { message: '팀 이름은 필수 입력입니다.' }), | ||
| image: z | ||
| .string() | ||
| .min(1) | ||
| .refine((val) => val !== '/icons/BaseTeam_Icon.svg'), | ||
| }); | ||
|
|
||
| export default function AddTeam() { | ||
| const [selectImage, setSelectImage] = useState<File | null>(null); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 코드 패치는 팀 정보를 추가하는 기능을 하는 컴포넌트인데, 기능적으로 문제가 없어 보입니다. 그러나 몇 가지 개선 제안이 있습니다:
전반적으로 코드는 안정적으로 보이지만, 중복 정의된 teamSchema를 개선하여 코드를 더 간결하고 가독성 높게 유지할 수 있습니다. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import Button, { | |
| TextSize, | ||
| } from '@/components/common/Button/Button'; | ||
| import Input from '@/components/common/Input'; | ||
| import { attendTeamSchema } from '@/constants/formSchemas/teamSchema'; | ||
| import { useRedirect } from '@/hooks/useRedirect'; | ||
| import { useToast } from '@/hooks/useToast'; | ||
| import { useInviteGroupMutation } from '@/queries/groups.queries'; | ||
|
|
@@ -18,11 +19,7 @@ import { useRouter } from 'next/router'; | |
| import { useForm } from 'react-hook-form'; | ||
| import { z } from 'zod'; | ||
|
|
||
| const teamSchema = z.object({ | ||
| link: z.string().min(1, { message: '팀 링크를 입력해주세요.' }), | ||
| }); | ||
|
|
||
| type TeamLinkValues = z.infer<typeof teamSchema>; | ||
| type TeamLinkValues = z.infer<typeof attendTeamSchema>; | ||
|
|
||
| export default function AttendTeam() { | ||
| const router = useRouter(); | ||
|
|
@@ -36,7 +33,7 @@ export default function AttendTeam() { | |
| handleSubmit, | ||
| formState: { errors }, | ||
| } = useForm<TeamLinkValues>({ | ||
| resolver: zodResolver(teamSchema), | ||
| resolver: zodResolver(attendTeamSchema), | ||
| defaultValues: { | ||
| link: '', | ||
| }, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 수정 사항:
잠재적인 버그 리스크:
개선 제안:
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 코드 패치는 Next.js를 사용한 프로젝트의 README 파일을 업데이트한 것입니다. 코드 리뷰 및 개선 사항은 다음과 같습니다:
잘못된 이미지 링크
코드 일관성
번역 확인
배포 방법 설명
이러한 부분들을 개선하여 README 파일을 더 명확하고 사용자 친화적으로 만들어보세요.