-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[feat] 프로필 조회 API
- Loading branch information
Showing
7 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as interviewController } from './interviewController'; | ||
export { default as interviewController } from './interviewController'; | ||
export { default as userController } from './userController'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Request, Response, NextFunction } from 'express'; | ||
import { message, statusCode } from '../module/constant'; | ||
import { success } from '../module/constant/utils'; | ||
import { userService } from '../service'; | ||
|
||
const accessUserInfo = async (req: Request, res: Response, next: NextFunction) => { | ||
const refreshToken = req.body; | ||
|
||
try { | ||
const data = await userService.accessUserInfo(refreshToken); | ||
|
||
return res | ||
.status(statusCode.CREATED) | ||
.send(success(statusCode.CREATED, message.ACCESS_USERINFO_SUCCESS, data)); | ||
} catch (error) { | ||
next(error); | ||
} | ||
}; | ||
|
||
export default { | ||
accessUserInfo | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { Router } from "express"; | ||
import interviewRouter from './interviewRouter'; | ||
import userRouter from "./userRouter"; | ||
|
||
const router: Router = Router(); | ||
|
||
router.use('/interview', interviewRouter); | ||
router.use('/accounts', userRouter); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Router } from 'express'; | ||
import { body, header, param } from 'express-validator'; | ||
import { userController } from '../controller'; | ||
import errorValidator from '../middleware/error/errorValidator'; | ||
|
||
const router: Router = Router(); | ||
|
||
router.get( | ||
'/', | ||
[ | ||
body('refreshToken').notEmpty(), | ||
], | ||
errorValidator, | ||
userController.accessUserInfo, | ||
); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as interviewService } from './interviewService'; | ||
export { default as interviewService } from './interviewService'; | ||
export { default as userService } from './userService'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
import errorGenerator from '../middleware/error/errorGenerator'; | ||
import { message, statusCode } from '../module/constant'; | ||
const prisma = new PrismaClient(); | ||
|
||
const accessUserInfo = async (refreshToken: string) => { | ||
try { | ||
const userInfo = await prisma.user.findfirst({ | ||
where: { | ||
refreshToken: refreshToken, | ||
}, | ||
select: { | ||
id: true, | ||
userName: true, | ||
pictureURL: true, | ||
themeColor: true, | ||
refreshToken: true, | ||
} | ||
}); | ||
return userInfo; | ||
} catch(error) { | ||
throw error; | ||
} | ||
}; | ||
|
||
export default { | ||
accessUserInfo, | ||
}; |