Add /misc/server/versions

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-06-26 22:26:47 +01:00
parent 3682ca51d8
commit a324c6fc63
5 changed files with 41 additions and 4 deletions

View File

@ -1,7 +1,9 @@
const issue = require('../services/issue.services');
const log = require('../utils/log.utils');
async function post(req, res, next){
try {
log.out(`issueControllers.post: Request Body: ${JSON.stringify(req.body)}`);
res.json(await issue.processor(req.body));
} catch (err) {
console.error('Controller Error', err.message);

View File

@ -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 = {
get
get,
versions
};

View File

@ -3,12 +3,13 @@ const router = express.Router();
// Controller Imports
const issueCtr = require('../controllers/issue.controllers');
const statCtr = require('../controllers/stats.controllers');
// Routes
router.get('/server/stats');
router.get('/server/versions');
router.get('/server/versions', statCtr.versions);
router.post('/issue', issueCtr.post);

View File

@ -2,11 +2,19 @@
const axios = require('axios');
const log = require('../utils/log.utils');
const issueLabels = {
bug: 120,
enhancement: 122,
question: 125,
'user-support': 152,
'web-user': 153
};
async function processor(data) {
log.out('issueService.processor: Issue received', 'info');
console.log(data); // TEMPORARY MEASURE
let out = {};
out.labels = data?.labels || [];
out.labels = [(issueLabels[data?.label] || 0), issueLabels['web-user']];
out.title = data?.subject.replace(/<[^>]+>|[\*\$]/g, '');
out.body = data?.msg.replace(/<[^>]+>|[\*\$]/g, '');
return await sendToGitea(out);

View File

@ -41,6 +41,21 @@ async function hits(){
return out;
}
module.exports = {
hits
async function versions() {
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
};