From c20a5a183f9cdea12dcaccde2c191b1762259583 Mon Sep 17 00:00:00 2001 From: Oliver Noller Date: Tue, 20 Mar 2018 10:52:24 +0100 Subject: [PATCH 1/4] Added little check to be able to pass an option to dynamicly set the host based on request --- lib/expressroutes.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/expressroutes.js b/lib/expressroutes.js index a24ee68..2d52fe7 100644 --- a/lib/expressroutes.js +++ b/lib/expressroutes.js @@ -185,7 +185,11 @@ function expressroutes(router, options) { mountpath = utils.unsuffix(options.api.basePath, '/'); router.get(mountpath + options.docspath, function (req, res) { - res.json(options.api); + let resp = options.api; + if (options.setDocBaseToReqHost) { + resp = Object.assign(res, { basepath: utils.prefix(req.get('host'), '/') }); + } + res.json(resp); }); routes.forEach(function (route) { From a2f900e9c4b50f135bb13706133538aeb963371d Mon Sep 17 00:00:00 2001 From: Oliver Noller Date: Tue, 20 Mar 2018 10:59:07 +0100 Subject: [PATCH 2/4] ooops --- lib/expressroutes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/expressroutes.js b/lib/expressroutes.js index 2d52fe7..c884d93 100644 --- a/lib/expressroutes.js +++ b/lib/expressroutes.js @@ -187,7 +187,7 @@ function expressroutes(router, options) { router.get(mountpath + options.docspath, function (req, res) { let resp = options.api; if (options.setDocBaseToReqHost) { - resp = Object.assign(res, { basepath: utils.prefix(req.get('host'), '/') }); + resp = Object.assign(resp, { basepath: utils.prefix(req.get('host'), '/') }); } res.json(resp); }); From 2c9d0ee5f390f1060b74b47823d93328701b0a31 Mon Sep 17 00:00:00 2001 From: Oliver Noller Date: Tue, 20 Mar 2018 11:16:59 +0100 Subject: [PATCH 3/4] fixed reserved word warning --- lib/expressroutes.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/expressroutes.js b/lib/expressroutes.js index c884d93..551e28c 100644 --- a/lib/expressroutes.js +++ b/lib/expressroutes.js @@ -185,11 +185,11 @@ function expressroutes(router, options) { mountpath = utils.unsuffix(options.api.basePath, '/'); router.get(mountpath + options.docspath, function (req, res) { - let resp = options.api; + let response = options.api; if (options.setDocBaseToReqHost) { - resp = Object.assign(resp, { basepath: utils.prefix(req.get('host'), '/') }); + response = Object.assign(response, { basepath: utils.prefix(req.get('host'), '/') }); } - res.json(resp); + res.json(response); }); routes.forEach(function (route) { From 12d8d40440d4c196fe072eee04ae1223113e027c Mon Sep 17 00:00:00 2001 From: Oliver Noller Date: Tue, 20 Mar 2018 11:22:03 +0100 Subject: [PATCH 4/4] changed let to var --- lib/expressroutes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/expressroutes.js b/lib/expressroutes.js index 551e28c..20a6855 100644 --- a/lib/expressroutes.js +++ b/lib/expressroutes.js @@ -185,7 +185,7 @@ function expressroutes(router, options) { mountpath = utils.unsuffix(options.api.basePath, '/'); router.get(mountpath + options.docspath, function (req, res) { - let response = options.api; + var response = options.api; if (options.setDocBaseToReqHost) { response = Object.assign(response, { basepath: utils.prefix(req.get('host'), '/') }); }