@digest/koa 4.14.15 → 4.14.16
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/middleware/history.js +12 -17
- package/dist/middleware/statics.js +8 -2
- package/package.json +6 -6
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -22,20 +13,24 @@ const history = (baseHref, options) => {
|
|
|
22
13
|
const defaultIndex = baseHref ?
|
|
23
14
|
node_path_1.default.join(baseHref, 'index.html') :
|
|
24
15
|
undefined;
|
|
25
|
-
const defaultOptions =
|
|
16
|
+
const defaultOptions = {
|
|
17
|
+
htmlAcceptHeaders: ACCEPT_HEADERS,
|
|
18
|
+
index: defaultIndex,
|
|
19
|
+
...options
|
|
20
|
+
};
|
|
26
21
|
const middleware = (0, koa_history_api_fallback_1.default)(defaultOptions);
|
|
27
|
-
const historyMiddleware = (context, next) =>
|
|
22
|
+
const historyMiddleware = async (context, next) => {
|
|
28
23
|
if (context.state.history) {
|
|
29
|
-
|
|
24
|
+
await next();
|
|
30
25
|
}
|
|
31
26
|
else {
|
|
32
|
-
const nextRoute = () =>
|
|
27
|
+
const nextRoute = async () => {
|
|
33
28
|
context.state.history = true;
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
29
|
+
await context.router.routes()(context, next);
|
|
30
|
+
};
|
|
31
|
+
await middleware(context, nextRoute);
|
|
37
32
|
}
|
|
38
|
-
}
|
|
33
|
+
};
|
|
39
34
|
return historyMiddleware;
|
|
40
35
|
};
|
|
41
36
|
exports.default = history;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const koa_static_1 = __importDefault(require("koa-static"));
|
|
7
|
-
const MAX_AGE =
|
|
7
|
+
const MAX_AGE = 31_536_000;
|
|
8
8
|
const defaultServeStaticOptions = {
|
|
9
9
|
maxAge: MAX_AGE,
|
|
10
10
|
setHeaders: (response, filePath) => {
|
|
@@ -16,7 +16,13 @@ const defaultServeStaticOptions = {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
const statics = (baseHref, staticPath, production = false, serveStaticOptions) => {
|
|
19
|
-
const options =
|
|
19
|
+
const options = {
|
|
20
|
+
brotli: production,
|
|
21
|
+
defer: true,
|
|
22
|
+
gzip: production,
|
|
23
|
+
...defaultServeStaticOptions,
|
|
24
|
+
...serveStaticOptions
|
|
25
|
+
};
|
|
20
26
|
const staticMiddleware = (0, koa_static_1.default)(staticPath, options);
|
|
21
27
|
return staticMiddleware;
|
|
22
28
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@digest/koa",
|
|
3
3
|
"title": "Koa Digest",
|
|
4
4
|
"license": "LGPL-3.0-or-later",
|
|
5
|
-
"version": "4.14.
|
|
5
|
+
"version": "4.14.16",
|
|
6
6
|
"description": "Digested Koa configurations",
|
|
7
7
|
"author": "wallzero @wallzeroblog (http://wallzero.com)",
|
|
8
8
|
"contributors": [
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@digest/scripts": "^4.0.0",
|
|
55
|
-
"@koa/router": "^15.
|
|
55
|
+
"@koa/router": "^15.4.0",
|
|
56
56
|
"helmet": "^8.1.0",
|
|
57
|
-
"koa": "^3.1.
|
|
58
|
-
"koa-helmet": "^
|
|
57
|
+
"koa": "^3.1.2",
|
|
58
|
+
"koa-helmet": "^9.0.0",
|
|
59
59
|
"koa-history-api-fallback": "^1.0.0",
|
|
60
60
|
"koa-mount": "4.2.0",
|
|
61
61
|
"koa-remove-trailing-slashes": "^2.0.3",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/connect-history-api-fallback": "^1.5.4",
|
|
67
|
-
"@types/koa": "^3.0.
|
|
67
|
+
"@types/koa": "^3.0.2",
|
|
68
68
|
"@types/koa-mount": "^4.0.5",
|
|
69
69
|
"@types/koa-send": "^4.1.6",
|
|
70
70
|
"@types/koa-static": "^4.0.4",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"digest",
|
|
75
75
|
"koa"
|
|
76
76
|
],
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "aee0bf3ce973c772a7a29ed065a3208e80cadca1"
|
|
78
78
|
}
|