From 5a397afd0609611fd8ee6a38a5378aed2d7feaea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Mon, 14 May 2018 11:50:48 +0200 Subject: [PATCH] In order to extract common middlewares between routers and controlles we need to activate mergeParams options to preserve the req.params from the parent router --- lib/cartodb/api/api-router.js | 2 +- lib/cartodb/api/map/map-router.js | 2 +- lib/cartodb/api/template/template-router.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cartodb/api/api-router.js b/lib/cartodb/api/api-router.js index 9d53285b..b7534559 100644 --- a/lib/cartodb/api/api-router.js +++ b/lib/cartodb/api/api-router.js @@ -191,7 +191,7 @@ module.exports = class ApiRouter { Object.keys(this.serverOptions.routes).forEach(apiVersion => { const routes = this.serverOptions.routes[apiVersion]; - const apiRouter = router(); + const apiRouter = router({ mergeParams: true }); apiRouter.use(logger(this.serverOptions)); apiRouter.use(initializeStatusCode()); diff --git a/lib/cartodb/api/map/map-router.js b/lib/cartodb/api/map/map-router.js index 03f19937..46e2be5e 100644 --- a/lib/cartodb/api/map/map-router.js +++ b/lib/cartodb/api/map/map-router.js @@ -113,7 +113,7 @@ module.exports = class MapRouter { } register (apiRouter, mapPaths) { - const mapRouter = router(); + const mapRouter = router({ mergeParams: true }); this.analysisLayergroupController.register(mapRouter); this.attributesLayergroupController.register(mapRouter); diff --git a/lib/cartodb/api/template/template-router.js b/lib/cartodb/api/template/template-router.js index 9ddcf9fc..4234bb22 100644 --- a/lib/cartodb/api/template/template-router.js +++ b/lib/cartodb/api/template/template-router.js @@ -53,7 +53,7 @@ module.exports = class TemplateRouter { } register (apiRouter, templatePaths) { - const templateRouter = router(); + const templateRouter = router({ mergeParams: true }); this.namedMapController.register(templateRouter); this.tileTemplateController.register(templateRouter);