Skip to content

[신민준] Sprint 11#22

Merged
Irelander merged 47 commits intocodeit-sprint-fullstack:express-신민준from
MinJun916:release-v2
Dec 1, 2025
Merged

[신민준] Sprint 11#22
Irelander merged 47 commits intocodeit-sprint-fullstack:express-신민준from
MinJun916:release-v2

Conversation

@MinJun916
Copy link
Collaborator

@MinJun916 MinJun916 commented Nov 27, 2025

요구사항

기본 요구사항

공통

  • Github에 스프린트 미션 PR을 만들어 주세요.
  • React 및 Express를 사용해 진행합니다.
  • TypeScript를 활용해 프로젝트의 필요한 곳에 타입을 명시해 주세요.
  • any 타입의 사용은 최소화해 주세요.
  • 복잡한 객체 구조나 배열 구조를 가진 변수에 인터페이스 또는 타입 별칭을 사용하세요.
  • Union, Intersection, Generics 등 고급 타입을 적극적으로 사용해 주세요.
  • 타입 별칭 또는 유틸리티 타입을 사용해 타입 복잡성을 줄여주세요.
  • 타입스크립트 컴파일러가 에러 없이 정상적으로 작동해야 합니다.

백엔드

  • 기존 Express.js 프로젝트를 타입스크립트 프로젝트로 마이그레이션 해주세요.
  • tsconfig.json 파일을 생성하고, 필요한 컴파일러 옵션을 설정해야 합니다. (예: outDir).
  • TypeScript 관련 명령어를 package.json에 설정해 주세요. (예: 빌드 및 개발 서버 실행 명령어).
  • ts-node와 nodemon을 사용하여 개발 환경을 구성합니다.
  • nodemon과 함께 ts-node를 사용하여 . ts 파일이 변경될 때 서버를 자동으로 재시작하도록 설정합니다.
  • Mongoose나 Prisma 등 ORM을 사용하는 경우, 모델에 대한 인터페이스 또는 타입을 정의합니다.
  • 필요한 경우, declare를 사용하여 타입을 오버라이드하거나 확장합니다.

Comment

  • 기본 JS 기반 Express 코드에서 완전히 새로운 TS 기반 Express 프로젝트를 세팅하고, 리팩토링과 함께 마이그레이션을 진행했습니다.
  • MVC 패턴을 사용하여 폴더 구조를 정리했습니다.

@MinJun916 MinJun916 self-assigned this Nov 27, 2025
@MinJun916 MinJun916 requested a review from Irelander November 27, 2025 05:11
@MinJun916 MinJun916 marked this pull request as ready for review November 28, 2025 09:24
Copy link
Collaborator

@Irelander Irelander left a comment

Choose a reason for hiding this comment

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

Zod를 잘 활용하시는 점이 눈에 띄네요 ㅎㅎ 전반적으로 클린하고 좋은 코드를 작성하시는거 같아요!

큰 이슈들은 아닌데 아래 몇가지 부분들만 수정하면 더 좋을꺼 같습니다 ㅎㅎ

  1. 중복 검증 줄이기: 라우터 미들웨어에서 이미 검증된 데이터를 컨트롤러(getAllArticlesController)에서 다시 파싱하는 경우가 있습니다. 미들웨어를 신뢰하고 중복 연산을 줄여보세요!
  2. 데이터 무결성 및 보안: signupService에서 Refresh Token을 생성만 하고 DB에 저장하지 않는 치명적인 실수가 발견되었습니다. 또, 로그아웃 시 토큰 검증 로직이 빠져 있어 보안 취약점이 될 수 있으니 꼭 보완해주세요.
  3. any 단언 지양: 검증 로직은 완벽한데 마지막에 as any로 타입을 뭉개버리는 부분이 있어 아쉬웠습니다. Express.Request 확장을 통해 타입 안전성을 끝까지 가져가 봅시다!

조금만 다듬으면 정말 완벽한 코드가 될 것 같습니다. 이번 스프린트도 고생하셨습니다.

Comment on lines +14 to +19
const {
cursor,
limit = 10,
searchQuery = '',
sort = 'recent',
} = getArticlesQuerySchema.parse(req.query);
Copy link
Collaborator

Choose a reason for hiding this comment

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

라우터 레벨에서 validateQuery 미들웨어를 이미 통과했으므로,
여기서 다시 schema.parse()를 호출할 필요가 없습니다! (이중 검증)
req.query에 이미 검증되고 변환된 값이 들어있을 거예요.

data = req.body;
}

const result = schema.parse(data) as any;
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기서 as any를 사용하면 Zod가 검증해준 타입 정보를 잃어버리게 돼요.
schema.parse()가 반환하는 타입은 안전하므로, 이를 제대로 활용하려면 Request 타입을 제네릭으로 확장하거나
res.locals 등을 활용해서 안전하게 데이터를 전달하는 방법을 고민해보면 좋을 것 같아요!

Comment on lines +4 to +9
export const getAllProductsRepository = async (
page: number,
limit: number,
whereCondition: ProductWhereInput,
orderBy: ProductOrderByWithRelationInput | ProductOrderByWithRelationInput[],
) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

인자가 많아질 때는 이렇게 개별적으로 받기보다는 하나의 객체로 묶어서 받는 것(Parameter Object Pattern)이 유지보수에 더 유리해요!

interface GetProductsParams { page: number; limit: number; ... } 

처럼 인터페이스를 정의해보는 건 어떨까요?

@Irelander Irelander merged commit 08aa716 into codeit-sprint-fullstack:express-신민준 Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants