@apolitical/server 2.0.1-beta.1 → 2.0.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apolitical/server",
|
|
3
|
-
"version": "2.0.1-beta.
|
|
3
|
+
"version": "2.0.1-beta.2",
|
|
4
4
|
"description": "Node.js module to encapsulate Apolitical's express server setup",
|
|
5
5
|
"author": "Apolitical Group Limited <engineering@apolitical.co>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"husky": "7.0.4",
|
|
52
52
|
"jest": "27.4.7",
|
|
53
53
|
"jest-junit": "13.0.0",
|
|
54
|
-
"lint-staged": "12.2.
|
|
54
|
+
"lint-staged": "12.2.2",
|
|
55
55
|
"mock-jwks": "1.0.1",
|
|
56
56
|
"nock": "13.2.2"
|
|
57
57
|
},
|
|
@@ -12,12 +12,18 @@ module.exports = ({
|
|
|
12
12
|
return function load(app, { swaggerDocument }) {
|
|
13
13
|
const childLogger = logger.where(__filename, 'load');
|
|
14
14
|
childLogger.debug('Started');
|
|
15
|
+
// Internal middleware to dynamically set the host
|
|
16
|
+
function hostMiddleware(req, res, next) {
|
|
17
|
+
swaggerDocument.host = req.get('host');
|
|
18
|
+
req.swaggerDoc = swaggerDocument;
|
|
19
|
+
next();
|
|
20
|
+
}
|
|
15
21
|
// Load document endpoint
|
|
16
22
|
if (swaggerDocument) {
|
|
17
23
|
// Redirection to documentation
|
|
18
24
|
app.use(`${DOCUMENTATION}index.html`, (req, res) => res.redirect(MOVED_PERMANENTLY, DOCUMENTATION));
|
|
19
25
|
// Documentation express setup
|
|
20
|
-
app.use(DOCUMENTATION, authorisationMiddleware(), serve, setup(swaggerDocument));
|
|
26
|
+
app.use(DOCUMENTATION, authorisationMiddleware(), hostMiddleware, serve, setup(swaggerDocument));
|
|
21
27
|
}
|
|
22
28
|
childLogger.debug('Finished');
|
|
23
29
|
};
|