Skip to content

Commit 1cb8b68

Browse files
committed
feature: user model 업데이트 됨에 따라 type 들 업데이트, 특히 me api 리뉴얼
1 parent 4fff733 commit 1cb8b68

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/controllers/user.controller.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ export class UserController {
2424

2525
if (isProd) {
2626
baseOptions.sameSite = 'lax';
27-
baseOptions.domain = "velog-dashboard.kro.kr";
27+
baseOptions.domain = 'velog-dashboard.kro.kr';
2828
baseOptions.maxAge = THREE_WEEKS_IN_MS; // 3주
29-
3029
} else {
3130
baseOptions.domain = 'localhost';
3231
}
@@ -108,14 +107,16 @@ export class UserController {
108107
};
109108

110109
fetchCurrentUser: RequestHandler = async (req: Request, res: Response<LoginResponseDto>) => {
111-
// 외부 API (velog) 호출로 username 을 가져와야 함, 게시글 바로가기 때문에 (username)
112-
const { accessToken, refreshToken } = req.tokens;
113-
const velogUser = await fetchVelogApi(accessToken, refreshToken);
110+
const currnetUser = req.user;
111+
112+
// 인가 middle 에서 만든 객체 그대로 재활용
113+
const username = currnetUser.username || '';
114+
const profile = { thumbnail: currnetUser.thumbnail || '' };
114115

115116
const response = new LoginResponseDto(
116117
true,
117118
'유저 정보 조회에 성공하였습니다.',
118-
{ id: req.user.id, username: velogUser.username, profile: velogUser.profile },
119+
{ id: currnetUser.id, username: username, profile: profile },
119120
null,
120121
);
121122

src/routes/user.router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ router.post('/logout', authMiddleware.verify, userController.logout);
103103
* get:
104104
* tags:
105105
* - User
106-
* summary: 사용자 정보 조회
106+
* summary: 사용자 정보 조회, auth 미들웨어 객체 그대로 사용
107107
* responses:
108108
* '200':
109109
* description: 성공

src/types/models/User.type.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export interface User {
88
is_active: boolean;
99
created_at: Date;
1010
updated_at: Date;
11+
// 250607 추가
12+
username: string | null;
13+
thumbnail: string | null;
1114
}
1215

1316

0 commit comments

Comments
 (0)