-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/mission 09/소리 #64
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
base: 소리/main
Are you sure you want to change the base?
The head ref may contain hidden characters: "feature/mission-09/\uC18C\uB9AC"
Conversation
jeongkyueun
left a comment
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.
JWT를 기존 API에 적용하시고 google 로그인 구현 잘 하신 거 같습니다 수고 많으셨고 한 주만 더 파이팅합시다!!!
KateteDeveloper
left a comment
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.
코드를 미션에 맞춰서 잘 작성해주셨습니다! 너무 수고 많으셨습니다:)
ywkim1m
left a comment
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.
코드, 리드미 깔끔하게 작성하신 것 같습니다! 수고하셨습니다!!
suyeon0421
left a comment
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.
구글 로그인도 잘 구현하시고 isLogin 필요한 부분에 적절히 잘 넣으신 것 같아요 수고하셨습니다!!
hyeeon
left a comment
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.
미션 모두 잘 수행해주신 것 같아요! 수고 많으셨습니다!
Hminkyung
left a comment
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.
9주차 미션까지 고생많으셨습니다!!! 이제 드디어!! 다음주가 배포로 마지막이에요~~ 마지막까지 화이팅입니다!!!!!
| updateUserInfo, | ||
| } from "../repositories/user.repository.js"; | ||
|
|
||
| export const userSignUp = async (data) => { |
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.
여기 안에 있는 DuplicateUserEmailError가 import 되지 않아서 작동하지 않는것으로 보입니다!! error는 import 해주셔야 해요!!
|
|
||
| // 존재하지 않는 유저 미션 | ||
| export class MissionUserNotFoundError extends Error { | ||
| errorCode = "M002"; |
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.
에러에 상태코드 값이 없습니다! swagger에는 상태코드가 존재하고 error.js 에서는 존재하지 않으면 swagger내에 있는 상태코드 값은 불일치로 무시되는 이슈가 발생해요!! 두개 모두 동일하게 Statuscode를 처리해야해요!
ex) statusCode: 404라던가 혹은 401 error등등이 발생할 수 있겠죠!
src/auth.config.js
Outdated
| data: { | ||
| email, | ||
| name: profile.displayName, | ||
| gender: "추후 수정", |
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.
소리가 구현한 prisma 모델에서는 name, gender, birth, address, phoneNumber 가 모두 not null로 정의가 되어있어요! 그래서 여기에서는 추후수정으로 그치면 안되고 API 스펙에 맞춰서 변경이 되어야 합니다!
| }; | ||
| // ID로 user_mission 정보 조회 (방금 추가한 '도전' 확인용) | ||
| // ID로 user_mission 정보 조회 | ||
| export const getUserMissionById = async (userMissionId) => { |
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.
여기에서 userMission에 있는 userId는 undefined가 된 형태입니다! prisma에는 userId가 존재하지만 userId는 fk이고 getUserMissionById에서 사용을 하기 위해서는 select 설정으로 불러와야하기 때문이죠! 그런데 여기에서는 include를 mission과 user만 하고 userId나 missionId 필드는 include하지 않은 상태입니다!
prisma는 include된 필드를 반드시 포함해서 가져오고 relation에서 필요한 fk는 가져오지만 relation 객체 안에만 들어있는 형식으로 동작합니다 따라서 이 경우에는 fk인 userId가 반환되지 않아요!
const userMission = await prisma.userMission.findUnique({
where: { id: userMissionId },
include: {
user: true,
mission: true,
},
select: {
id: true,
status: true,
userId: true,
missionId: true,
user: true,
mission: true,
}
});
이 형식으로 select를 추가하면 정상 동작 진행합니다!
| }; | ||
| // ID로 user_mission 정보 조회 (방금 추가한 '도전' 확인용) | ||
| // ID로 user_mission 정보 조회 | ||
| export const getUserMissionById = async (userMissionId) => { |
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.
그리고 위에 있는 checkUserMissionExists 의 경우 prisma schema에서 모델명을 기준으로 client API를 생성하기 때문에 prisma 모델명으로 작성해야합니다! 따라서
const existingMission = await prisma.userMission.findUnique({
where: {
userId_missionId: {
userId,
missionId,
},
},
});
이런식으로 user_mission 이 아니라 userMission으로 되어야 해요!
| updateUserInfo, | ||
| } from "../repositories/user.repository.js"; | ||
|
|
||
| export const userSignUp = async (data) => { |
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.
지금 userSignUp의 경우는 name, gender, birth, address, detailAddress, phoneNumber, preferences(userFavorCategory와 연결했으니까요!) 가 생성되고 있어요! 반면에 Google로 생성한 유저의 경우는 gender, birth, address, detailAddress, phoneNumber만 있고 preferences 가 없는 상태입니다! 이 경우에는 updateMyInfo를 호출해도 회원가입 API와 동일한 구조가 아니기 때문에 DTO 변환을 적용해도 데이터 불일치가 발생해요!
그래서 방법은 여러가지가 있겠지만 저라면 구글 로그인 시에 preferences를 빈배열로 생성하고 responseFromUser에서 preferences에 기본값인 []으로 처리할 것 같아요!
🚀 작업한 기능 설명 (Feature Description)
🔍 작업 상세 (Implementation Details)
jwt / google 로그인 구현 및 적용
미션, 리뷰 추가, 미션 도전, 유저 정보 수정에 isLogin 미들웨어로 로그인한 사용자만 해당 기능을 이용할 수 있도록 함
유저 정보 수정 기능 추가
구글 로그인 등으로 가입한 유저가 이름, 성별, 생일, 주소, 전화번호를 수정할 수 있게 하는 기능 추가
🖼️ 이미지 첨부 (Images)
📋 관련 자료 (Related Resources)
📝 추가 정보 (Additional Information)