Use express router to group controllers' enpoints and reuse common middleware for analysis controller

This commit is contained in:
Daniel García Aubert
2017-09-22 16:28:52 +02:00
parent b0486f9bae
commit ee8619c470
2 changed files with 12 additions and 5 deletions
+7 -4
View File
@@ -20,11 +20,14 @@ util.inherits(AnalysesController, BaseController);
module.exports = AnalysesController;
AnalysesController.prototype.register = function(app) {
app.get(
app.base_url_mapconfig + '/analyses/catalog',
AnalysesController.prototype.register = function(router) {
router.use(
cors(),
userMiddleware,
userMiddleware
);
router.get(
'/analyses/catalog',
this.req2paramsMiddleware,
this.catalog.bind(this)
);
+5 -1
View File
@@ -255,7 +255,11 @@ module.exports = function(serverOptions) {
new controller.NamedMapsAdmin(authApi, pgConnection, templateMaps).register(app);
new controller.Analyses(authApi, pgConnection).register(app);
const analysisRouter = express.Router();
new controller.Analyses(authApi, pgConnection).register(analysisRouter);
app.use(app.base_url_mapconfig, analysisRouter);
new controller.ServerInfo(versions).register(app);