Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feature: user model 업데이트 됨에 따라 type 들 업데이트, 특히 me api 리뉴얼
  • Loading branch information
Nuung committed Jun 7, 2025
commit 1cb8b68dd65d9d7cc48344c2b874a7c709e57898
13 changes: 7 additions & 6 deletions src/controllers/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ export class UserController {

if (isProd) {
baseOptions.sameSite = 'lax';
baseOptions.domain = "velog-dashboard.kro.kr";
baseOptions.domain = 'velog-dashboard.kro.kr';
baseOptions.maxAge = THREE_WEEKS_IN_MS; // 3주

} else {
baseOptions.domain = 'localhost';
}
Expand Down Expand Up @@ -108,14 +107,16 @@ export class UserController {
};

fetchCurrentUser: RequestHandler = async (req: Request, res: Response<LoginResponseDto>) => {
// 외부 API (velog) 호출로 username 을 가져와야 함, 게시글 바로가기 때문에 (username)
const { accessToken, refreshToken } = req.tokens;
const velogUser = await fetchVelogApi(accessToken, refreshToken);
const currnetUser = req.user;

// 인가 middle 에서 만든 객체 그대로 재활용
const username = currnetUser.username || '';
const profile = { thumbnail: currnetUser.thumbnail || '' };

const response = new LoginResponseDto(
true,
'유저 정보 조회에 성공하였습니다.',
{ id: req.user.id, username: velogUser.username, profile: velogUser.profile },
{ id: currnetUser.id, username: username, profile: profile },
null,
);

Expand Down
2 changes: 1 addition & 1 deletion src/routes/user.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ router.post('/logout', authMiddleware.verify, userController.logout);
* get:
* tags:
* - User
* summary: 사용자 정보 조회
* summary: 사용자 정보 조회, auth 미들웨어 객체 그대로 사용
* responses:
* '200':
* description: 성공
Expand Down
3 changes: 3 additions & 0 deletions src/types/models/User.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export interface User {
is_active: boolean;
created_at: Date;
updated_at: Date;
// 250607 추가
username: string | null;
thumbnail: string | null;
}


Expand Down