Skip to content

[week09] 도얏 9주차 미션#38

Open
higashiaka wants to merge 10 commits into
mainfrom
week9_doeyat
Open

[week09] 도얏 9주차 미션#38
higashiaka wants to merge 10 commits into
mainfrom
week9_doeyat

Conversation

@higashiaka
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

@si-zero si-zero 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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Prisma 스키마에서 ID 필드들이 BigInt로 설계되어 있습니다. 자바스크립트/타입스크립트 환경에서 BigInt를 다룰 때는 주의가 필요합니다.

일부 컨트롤러나 서비스 레이어에서 URL 파라미터를 받을 때 Number(memberId)와 같이 일반 숫자로 캐스팅하여 넘겨주는 부분이 존재합니다. 자바스크립트의 Number는 큰 대형 정수를 정확히 표현하지 못해 값이 왜곡될 수 있습니다

데이터베이스와 통신하는 모든 ID 값은 컨트롤러 진입 단계(DTO 혹은 라우터)에서부터 안정적으로 BigInt(memberId)를 사용하도록 통일하고, 문자열로 안전하게 변환하여 응답하도록 아키텍처 규칙을 일관되게 정립하는 것이 좋습니다.

Comment on lines +15 to +32
export const signUp = async (data: MemberSignUpRequest) => {
// TSOA required 검증 이후에도 빈 문자열 입력은 서비스에서 한 번 더 방어합니다.
if (!data.name) {
throw new BaseError(ErrorCode.MEMBER_REQUIRED_FIELD)
}

const hashedPassword = data.password ? await bcrypt.hash(data.password, 10) : null

const memberData = bodyToMember(data)
const memberId = await addUser({ ...memberData, ...(hashedPassword ? { password: hashedPassword } : {}) })

if (memberId === null) {
throw new BaseError(ErrorCode.DUPLICATE_EMAIL)
}

const member = await getUser(memberId)
return responseFromMember(member)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

회원가입 시 프로필을 동시에 생성하거나, 미션 도전을 시작할 때 관련된 로그를 남기는 등 동시에 2개 이상의 테이블에 값을 추가/수정하는 비즈니스 로직들이 존재합니다.

트랜잭션을 이용하여 롤백되도록 안전장치를 마련하는게 좋아보입니다.

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.

2 participants