Add /misc/server/versions
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
3682ca51d8
commit
a324c6fc63
@ -1,7 +1,9 @@
|
|||||||
const issue = require('../services/issue.services');
|
const issue = require('../services/issue.services');
|
||||||
|
const log = require('../utils/log.utils');
|
||||||
|
|
||||||
async function post(req, res, next){
|
async function post(req, res, next){
|
||||||
try {
|
try {
|
||||||
|
log.out(`issueControllers.post: Request Body: ${JSON.stringify(req.body)}`);
|
||||||
res.json(await issue.processor(req.body));
|
res.json(await issue.processor(req.body));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Controller Error', err.message);
|
console.error('Controller Error', err.message);
|
||||||
|
@ -10,6 +10,17 @@ async function get(req, res, next) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function versions(req, res, next) {
|
||||||
|
try {
|
||||||
|
res.json(await stat.versions());
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Controller Error', err);
|
||||||
|
err.status = 500;
|
||||||
|
next(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
get
|
get,
|
||||||
|
versions
|
||||||
};
|
};
|
@ -3,12 +3,13 @@ const router = express.Router();
|
|||||||
|
|
||||||
// Controller Imports
|
// Controller Imports
|
||||||
const issueCtr = require('../controllers/issue.controllers');
|
const issueCtr = require('../controllers/issue.controllers');
|
||||||
|
const statCtr = require('../controllers/stats.controllers');
|
||||||
|
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
|
|
||||||
router.get('/server/stats');
|
router.get('/server/stats');
|
||||||
router.get('/server/versions');
|
router.get('/server/versions', statCtr.versions);
|
||||||
|
|
||||||
router.post('/issue', issueCtr.post);
|
router.post('/issue', issueCtr.post);
|
||||||
|
|
||||||
|
@ -2,11 +2,19 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const log = require('../utils/log.utils');
|
const log = require('../utils/log.utils');
|
||||||
|
|
||||||
|
const issueLabels = {
|
||||||
|
bug: 120,
|
||||||
|
enhancement: 122,
|
||||||
|
question: 125,
|
||||||
|
'user-support': 152,
|
||||||
|
'web-user': 153
|
||||||
|
};
|
||||||
|
|
||||||
async function processor(data) {
|
async function processor(data) {
|
||||||
log.out('issueService.processor: Issue received', 'info');
|
log.out('issueService.processor: Issue received', 'info');
|
||||||
console.log(data); // TEMPORARY MEASURE
|
console.log(data); // TEMPORARY MEASURE
|
||||||
let out = {};
|
let out = {};
|
||||||
out.labels = data?.labels || [];
|
out.labels = [(issueLabels[data?.label] || 0), issueLabels['web-user']];
|
||||||
out.title = data?.subject.replace(/<[^>]+>|[\*\$]/g, '');
|
out.title = data?.subject.replace(/<[^>]+>|[\*\$]/g, '');
|
||||||
out.body = data?.msg.replace(/<[^>]+>|[\*\$]/g, '');
|
out.body = data?.msg.replace(/<[^>]+>|[\*\$]/g, '');
|
||||||
return await sendToGitea(out);
|
return await sendToGitea(out);
|
||||||
|
@ -41,6 +41,21 @@ async function hits(){
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
async function versions() {
|
||||||
hits
|
log.out('statsServices.versions: Fetching versions', 'info');
|
||||||
|
const versions = db.query('meta', {target: 'versions'});
|
||||||
|
let data = {
|
||||||
|
backend: '',
|
||||||
|
'db-manager': '',
|
||||||
|
'mq-subscriber': '',
|
||||||
|
};
|
||||||
|
await versions;
|
||||||
|
data.backend = vers.app;
|
||||||
|
data['db-manager'] = versions[0]['dbmanager'];
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
hits,
|
||||||
|
versions
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user