Files
fredy/lib/services/stats.js
Christian Kellner c6cffe029d Release v1.0.0 🎉
2018-01-20 20:23:27 +01:00

26 lines
614 B
JavaScript

const config = require('../../conf/config.json');
let lastScrape = {};
if (config.enableStats) {
const http = require('http');
http
.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(
JSON.stringify({
config,
lastScrape
})
);
})
.listen(config.statsPort, '127.0.0.1');
}
exports.setLastScrape = (serviceName, numberFound) => {
lastScrape[serviceName] = lastScrape[serviceName] || [];
lastScrape[serviceName].push({
scapeTime: new Date().toString(),
numberFound: numberFound
});
};