diff --git a/README.md b/README.md index 6958b7f..41a2e8d 100755 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ This makes sense for provider that only offer limited filter functions like Kala # API 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. +Gives you an overview of running search jobs, their included enabled provider, last execution and the number of listings, found by each provider. You can disable the api by setting `infoApi: false` within the config. #### http://localhost:9998/ping Should you ever need some health checks, this returns pong ;) diff --git a/conf/config.example b/conf/config.example index 38b835d..5799796 100755 --- a/conf/config.example +++ b/conf/config.example @@ -1,5 +1,6 @@ { "interval": 1, + "infoApi": true, "jobs": { "yourSearchJob": { "notification": { diff --git a/lib/api/api.js b/lib/api/api.js index 0c667b8..f222568 100644 --- a/lib/api/api.js +++ b/lib/api/api.js @@ -3,6 +3,8 @@ const config = require('../../conf/config'); const { getLastJobExecution, getLastProviderExecution, getTotalNumberOfListings } = require('../services/store'); const PORT = 9998; const service = require('restana')(); +const enabled = config.infoApi == null ? false : config.infoApi; + service.use(bodyParser.json()); service.get('/', async (req, res) => { @@ -55,8 +57,12 @@ service.get('/ping', function (req, res) { res.send(); }); -service.start(PORT).then(() => { - /* eslint-disable no-console */ - console.info(`Started API service on port ${PORT}`); - /* eslint-enable no-console */ -}); +/* eslint-disable no-console */ +if (enabled) { + service.start(PORT).then(() => { + console.info(`Started API service on port ${PORT}`); + }); +} else { + console.info('Info Api is disabled.'); +} +/* eslint-enable no-console */