@apolitical/server 2.3.2 → 2.3.3-rc.test.1
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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.3.3] - 2022-02-21
|
|
9
|
+
### Changed
|
|
10
|
+
- maging sure index.html is not considered as a static asset by the middleware loader
|
|
11
|
+
|
|
8
12
|
## [2.3.2] - 2022-02-21
|
|
9
13
|
### Changed
|
|
10
14
|
- loading static files middleware after the app has been loaded
|
package/package.json
CHANGED
package/src/container.js
CHANGED
|
@@ -35,7 +35,6 @@ const jwtPassportHelper = require('./helpers/jwt/passport.helper');
|
|
|
35
35
|
const documentationLoader = require('./loaders/documentation.loader');
|
|
36
36
|
const loggerLoader = require('./loaders/logger.loader');
|
|
37
37
|
const middlewaresLoader = require('./loaders/middlewares.loader');
|
|
38
|
-
const staticLoader = require('./loaders/static.loader');
|
|
39
38
|
const probesLoader = require('./loaders/probes.loader');
|
|
40
39
|
const fallbackLoader = require('./loaders/fallback.loader');
|
|
41
40
|
// Middleware
|
|
@@ -85,7 +84,6 @@ container.register({
|
|
|
85
84
|
documentationLoader: asFunction(documentationLoader).singleton(),
|
|
86
85
|
loggerLoader: asFunction(loggerLoader).singleton(),
|
|
87
86
|
middlewaresLoader: asFunction(middlewaresLoader).singleton(),
|
|
88
|
-
staticLoader: asFunction(staticLoader).singleton(),
|
|
89
87
|
probesLoader: asFunction(probesLoader).singleton(),
|
|
90
88
|
fallbackLoader: asFunction(fallbackLoader).singleton(),
|
|
91
89
|
// Middlewares
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
module.exports = ({
|
|
3
|
+
module.exports = ({
|
|
4
|
+
bodyParser: { json, urlencoded },
|
|
5
|
+
express,
|
|
6
|
+
compression,
|
|
7
|
+
cors,
|
|
8
|
+
cookieParser,
|
|
9
|
+
prerender,
|
|
10
|
+
config,
|
|
11
|
+
logger,
|
|
12
|
+
}) => {
|
|
4
13
|
const {
|
|
5
14
|
BODY_PARSER_OPTIONS: { JSON_OPTIONS, URL_ENCODED_OPTIONS },
|
|
6
15
|
CORS_OPTIONS,
|
|
7
16
|
} = config.SERVER;
|
|
8
17
|
|
|
9
|
-
return function load(app, { corsOptions, prerenderToken }) {
|
|
18
|
+
return function load(app, { corsOptions, prerenderToken, staticFiles }) {
|
|
10
19
|
const childLogger = logger.where(__filename, 'load');
|
|
11
20
|
childLogger.debug('Started');
|
|
12
21
|
// Load useful middlewares
|
|
@@ -18,6 +27,10 @@ module.exports = ({ bodyParser: { json, urlencoded }, compression, cors, cookieP
|
|
|
18
27
|
if (prerenderToken) {
|
|
19
28
|
app.use(prerender.set('prerenderToken', prerenderToken));
|
|
20
29
|
}
|
|
30
|
+
if (staticFiles) {
|
|
31
|
+
const { baseUrl, folderPath } = staticFiles;
|
|
32
|
+
app.use(baseUrl, express.static(folderPath, { index: false }));
|
|
33
|
+
}
|
|
21
34
|
childLogger.debug('Finished');
|
|
22
35
|
};
|
|
23
36
|
};
|
|
@@ -10,7 +10,6 @@ module.exports = ({
|
|
|
10
10
|
authorisationMiddleware,
|
|
11
11
|
errorMiddleware,
|
|
12
12
|
middlewaresLoader,
|
|
13
|
-
staticLoader,
|
|
14
13
|
probesLoader,
|
|
15
14
|
fallbackLoader,
|
|
16
15
|
jwtService,
|
|
@@ -51,8 +50,6 @@ module.exports = ({
|
|
|
51
50
|
if (opts.appLoader) {
|
|
52
51
|
await opts.appLoader(app);
|
|
53
52
|
}
|
|
54
|
-
// Load static files middleware
|
|
55
|
-
staticLoader(app, opts);
|
|
56
53
|
// Load documentation
|
|
57
54
|
documentationLoader(app, opts);
|
|
58
55
|
// Load fallback routing
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = ({ express, logger }) => {
|
|
4
|
-
return function load(app, { staticFiles }) {
|
|
5
|
-
const childLogger = logger.where(__filename, 'load');
|
|
6
|
-
childLogger.debug('Started');
|
|
7
|
-
|
|
8
|
-
if (staticFiles) {
|
|
9
|
-
const { baseUrl, folderPath } = staticFiles;
|
|
10
|
-
app.use(baseUrl, express.static(folderPath));
|
|
11
|
-
}
|
|
12
|
-
childLogger.debug('Finished');
|
|
13
|
-
};
|
|
14
|
-
};
|