Conversation
fix: replace birthDate with calculated age in user response DTO
There was a problem hiding this comment.
Pull request overview
카카오 로그인 시 프로필 응답의 gender / birthyear / birthday를 활용해 User의 sex / birthdate / age를 자동 생성·부분 갱신하려는 변경이며, 서버의 쿠키 파싱을 cookie-parser 미들웨어로 전환합니다.
Changes:
- Kakao profile 응답에 성별/생년월일 필드를 파싱해
birthdate(UTC)및age계산,Sex매핑 후 유저 생성/업데이트에 반영 /users/me응답에서birthDate대신age를 내려주도록 DTO/서비스/리포지토리 수정main.ts의 수동 쿠키 파싱 로직 제거 후cookie-parser적용 및 관련 패키지 추가
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/modules/auth/services/kakao-auth.service.ts | 카카오 프로필에서 birth/sex 정보를 파싱해 유저 upsert에 반영, 온보딩 판단 로직 일부 수정 |
| src/modules/user/services/user/user.service.ts | getMe 응답에서 birthDate 대신 age 반환하도록 변경 |
| src/modules/user/repositories/user.repository.ts | findProfileById 조회 필드를 birthdate → age로 변경 |
| src/modules/user/dtos/user-me-response.dto.ts | /users/me 스키마에서 birthDate 제거 및 age 필드 추가 |
| src/main.ts | 수동 쿠키 파싱 제거, cookie-parser 미들웨어로 전환 |
| package.json | cookie-parser 및 타입 패키지 추가(추가로 cookie도 포함) |
| package-lock.json | 의존성/버전 고정 및 cookie(-parser) 관련 락 업데이트 |
Comments suppressed due to low confidence (1)
src/modules/auth/services/kakao-auth.service.ts:340
- PR 설명에 따르면 onboardingRequired 판단 로직은 기존 정책을 유지해야 하는데, 현재
isOnboardingRequired에서 기본birthdate(DEFAULT_BIRTHDATE) 여부 체크가 제거되어 신규 유저가 생년월일 정보를 못 받았을 때도 온보딩이 필요하지 않은 것으로 처리됩니다. 기본값(1900-01-01/age default 등)이 남은 상태로 서비스 흐름을 타게 되므로, 기존처럼 birthdate(또는 age/sex 포함) 기반의 온보딩 필요 조건을 다시 포함시키거나 정책 변경이라면 명시적으로 반영해 주세요.
private isOnboardingRequired(user: {
introText: string;
introVoiceUrl: string;
profileImageUrl: string;
code: string;
}) {
return (
user.introText.trim() === '' ||
user.introVoiceUrl === KakaoAuthService.DEFAULT_INTRO_VOICE_URL ||
user.profileImageUrl === KakaoAuthService.DEFAULT_PROFILE_IMAGE_URL ||
user.code === KakaoAuthService.DEFAULT_ADDRESS_CODE
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -19,8 +19,8 @@ export class UserMeResponseDto { | |||
| @ApiProperty({ example: 'F', enum: Sex }) | |||
| gender: Sex; | |||
|
|
|||
There was a problem hiding this comment.
UserMeResponseDto에서 birthDate를 제거하고 age로 대체하면서 /users/me 응답 스키마가 깨지는 변경이 들어갔습니다. 현재 다른 DTO/로직에서는 여전히 birthDate를 사용하고 있어(예: 프로필 업데이트/온보딩) API 일관성이 깨집니다. 호환성을 위해 birthDate를 유지하고 age를 추가로 제공하거나, 버전업/마이그레이션 계획을 포함해 변경을 조정해 주세요.
| @ApiProperty({ | |
| example: '1970-01-01', | |
| description: '생년월일 (ISO 8601). 향후 age 필드로 대체 예정', | |
| deprecated: true, | |
| }) | |
| birthDate: string; |
| const age = user.age; | ||
| return { | ||
| userId: Number(user.id), | ||
| nickname: user.nickname, | ||
| gender: user.sex, | ||
| birthDate, | ||
| age, | ||
| area: { |
There was a problem hiding this comment.
getMe 응답을 age로 바꾸면, 사용자가 birthDate를 수정하는 기존 플로우(예: updateMe에서 birthdate 업데이트)가 있어도 age가 함께 갱신되지 않아 데이터가 쉽게 불일치할 수 있습니다. birthdate 변경 시 age를 재계산/동기화하거나, age를 저장값이 아닌 계산값으로 제공하는 방식으로 일관성을 보장해 주세요.
| "@prisma/client": "7.2.0", | ||
| "class-transformer": "^0.5.1", | ||
| "class-validator": "^0.14.3", | ||
| "cookie": "^1.1.1", |
There was a problem hiding this comment.
cookie-parser는 src/main.ts에서 사용되지만, cookie 패키지는 현재 코드베이스에서 import/사용되는 곳이 확인되지 않습니다. 불필요한 런타임 의존성은 제거하는 게 좋으니 cookie를 dependency에서 제외해 주세요(직접 파싱 로직은 이미 삭제됨).
| "cookie": "^1.1.1", |
| "@nestjs/testing": "^11.0.1", | ||
| "@types/cookie": "^0.6.0", | ||
| "@types/cookie-parser": "^1.4.10", | ||
| "@types/express": "^5.0.0", |
There was a problem hiding this comment.
@types/cookie가 코드에서 사용되지 않는 것으로 보입니다(현재 cookie 모듈도 미사용). 타입 패키지도 함께 제거해서 의존성/락파일 변경 범위를 줄여 주세요.
| const birthdate = new Date(Date.UTC(year, month - 1, day)); | ||
| if (Number.isNaN(birthdate.getTime())) { | ||
| return {}; | ||
| } |
There was a problem hiding this comment.
buildBirthInfo에서 new Date(Date.UTC(year, month - 1, day))는 잘못된 날짜(예: 02/31)를 자동으로 다음 달로 보정해 유효한 Date를 만들어버리므로, 현재의 NaN 체크로는 invalid birthday를 걸러내지 못합니다. 생성된 birthdate의 UTC year/month/day가 입력값과 정확히 일치하는지 추가 검증(또는 엄격한 파싱)을 넣어 잘못된 생일이 저장/나이 계산에 반영되지 않게 해주세요.
| } | |
| } | |
| // Ensure that the constructed UTC date matches the input components exactly. | |
| // This prevents dates like "0231" (Feb 31) from rolling over into the next month. | |
| if ( | |
| birthdate.getUTCFullYear() !== year || | |
| birthdate.getUTCMonth() + 1 !== month || | |
| birthdate.getUTCDate() !== day | |
| ) { | |
| return {}; | |
| } |
이슈 번호
close #95
주요 변경사항
테스트 결과 (스크린샷)
참고 및 개선사항