backend/src/services/stats.services.js
Fred Boniface 95d735205a Add api versions to stats api
Signed-off-by: Fred Boniface <fred@fjla.uk>
2023-03-30 21:18:07 +01:00

24 lines
785 B
JavaScript

const log = require('../utils/log.utils'); // Log Helper
const db = require('../services/dbAccess.services')
const os = require('os')
const vers = require('../configs/version.configs')
async function hits(){
log.out("statsServices.hits: Statistics Requested", "info")
var dat = db.query("meta", {target: "counters"});
var ver = db.query("meta", {target: "versions"});
log.out(`statsServices.hits: fetched server meta`, "info")
let out = {};
out.host = os.hostname();
out.mode = process.env.NODE_ENV;
out.verBkend = vers.app;
out.verApi = vers.api;
out.dat = await dat;
out.ver = await ver;
log.out(`statsServices.hits: Sending Data: ${JSON.stringify(out)}`, "info")
return out;
}
module.exports = {
hits
}