From 261e15e6a481a5cb5e5afd717bd73ddc9fead814 Mon Sep 17 00:00:00 2001 From: seiyria Date: Thu, 6 Feb 2020 13:51:30 -0600 Subject: [PATCH] update player route --- src/db.js | 4 ++++ src/routes/player.js | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/db.js b/src/db.js index 7f38785..bfa6134 100644 --- a/src/db.js +++ b/src/db.js @@ -22,6 +22,10 @@ class Database { this.$players = db.collection('player'); this.$guilds = db.collection('guild'); + this.$inventory = db.collection('inventory'); + this.$collectibles = db.collection('collectibles'); + this.$achievements = db.collection('achievements'); + resolve(); } catch(e) { diff --git a/src/routes/player.js b/src/routes/player.js index a27ea77..ea372d7 100644 --- a/src/routes/player.js +++ b/src/routes/player.js @@ -6,10 +6,39 @@ exports.route = (app) => { const player = await DB.$players .findOne( - { name: req.query.name }, - { fields: { name: 1, profession: 1, 'level.__current': 1, 'level.maximum': 1, ascensionLevel: 1, map: 1 } } + { name: req.query.name, banned: { $ne: true } }, + { fields: { + name: 1, + title: 1, + profession: 1, + 'level.__current': 1, + 'level.maximum': 1, + ascensionLevel: 1, + map: 1, + createdAt: 1, + gender: 1, + xp: 1, + gold: 1, + loggedIn: 1, + stats: 1 + } + } ); + if(!player) return res.json(null); + + const [inventory, collectibles, statistics, achievements] = await Promise.all([ + DB.$inventory.findOne({ owner: req.query.name }), + DB.$collectibles.findOne({ owner: req.query.name }), + DB.$statistics.findOne({ owner: req.query.name }), + DB.$achievements.findOne({ owner: req.query.name }) + ]); + + player.inventory = inventory; + player.collectibles = collectibles; + player.statistics = statistics; + player.achievements = achievements; + res.json(player); });