DO - 16 랭킹 서버 수정
This commit is contained in:
parent
a393930db7
commit
c0e039f7f8
2
app.js
2
app.js
@ -75,7 +75,7 @@ app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
app.use('/', indexRouter);
|
||||
app.use('/users', usersRouter);
|
||||
app.use('/leaderboard', leaderboardRouter);
|
||||
app.use('/', leaderboardRouter);
|
||||
app.use('/coins', coinsRouter);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
|
@ -3,7 +3,7 @@ const {ObjectId} = require("mongodb");
|
||||
var router = express.Router();
|
||||
|
||||
// 랭킹 조회
|
||||
router.get("/", async function (req, res, next) {
|
||||
router.get("/leaderboard", async function (req, res, next) {
|
||||
try {
|
||||
if(!req.session.isAuthenticated) {
|
||||
return res.status(403).send("로그인이 필요합니다.");
|
||||
@ -35,7 +35,7 @@ router.get("/", async function (req, res, next) {
|
||||
lose: user.lose || 0,
|
||||
winRate: parseFloat(winRate.toFixed(2)), // 소수점 2자리까지 표시
|
||||
totalGames: totalGames,
|
||||
imageIndex: user.profileImageIndex,
|
||||
profileImageIndex: user.profileImageIndex,
|
||||
};
|
||||
})
|
||||
.sort((a, b) => {
|
||||
@ -46,9 +46,11 @@ router.get("/", async function (req, res, next) {
|
||||
return b.winRate - a.winRate; // 승률 내림차순 정렬
|
||||
});
|
||||
|
||||
console.log(userRating);
|
||||
console.log(result);
|
||||
res.json({
|
||||
rating: userRating,
|
||||
leaderboardDatas : result ?? []
|
||||
scoreInfos : result ?? []
|
||||
});
|
||||
} catch(err) {
|
||||
console.error(err);
|
||||
|
Loading…
x
Reference in New Issue
Block a user