bad system endpoint

This commit is contained in:
codepupper 2019-11-16 18:52:47 +01:00
parent cc476832ab
commit 44ba5416e2
3 changed files with 2107 additions and 0 deletions

View file

@ -2,6 +2,7 @@ var express = require('express');
var api = express.Router();
var config = require('../../config');
var utils = require('../../utils');
const os = require('os');
api.get('/', (req, res) => {
res.status(200).jsonp({
@ -25,4 +26,22 @@ api.get('/ints/:kind/:user1?/:user2?', (req, res) => {
});
});
function format(seconds) {
function pad(s) {
return (s < 10 ? '0' : '') + s;
}
var hours = Math.floor(seconds / (60 * 60));
var minutes = Math.floor((seconds % (60 * 60)) / 60);
var seconds = Math.floor(seconds % 60);
return pad(hours) + 'h ' + pad(minutes) + 'm ' + pad(seconds) + 's';
}
api.get('/system', (req, res) => {
res.jsonp({
hostname: os.hostname(),
uptime: `${format(process.uptime())}`
});
});
module.exports = api;

2084
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -22,6 +22,7 @@
"mongojs": "^2.6.0",
"morgan": "^1.9.1",
"node-emoji": "^1.10.0",
"nodemon": "^1.19.4",
"ora": "^4.0.2",
"phin": "*",
"quick.db": "^7.0.0-b22",
@ -30,5 +31,8 @@
"trello": "^0.9.1",
"usage": "^0.7.1",
"yiff": "^1.2.5"
},
"scripts": {
"test": "nodemon index.js"
}
}