@digest/koa 4.14.4-next.1 → 4.14.5-beta.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/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.4-next.1",
5
+ "version": "4.14.5-beta.1",
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": "^13.1.0",
55
+ "@koa/router": "^15.1.1",
56
56
  "helmet": "^8.1.0",
57
- "koa": "^3.0.0",
58
- "koa-helmet": "^8.0.1",
57
+ "koa": "^3.1.1",
58
+ "koa-helmet": "^8.0.3",
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,15 +64,15 @@
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/connect-history-api-fallback": "^1.5.4",
67
- "@types/koa": "^2.15.0",
67
+ "@types/koa": "^3.0.1",
68
68
  "@types/koa-mount": "^4.0.5",
69
69
  "@types/koa-send": "^4.1.6",
70
70
  "@types/koa-static": "^4.0.4",
71
- "@types/koa__router": "^12.0.4"
71
+ "@types/koa__router": "^12.0.5"
72
72
  },
73
73
  "keywords": [
74
74
  "digest",
75
75
  "koa"
76
76
  ],
77
- "gitHead": "5c934cc91c09c63ecf91335b51d14cd861230950"
77
+ "gitHead": "a1d0041df4dd60b1d85f330e1ee9f3246330d06e"
78
78
  }
package/dist/app.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import Koa from 'koa';
2
- declare const app: Koa<Koa.DefaultState, Koa.DefaultContext>;
3
- export default app;
package/dist/app.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const routers_1 = __importDefault(require("./routers"));
7
- const server_1 = __importDefault(require("./server"));
8
- const scripts_1 = require("@digest/scripts");
9
- const koa_1 = __importDefault(require("koa"));
10
- const koa_helmet_1 = __importDefault(require("koa-helmet"));
11
- const koa_remove_trailing_slashes_1 = __importDefault(require("koa-remove-trailing-slashes"));
12
- const app = new koa_1.default();
13
- const router = (0, routers_1.default)();
14
- app.use((0, koa_helmet_1.default)()).use(router.routes()).use(router.allowedMethods()).use((0, koa_remove_trailing_slashes_1.default)());
15
- if (!scripts_1.production) {
16
- app.use(koa_helmet_1.default.contentSecurityPolicy({
17
- directives: {
18
- defaultSrc: [
19
- '\'self\'',
20
- '\'unsafe-inline\''
21
- ],
22
- upgradeInsecureRequests: null
23
- }
24
- }));
25
- }
26
- (0, server_1.default)(app);
27
- exports.default = app;
@@ -1,4 +0,0 @@
1
- import { type Options } from 'connect-history-api-fallback';
2
- import { type Middleware } from 'koa';
3
- declare const history: (baseHref?: string, options?: Options) => Middleware;
4
- export default history;
@@ -1,41 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const koa_history_api_fallback_1 = __importDefault(require("koa-history-api-fallback"));
16
- const node_path_1 = __importDefault(require("node:path"));
17
- const history = (baseHref, options) => {
18
- const ACCEPT_HEADERS = [
19
- 'text/html',
20
- 'application/xhtml+xml'
21
- ];
22
- const defaultIndex = baseHref ?
23
- node_path_1.default.join(baseHref, 'index.html') :
24
- undefined;
25
- const defaultOptions = Object.assign({ htmlAcceptHeaders: ACCEPT_HEADERS, index: defaultIndex }, options);
26
- const middleware = (0, koa_history_api_fallback_1.default)(defaultOptions);
27
- const historyMiddleware = (context, next) => __awaiter(void 0, void 0, void 0, function* () {
28
- if (context.state.history) {
29
- yield next();
30
- }
31
- else {
32
- const nextRoute = () => __awaiter(void 0, void 0, void 0, function* () {
33
- context.state.history = true;
34
- yield context.router.routes()(context, next);
35
- });
36
- yield middleware(context, nextRoute);
37
- }
38
- });
39
- return historyMiddleware;
40
- };
41
- exports.default = history;
@@ -1,3 +0,0 @@
1
- import { type Options } from 'koa-static';
2
- declare const statics: (baseHref: string, staticPath: string, production?: boolean, serveStaticOptions?: Options) => import("koa").Middleware<{}>;
3
- export default statics;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const koa_static_1 = __importDefault(require("koa-static"));
7
- const MAX_AGE = 31536000;
8
- const defaultServeStaticOptions = {
9
- maxAge: MAX_AGE,
10
- setHeaders: (response, filePath) => {
11
- if (filePath.includes('workbox.js')) {
12
- response.setHeader('Cache-Control', 'max-age=0, no-cache, no-store, must-revalidate');
13
- response.setHeader('Pragma', 'no-cache');
14
- response.setHeader('Expires', '0');
15
- }
16
- }
17
- };
18
- const statics = (baseHref, staticPath, production = false, serveStaticOptions) => {
19
- const options = Object.assign(Object.assign({ brotli: production, defer: true, gzip: production }, defaultServeStaticOptions), serveStaticOptions);
20
- const staticMiddleware = (0, koa_static_1.default)(staticPath, options);
21
- return staticMiddleware;
22
- };
23
- exports.default = statics;
@@ -1,2 +0,0 @@
1
- declare const stats: () => import("koa").Middleware;
2
- export default stats;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const koa_helmet_1 = __importDefault(require("koa-helmet"));
7
- const stats = () => {
8
- const helmetMiddleware = koa_helmet_1.default.contentSecurityPolicy({
9
- directives: {
10
- 'script-src': [
11
- '\'self\'',
12
- '\'unsafe-inline\''
13
- ]
14
- },
15
- useDefaults: true
16
- });
17
- return helmetMiddleware;
18
- };
19
- exports.default = stats;
@@ -1,3 +0,0 @@
1
- import Router from '@koa/router';
2
- declare const history: (baseHref: string) => Router<import("koa").DefaultState, import("koa").DefaultContext>;
3
- export default history;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const history_1 = __importDefault(require("../middleware/history"));
7
- const router_1 = __importDefault(require("@koa/router"));
8
- const history = (baseHref) => {
9
- const router = new router_1.default({
10
- sensitive: true,
11
- strict: true
12
- });
13
- const historyMiddleware = (0, history_1.default)(baseHref);
14
- const historyBase = '(.*)';
15
- router.get(historyBase, historyMiddleware);
16
- router.head(historyBase, historyMiddleware);
17
- router.options(historyBase, historyMiddleware);
18
- return router;
19
- };
20
- exports.default = history;
@@ -1,3 +0,0 @@
1
- import Router from '@koa/router';
2
- declare const routers: () => Router<import("koa").DefaultState, import("koa").DefaultContext>;
3
- export default routers;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const history_1 = __importDefault(require("./history"));
7
- const statics_1 = __importDefault(require("./statics"));
8
- const stats_1 = __importDefault(require("./stats"));
9
- const scripts_1 = require("@digest/scripts");
10
- const router_1 = __importDefault(require("@koa/router"));
11
- const routers = () => {
12
- const { baseHref } = scripts_1.config;
13
- const staticPath = scripts_1.config.staticPath || '';
14
- const router = new router_1.default({
15
- sensitive: true,
16
- strict: true
17
- });
18
- const statsRouter = (0, stats_1.default)();
19
- const historyRouter = (0, history_1.default)(baseHref);
20
- const staticsRouter = (0, statics_1.default)(baseHref, staticPath, scripts_1.production);
21
- router.use(baseHref, statsRouter.routes(), statsRouter.allowedMethods(), staticsRouter.routes(), staticsRouter.allowedMethods(), historyRouter.routes(), historyRouter.allowedMethods());
22
- return router;
23
- };
24
- exports.default = routers;
@@ -1,4 +0,0 @@
1
- import Router from '@koa/router';
2
- import { type Options } from 'koa-static';
3
- declare const statics: (baseHref: string, staticPath: string, production?: boolean, serveStaticOptions?: Options) => Router<import("koa").DefaultState, import("koa").DefaultContext>;
4
- export default statics;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const statics_1 = __importDefault(require("../middleware/statics"));
7
- const router_1 = __importDefault(require("@koa/router"));
8
- const koa_mount_1 = __importDefault(require("koa-mount"));
9
- const statics = (baseHref, staticPath, production = false, serveStaticOptions) => {
10
- const router = new router_1.default({
11
- sensitive: true,
12
- strict: true
13
- });
14
- const staticMiddleware = (0, statics_1.default)(baseHref, staticPath, production, serveStaticOptions);
15
- const staticBase = '(.*)';
16
- router.get(staticBase, (0, koa_mount_1.default)(baseHref, staticMiddleware));
17
- router.head(staticBase, (0, koa_mount_1.default)(baseHref, staticMiddleware));
18
- router.options(staticBase, (0, koa_mount_1.default)(baseHref, staticMiddleware));
19
- return router;
20
- };
21
- exports.default = statics;
@@ -1,3 +0,0 @@
1
- import Router from '@koa/router';
2
- declare const stats: () => Router<import("koa").DefaultState, import("koa").DefaultContext>;
3
- export default stats;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const stats_1 = __importDefault(require("../middleware/stats"));
7
- const router_1 = __importDefault(require("@koa/router"));
8
- const stats = () => {
9
- const router = new router_1.default({
10
- sensitive: true,
11
- strict: true
12
- });
13
- const statsMiddleware = (0, stats_1.default)();
14
- const statsPath = '/stats/(.*)';
15
- router.get(statsPath, statsMiddleware);
16
- router.head(statsPath, statsMiddleware);
17
- router.options(statsPath, statsMiddleware);
18
- return router;
19
- };
20
- exports.default = stats;
package/dist/server.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type Koa from 'koa';
2
- import { type Server } from 'node:http';
3
- export default function (app: Koa): Server;
package/dist/server.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const scripts_1 = require("@digest/scripts");
5
- function default_1(app) {
6
- return app.listen(scripts_1.config.appPort, scripts_1.config.appHost, () => {
7
- console.info(`Listening on http://${scripts_1.config.appHost}:${scripts_1.config.appPort}${scripts_1.config.baseHref}`);
8
- return app;
9
- });
10
- }