diff --git a/src/modules/api/api.js b/src/modules/api/api.js index 0c7f269..032e627 100644 --- a/src/modules/api/api.js +++ b/src/modules/api/api.js @@ -43,6 +43,7 @@ const usersDbBackupPath = 'data/dbs/backup' const quickVoteResultsDir = 'stats/qvote' const quickVotes = 'stats/qvote/votes.json' const testUsersFile = 'data/testUsers.json' +const idStatFile = 'stats/idstats' // other constants const maxVeteranPwGetCount = 10 @@ -161,6 +162,32 @@ function GetApp() { // ------------------------------------------------------------- + app.get('/ranklist', (req, res) => { + const user = req.session.user + const data = utils.ReadJSON(idStatFile) + + const list = [] + + Object.keys(data).forEach((key) => { + list.push({ + userId: parseInt(key), + ...data[key], + }) + }) + + if (list.length === 0) { + res.json({ + msg: 'There are no users in the stats db :c', + }) + return + } + + res.json({ + list: list, + selfuserId: user.id, + }) + }) + app.get('/quickvote', (req, res) => { const key = req.query.key const val = req.query.val