Remove generic controller, its functionallity fits better in cors middleware

This commit is contained in:
Daniel García Aubert 2019-10-01 12:52:54 +02:00
parent d85331e97b
commit a383785e7c
3 changed files with 4 additions and 17 deletions

View File

@ -1,13 +0,0 @@
'use strict';
module.exports = class GenericController {
route (app) {
app.options('*', emptyResponse());
}
};
function emptyResponse () {
return function emptyResponseMiddleware (req, res) {
res.end();
};
}

View File

@ -21,6 +21,10 @@ module.exports = function cors(extraHeaders = []) {
res.header('Access-Control-Allow-Headers', headers.join(', '));
res.header('Access-Control-Expose-Headers', exposedHeaders.join(', '));
if (req.method === 'OPTIONS') {
return res.send();
}
next();
};
};

View File

@ -29,7 +29,6 @@ const Logger = require('./services/logger');
var cors = require('./middlewares/cors');
const ApiRouter = require('./controllers/api-router');
var GenericController = require('./controllers/generic_controller');
var HealthCheckController = require('./controllers/health_check_controller');
var VersionController = require('./controllers/version_controller');
@ -129,9 +128,6 @@ function App(statsClient) {
const dataIngestionLogger = new Logger(global.settings.dataIngestionLogPath, 'data-ingestion');
app.dataIngestionLogger = dataIngestionLogger;
var genericController = new GenericController();
genericController.route(app);
var healthCheckController = new HealthCheckController();
healthCheckController.route(app);