Skip to content
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

[BE] 2.04 oAuth를 활용한 로그인 API 구현 #7 #43

Merged
merged 11 commits into from
Nov 11, 2024

Conversation

jinddings
Copy link
Collaborator

✅ 주요 작업

💭 고민과 해결과정

express 모듈의 Request 타입 재정의

express Request에는 user 필드가 없기 때문에 req.user 로 접근이 불가능 하였다.
nestjs에서 여러 모듈의 타입들을 상속받아 재정의 할 수 있다는 것을 알게 되어 적용해보았다.

// src/types/express.d.ts
import { Request as Req } from 'express';
import { UUID } from 'crypto';

declare module 'express' {
  interface Request extends Req {
    user: {
      kakaoId?: number;
      userId?: UUID;
    };
  }
}

해당 파일을 생성 후에

tsconfig.json 의 compilerOptions 에 "typeRoots": ["./node_modules/@types", "./src/types"] 추가하여 type 을 재정의 할 수 있었다.

@jinddings jinddings linked an issue Nov 7, 2024 that may be closed by this pull request
@jinddings jinddings requested review from uuuo3o and sieunie and removed request for uuuo3o November 7, 2024 10:30
Copy link
Collaborator

@sieunie sieunie left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다~
라고하려햇는데 린트 오류나네요...

Comment on lines +20 to +23
constructor(
private authService: AuthService,
private configService: ConfigService,
) {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

🟢 요런 아이들 private readonly로 통일하는게 좋지 않을까용??

const currentRefreshToken = await bcrypt.hash(refreshToken, salt);
const currentRefreshTokenExpiresAt = new Date(
currentDate.getTime() +
parseInt(this.configService.get<string>('JWT_REFRESH_EXPIRATION_TIME')),
Copy link
Collaborator

Choose a reason for hiding this comment

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

🟢 헉 진명님도 process.env 안되셔서 이렇게 하신건가요??

@@ -23,7 +22,7 @@ import { KoreaInvestmentModule } from './koreaInvestment/korea.investment.module
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWD,
database: process.env.DB_DATABASE,
entities: [User],
entities: [__dirname + '/../**/*.entity.{js,ts}'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

🟢 이렇게 추가하면 일일이 추가하지 않아도 되겠네요! 좋습니다.

entities: [__dirname + '/../**/*.entity.{js,ts}'],
synchronize: true,
}),
TypeOrmModule.forRoot(typeOrmConfig),
Copy link
Collaborator

Choose a reason for hiding this comment

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

🟢 코드를 정리하니 보기 좋네요~

@uuuo3o
Copy link
Collaborator

uuuo3o commented Nov 7, 2024

이거 근데 저만 풀리퀘스트 이름 잘못 보이나요? 바로 밑에 시은님 풀리퀘 이름이랑 똑같이 보이네요

@jinddings jinddings changed the title [BE] 3.03 주식 차트 정보 기능 테스트 [BE] 2.04 oAuth를 활용한 로그인 API 구현 #7 Nov 7, 2024
@uuuo3o uuuo3o added BE 백엔드 API API 구현 labels Nov 8, 2024
@jinddings jinddings merged commit 3e0df74 into back/main Nov 11, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API API 구현 BE 백엔드
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BE] 2.04 oAuth를 활용한 로그인 API 구현
3 participants