Skip to content

[9주차/찬찬] 워크북 제출합니다#18

Open
inhadissolve wants to merge 5 commits into
UMC-Inha:chanchan/mainfrom
inhadissolve:feature/chapter-09
Open

[9주차/찬찬] 워크북 제출합니다#18
inhadissolve wants to merge 5 commits into
UMC-Inha:chanchan/mainfrom
inhadissolve:feature/chapter-09

Conversation

@inhadissolve
Copy link
Copy Markdown

✅ 실습 체크리스트

  • 이론 학습을 완료하셨나요?
  • 미션 요구사항을 모두 이해하셨나요?
  • 실습을 수행하기 위한 공부를 완료하셨나요?
  • 실습 요구사항을 모두 완료하셨나요?

✅ 컨벤션 체크리스트

  • 디렉토리 구조 컨벤션을 잘 지켰나요?
  • pr 제목을 컨벤션에 맞게 작성하였나요?
  • pr에 해당되는 이슈를 연결하였나요?(중요)
  • 적절한 라벨을 설정하였나요?
  • 파트장에게 code review를 요청하기 위해 reviewer를 등록하였나요?
  • 닉네임/main 브랜치의 최신 상태를 반영하고 있는지 확인했나요?(매우 중요!)

@inhadissolve inhadissolve self-assigned this May 27, 2026
@inhadissolve inhadissolve added the documentation Improvements or additions to documentation label May 27, 2026
Comment thread src/auth.config.ts
Comment on lines +92 to +93
clientID: process.env.PASSPORT_GOOGLE_CLIENT_ID!,
clientSecret: process.env.PASSPORT_GOOGLE_CLIENT_SECRET!,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

환경변수는 ! 으로 단정하기 보다 외부에 추가로 변수를 선언한뒤 만약 선언이 안되었다면 error를 생성하는 식으로 구현하는게 좋습니다

const id = process.env.ID;
if(!id)
   throw new Error("환경변수 ID가 선언되지 않았습니다

Comment thread src/auth.config.ts
{
clientID: process.env.PASSPORT_GOOGLE_CLIENT_ID!,
clientSecret: process.env.PASSPORT_GOOGLE_CLIENT_SECRET!,
callbackURL: "http://localhost:3000/oauth2/callback/google",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

callbackURL도 환경마다 바뀔수 있으니 baseURL을 환경변수로 빼주시면 좋습니다!

Comment thread src/auth.config.ts
Comment on lines +64 to +72
user = await prisma.user.create({
data: {
email,
name: profile.displayName,
gender: "추후 수정",
birth: new Date(1970, 0, 1),
address: "추후 수정",
detailAddress: "추후 수정",
phoneNumber: "추후 수정",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

우리가 이미 user.repository에서 prisma.user를 접근하는 로직을 만들었으니 여기서도 해당 class를 import 해서 사용하는게 좋을거 같습니다. 단순한 로직은 여러곳에서 prisma 인스턴스를 사용하는게 문제가 없을 수 있는데 추후에 DI, 의존성 문제가 발생할 수도 있으니 확인해보세요!

Comment thread src/index.ts
* Authorization: Bearer <accessToken>
* 형식으로 토큰을 보내야 통과할 수 있습니다.
*/
const isLogin = passport.authenticate("jwt", { session: false });
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

미들웨어를 선언하신건 좋지만 해당 함수도 middleware 파일로 분리하면 좋을거 같네요

또한 passport.authenticate 자체가 인증 실패시 401을 발생하지만 응답을 json으로 통일하려면 커스텀 콜백이 필요합니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants