From f74e36bd66a6a0cdcd64e77b366d3562efde8086 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Fri, 17 Jul 2020 22:15:22 +0200 Subject: [PATCH] changing rest port --- README.md | 8 ++++---- lib/api/api.js | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 5b7facd..9c2bcba 100755 --- a/README.md +++ b/README.md @@ -151,14 +151,14 @@ Districts that are unwanted can be blacklisted here. This makes sense for provider that only offer limited filter functions like Kalaydo/Ebay. # API -While Fredy is running, you can make use of the rest api provided on port `9988` to get information about the current status of Fredy. -#### http://localhost:9988/ +While Fredy is running, you can make use of the rest api provided on port `9998` to get information about the current status of Fredy. +#### http://localhost:9998/ Gives you an overview of running search jobs, their included enabled provider, last execution and the number of listings, found by each provider. -#### http://localhost:9988/ping +#### http://localhost:9998/ping Should you ever need some health checks, this returns pong ;) -#### http://localhost:9988/jobs/:name +#### http://localhost:9998/jobs/:name Returns specific information about the job with the given name or `404` if the job could not be found. # Docker diff --git a/lib/api/api.js b/lib/api/api.js index 056580b..c6de9cd 100644 --- a/lib/api/api.js +++ b/lib/api/api.js @@ -1,24 +1,24 @@ const bodyParser = require('body-parser'); const config = require('../../conf/config'); const { getLastJobExecution, getLastProviderExecution, getTotalNumberOfListings } = require('../services/store'); -const PORT = 9988; +const PORT = 9908; const service = require('restana')(); service.use(bodyParser.json()); service.get('/', async (req, res) => { const result = {}; - Object.keys(config.jobs).forEach(job => { + Object.keys(config.jobs).forEach((job) => { result[job] = { lastExecution: getLastJobExecution(job), enabledProvider: Object.keys(config.jobs[job].provider) - .filter(providerKey => config.jobs[job].provider[providerKey].enabled) - .map(providerKey => { + .filter((providerKey) => config.jobs[job].provider[providerKey].enabled) + .map((providerKey) => { return { name: providerKey, lastExecution: getLastProviderExecution(job, providerKey), - totalFindings: getTotalNumberOfListings(job, providerKey) + totalFindings: getTotalNumberOfListings(job, providerKey), }; - }) + }), }; }); res.body = result; @@ -35,22 +35,22 @@ service.get('/jobs/:name', async (req, res) => { res.body = { lastExecution: getLastJobExecution(jobKey), enabledProvider: Object.keys(config.jobs[jobKey].provider) - .filter(providerKey => config.jobs[jobKey].provider[providerKey].enabled) - .map(providerKey => { + .filter((providerKey) => config.jobs[jobKey].provider[providerKey].enabled) + .map((providerKey) => { return { name: providerKey, url: config.jobs[jobKey].provider[providerKey].url, lastExecution: getLastProviderExecution(jobKey, providerKey), - totalFindings: getTotalNumberOfListings(jobKey, providerKey) + totalFindings: getTotalNumberOfListings(jobKey, providerKey), }; - }) + }), }; res.send(); }); -service.get('/ping', function(req, res) { +service.get('/ping', function (req, res) { res.body = { - pong: 'pong' + pong: 'pong', }; res.send(); });