adding option to disable the info api

This commit is contained in:
Christian Kellner
2020-07-20 16:21:11 +02:00
parent e9b1eeae48
commit f1a00cf3bd
3 changed files with 13 additions and 6 deletions

View File

@@ -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 */