diff --git a/src/controller/authController.js b/src/controller/authController.js index c2f0557..aa66329 100644 --- a/src/controller/authController.js +++ b/src/controller/authController.js @@ -448,6 +448,26 @@ export const subscribePremium = async (req, res, next) => { } }; +/* + * API No. 11 + * API Name : 개인 포인트 순위 조회 + * [GET] /auth/rank + */ +export const getUserRank = async(req, res, next) => { + try { + const users = await User.find().sort({ point: -1 }).limit(3); + + if (users.length === 0) { + return res.send(errResponse(status.MEMBER_NOT_FOUND)); + } + + return res.send(response(status.SUCCESS, users)); + } catch (err) { + console.log(err); + return res.send(errResponse(status.INTERNAL_SERVER_ERROR)); + } +}; + /*************************************************************************************/ // 이메일 유효성 검사 export const validEmailCheck = (email) => { @@ -501,4 +521,4 @@ export const generateRandomPassword = () => { export const getRandomChar = (charset) => { const index = Math.floor(Math.random() * charset.length); return charset[index]; -}; +}; \ No newline at end of file diff --git a/src/router/authRouter.js b/src/router/authRouter.js index 223be07..b11a600 100644 --- a/src/router/authRouter.js +++ b/src/router/authRouter.js @@ -10,6 +10,7 @@ import { checkEmail, findPassword, subscribePremium, + getUserRank, } from "../controller/authController"; import { authenticateUser, @@ -37,3 +38,4 @@ authRouter.post("/premium", authenticateUser, subscribePremium); // 프리미엄 authRouter.get("/payment", function (req, res) { res.render("payment"); }); +authRouter.get("/rank", getUserRank); // 개인 포인트 순위 조회 \ No newline at end of file