mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
adding option to disable the info api
This commit is contained in:
@@ -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 ;)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"interval": 1,
|
||||
"infoApi": true,
|
||||
"jobs": {
|
||||
"yourSearchJob": {
|
||||
"notification": {
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user