@digest/express 3.3.3 → 3.4.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/dist/app.js +2 -1
- package/dist/routers/history.d.ts +1 -1
- package/dist/routers/history.js +7 -8
- package/dist/routers/index.js +3 -1
- package/dist/routers/statics.js +4 -4
- package/dist/routers/stats.d.ts +2 -0
- package/dist/routers/stats.js +25 -0
- package/package.json +10 -6
package/dist/app.js
CHANGED
|
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const connect_slashes_1 = __importDefault(require("connect-slashes"));
|
|
6
7
|
const express_1 = __importDefault(require("express"));
|
|
7
8
|
const helmet_1 = __importDefault(require("helmet"));
|
|
8
9
|
const routers_1 = __importDefault(require("./routers"));
|
|
9
10
|
const server_1 = __importDefault(require("./server"));
|
|
10
11
|
const app = (0, express_1.default)();
|
|
11
|
-
app.use((0, helmet_1.default)(), routers_1.default);
|
|
12
|
+
app.use((0, helmet_1.default)(), routers_1.default, (0, connect_slashes_1.default)(false));
|
|
12
13
|
(0, server_1.default)(app);
|
|
13
14
|
exports.default = app;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const history: (baseHref
|
|
1
|
+
declare const history: (baseHref?: string) => import("express-serve-static-core").Router;
|
|
2
2
|
export default history;
|
package/dist/routers/history.js
CHANGED
|
@@ -10,21 +10,20 @@ const ACCEPT_HEADERS = [
|
|
|
10
10
|
'text/html',
|
|
11
11
|
'application/xhtml+xml'
|
|
12
12
|
];
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const history = (baseHref = '/') => {
|
|
14
|
+
const router = (0, express_1.Router)({
|
|
15
|
+
caseSensitive: true,
|
|
16
|
+
strict: true
|
|
17
|
+
});
|
|
18
18
|
const defaultIndex = path_1.default.join(baseHref, 'index.html');
|
|
19
19
|
const historyMiddleware = (0, connect_history_api_fallback_1.default)({
|
|
20
20
|
htmlAcceptHeaders: ACCEPT_HEADERS,
|
|
21
21
|
index: defaultIndex
|
|
22
22
|
});
|
|
23
|
-
const historyBase = '
|
|
23
|
+
const historyBase = '/*';
|
|
24
24
|
router.get(historyBase, historyMiddleware);
|
|
25
25
|
router.head(historyBase, historyMiddleware);
|
|
26
|
-
router.
|
|
27
|
-
router.head('/', historyMiddleware);
|
|
26
|
+
router.options(historyBase, historyMiddleware);
|
|
28
27
|
return router;
|
|
29
28
|
};
|
|
30
29
|
exports.default = history;
|
package/dist/routers/index.js
CHANGED
|
@@ -7,13 +7,15 @@ const scripts_1 = __importDefault(require("@digest/scripts"));
|
|
|
7
7
|
const express_1 = require("express");
|
|
8
8
|
const history_1 = __importDefault(require("./history"));
|
|
9
9
|
const statics_1 = __importDefault(require("./statics"));
|
|
10
|
+
const stats_1 = __importDefault(require("./stats"));
|
|
10
11
|
const { baseHref, production } = scripts_1.default;
|
|
11
12
|
const staticPath = scripts_1.default.staticPath.replace('/bundle', '');
|
|
12
13
|
const routers = (0, express_1.Router)({
|
|
13
14
|
caseSensitive: true,
|
|
14
15
|
strict: true
|
|
15
16
|
});
|
|
17
|
+
const statsRouter = (0, stats_1.default)();
|
|
16
18
|
const historyRouter = (0, history_1.default)(baseHref);
|
|
17
19
|
const staticsRouter = (0, statics_1.default)(baseHref, staticPath.replace('/bundle', ''), production);
|
|
18
|
-
routers.use(baseHref, historyRouter, staticsRouter);
|
|
20
|
+
routers.use(baseHref, statsRouter, historyRouter, staticsRouter);
|
|
19
21
|
exports.default = routers;
|
package/dist/routers/statics.js
CHANGED
|
@@ -7,10 +7,6 @@ const express_1 = require("express");
|
|
|
7
7
|
const express_static_gzip_1 = __importDefault(require("express-static-gzip"));
|
|
8
8
|
const serve_static_1 = __importDefault(require("serve-static"));
|
|
9
9
|
const MAX_AGE = 31536000;
|
|
10
|
-
const router = (0, express_1.Router)({
|
|
11
|
-
caseSensitive: true,
|
|
12
|
-
strict: true
|
|
13
|
-
});
|
|
14
10
|
const defaultServeStaticOptions = {
|
|
15
11
|
immutable: true,
|
|
16
12
|
index: false,
|
|
@@ -44,6 +40,10 @@ const removeBaseHref = (middleware, baseHref) => {
|
|
|
44
40
|
};
|
|
45
41
|
};
|
|
46
42
|
const statics = (baseHref, staticPath, production = false, serveStaticOptions) => {
|
|
43
|
+
const router = (0, express_1.Router)({
|
|
44
|
+
caseSensitive: true,
|
|
45
|
+
strict: true
|
|
46
|
+
});
|
|
47
47
|
const options = Object.assign(Object.assign({}, defaultServeStaticOptions), serveStaticOptions);
|
|
48
48
|
const staticBase = '/*';
|
|
49
49
|
const serveStatic = removeBaseHref(production ?
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const express_1 = require("express");
|
|
4
|
+
const helmet_1 = require("helmet");
|
|
5
|
+
const stats = () => {
|
|
6
|
+
const router = (0, express_1.Router)({
|
|
7
|
+
caseSensitive: true,
|
|
8
|
+
strict: true
|
|
9
|
+
});
|
|
10
|
+
const helmetMiddleware = (0, helmet_1.contentSecurityPolicy)({
|
|
11
|
+
directives: {
|
|
12
|
+
'script-src': [
|
|
13
|
+
'\'self\'',
|
|
14
|
+
'\'unsafe-inline\''
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
useDefaults: true
|
|
18
|
+
});
|
|
19
|
+
const statsPath = '/stats/*';
|
|
20
|
+
router.get(statsPath, helmetMiddleware);
|
|
21
|
+
router.head(statsPath, helmetMiddleware);
|
|
22
|
+
router.options(statsPath, helmetMiddleware);
|
|
23
|
+
return router;
|
|
24
|
+
};
|
|
25
|
+
exports.default = stats;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@digest/express",
|
|
3
3
|
"title": "Express Digest",
|
|
4
4
|
"license": "GPL-3.0",
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.4.1",
|
|
6
6
|
"description": "Digested Express configurations",
|
|
7
7
|
"author": "wallzero @wallzeroblog (http://wallzero.com)",
|
|
8
8
|
"contributors": [
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"/dist/routers/index.js",
|
|
22
22
|
"/dist/routers/statics.d.ts",
|
|
23
23
|
"/dist/routers/statics.js",
|
|
24
|
+
"/dist/routers/stats.d.ts",
|
|
25
|
+
"/dist/routers/stats.js",
|
|
24
26
|
"/dist/app.d.ts",
|
|
25
27
|
"/dist/app.js",
|
|
26
28
|
"/dist/server.d.ts",
|
|
@@ -42,14 +44,16 @@
|
|
|
42
44
|
"clean": "rimraf node_modules dist package-lock.json npm-debug.log"
|
|
43
45
|
},
|
|
44
46
|
"dependencies": {
|
|
45
|
-
"@digest/scripts": "^3.
|
|
47
|
+
"@digest/scripts": "^3.4.1",
|
|
46
48
|
"connect-history-api-fallback": "^1.6.0",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
49
|
+
"connect-slashes": "^1.4.0",
|
|
50
|
+
"express-static-gzip": "^2.1.5",
|
|
51
|
+
"helmet": "^5.0.2",
|
|
52
|
+
"serve-static": "^1.14.2"
|
|
50
53
|
},
|
|
51
54
|
"devDependencies": {
|
|
52
55
|
"@types/connect-history-api-fallback": "^1.3.5",
|
|
56
|
+
"@types/connect-slashes": "^0.0.33",
|
|
53
57
|
"@types/express": "^4.17.13",
|
|
54
58
|
"@types/serve-static": "^1.13.10"
|
|
55
59
|
},
|
|
@@ -60,5 +64,5 @@
|
|
|
60
64
|
"digest",
|
|
61
65
|
"express"
|
|
62
66
|
],
|
|
63
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "fe9b4c497d51cce743e952edc371c9003e55f876"
|
|
64
68
|
}
|