Skip to content

Commit

Permalink
Merge pull request #7 from MarcelKaemper/mVersionnumber
Browse files Browse the repository at this point in the history
Added version number to userinfo
  • Loading branch information
MarcelKaemper authored Nov 23, 2019
2 parents 936021c + 8d34a34 commit 57ad4ba
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
7 changes: 5 additions & 2 deletions public/javascripts/functions/getUserInfo.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
const getVersion = require('./getVersion');

const getUserInfo = (req) => {
return new Promise((resolve, reject) => {
return new Promise(async (resolve, reject) => {
resolve({name: req.session.name,
displayName: req.session.displayName,
xp: req.session.xp,
neededXP: req.session.neededXP,
clan: req.session.clan!=""?req.session.clan:"None",
level: req.session.level,
money: req.session.money,
ip: req.session.ip});
ip: req.session.ip,
version: await getVersion()});
});
};

Expand Down
12 changes: 12 additions & 0 deletions public/javascripts/functions/getVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const fetch = require('node-fetch');

const getVersion = () => {
const url = "https://api.github.com/repos/marcelkaemper/HackergameV2/releases";
return new Promise((resolve, reject) => {
fetch(url)
.then(res => res.json())
.then(data => resolve(data[0]["name"]));
});
}

module.exports = getVersion;
4 changes: 4 additions & 0 deletions views/layouts/layout.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
<td>IP:</td>
<td>{{user.ip}}</td>
</tr>
<tr>
<td>Version:</td>
<td>{{user.version}}</td>
</tr>
</table>
</div>
</div>
Expand Down
20 changes: 0 additions & 20 deletions views/profile.hbs

This file was deleted.

0 comments on commit 57ad4ba

Please sign in to comment.