@digest/express 4.14.4-next.1 → 4.14.5-next.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/express",
3
3
  "title": "Express Digest",
4
4
  "license": "LGPL-3.0-or-later",
5
- "version": "4.14.4-next.1",
5
+ "version": "4.14.5-next.1",
6
6
  "description": "Digested Express configurations",
7
7
  "author": "wallzero @wallzeroblog (http://wallzero.com)",
8
8
  "contributors": [
@@ -48,20 +48,20 @@
48
48
  "@digest/scripts": "^4.0.0",
49
49
  "connect-history-api-fallback": "^2.0.0",
50
50
  "connect-slashes": "^1.4.0",
51
- "express": "^5.1.0",
51
+ "express": "^5.2.1",
52
52
  "express-static-gzip": "^3.0.0",
53
53
  "helmet": "^8.1.0",
54
- "serve-static": "^2.2.0"
54
+ "serve-static": "^2.2.1"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/connect-history-api-fallback": "^1.5.4",
58
58
  "@types/connect-slashes": "^0.0.36",
59
- "@types/express": "^5.0.3",
60
- "@types/serve-static": "^1.15.8"
59
+ "@types/express": "^5.0.6",
60
+ "@types/serve-static": "^2.2.0"
61
61
  },
62
62
  "keywords": [
63
63
  "digest",
64
64
  "express"
65
65
  ],
66
- "gitHead": "5c934cc91c09c63ecf91335b51d14cd861230950"
66
+ "gitHead": "2be1836a97f894a45620d3e43ccd0205b30009fc"
67
67
  }
package/dist/app.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { type Express } from 'express';
2
- declare const app: Express;
3
- export default app;
package/dist/app.js DELETED
@@ -1,59 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- const routers_1 = __importDefault(require("./routers"));
40
- const server_1 = __importDefault(require("./server"));
41
- const scripts_1 = require("@digest/scripts");
42
- const connect_slashes_1 = __importDefault(require("connect-slashes"));
43
- const express_1 = __importDefault(require("express"));
44
- const helmet_1 = __importStar(require("helmet"));
45
- const app = (0, express_1.default)();
46
- app.use((0, helmet_1.default)(), routers_1.default, (0, connect_slashes_1.default)(false));
47
- if (!scripts_1.production) {
48
- app.use((0, helmet_1.contentSecurityPolicy)({
49
- directives: {
50
- defaultSrc: [
51
- '\'self\'',
52
- '\'unsafe-inline\''
53
- ],
54
- upgradeInsecureRequests: null
55
- }
56
- }));
57
- }
58
- (0, server_1.default)(app);
59
- exports.default = app;
@@ -1,3 +0,0 @@
1
- import { type Router } from 'express';
2
- declare const history: (baseHref?: string) => Router;
3
- export default history;
@@ -1,29 +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 connect_history_api_fallback_1 = __importDefault(require("connect-history-api-fallback"));
7
- const express_1 = require("express");
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const ACCEPT_HEADERS = [
10
- 'text/html',
11
- 'application/xhtml+xml'
12
- ];
13
- const history = (baseHref = '/') => {
14
- const router = (0, express_1.Router)({
15
- caseSensitive: true,
16
- strict: true
17
- });
18
- const defaultIndex = node_path_1.default.join(baseHref, 'index.html');
19
- const historyMiddleware = (0, connect_history_api_fallback_1.default)({
20
- htmlAcceptHeaders: ACCEPT_HEADERS,
21
- index: defaultIndex
22
- });
23
- const historyBase = '/*';
24
- router.get(historyBase, historyMiddleware);
25
- router.head(historyBase, historyMiddleware);
26
- router.options(historyBase, historyMiddleware);
27
- return router;
28
- };
29
- exports.default = history;
@@ -1,3 +0,0 @@
1
- import { type Router } from 'express';
2
- declare const routers: Router;
3
- export default routers;
@@ -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 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 express_1 = require("express");
11
- const { baseHref } = scripts_1.config;
12
- const staticPath = scripts_1.config.staticPath;
13
- const routers = (0, express_1.Router)({
14
- caseSensitive: true,
15
- strict: true
16
- });
17
- const statsRouter = (0, stats_1.default)();
18
- const historyRouter = (0, history_1.default)(baseHref);
19
- const staticsRouter = (0, statics_1.default)(baseHref, staticPath, scripts_1.production);
20
- routers.use(baseHref, statsRouter, historyRouter, staticsRouter);
21
- exports.default = routers;
@@ -1,4 +0,0 @@
1
- import { type Router } from 'express';
2
- import { type ServeStaticOptions } from 'serve-static';
3
- declare const statics: (baseHref: string, staticPath: string, production?: boolean, serveStaticOptions?: ServeStaticOptions) => Router;
4
- export default statics;
@@ -1,60 +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 express_1 = require("express");
7
- const express_static_gzip_1 = __importDefault(require("express-static-gzip"));
8
- const serve_static_1 = __importDefault(require("serve-static"));
9
- const MAX_AGE = 31536000;
10
- const defaultServeStaticOptions = {
11
- immutable: true,
12
- index: false,
13
- lastModified: false,
14
- maxAge: MAX_AGE,
15
- redirect: false,
16
- setHeaders: (response, filePath) => {
17
- if (filePath.includes('workbox.js')) {
18
- response.setHeader('Cache-Control', 'max-age=0, no-cache, no-store, must-revalidate');
19
- response.setHeader('Pragma', 'no-cache');
20
- response.setHeader('Expires', '0');
21
- }
22
- }
23
- };
24
- const removeBaseHref = (middleware, baseHref) => {
25
- return (request, response, next) => {
26
- const fixedRequest = {
27
- headers: request.headers,
28
- method: request.method,
29
- originalUrl: baseHref ?
30
- request.originalUrl.replace(baseHref, '/') :
31
- request.originalUrl,
32
- path: baseHref ?
33
- request.path.replace(baseHref, '/') :
34
- request.path,
35
- url: baseHref ?
36
- request.url.replace(baseHref, '/') :
37
- request.url
38
- };
39
- return middleware(fixedRequest, response, next);
40
- };
41
- };
42
- const statics = (baseHref, staticPath, production = false, serveStaticOptions) => {
43
- const router = (0, express_1.Router)({
44
- caseSensitive: true,
45
- strict: true
46
- });
47
- const options = Object.assign(Object.assign({}, defaultServeStaticOptions), serveStaticOptions);
48
- const staticBase = '/*';
49
- const serveStatic = removeBaseHref(production ?
50
- (0, express_static_gzip_1.default)(staticPath, {
51
- enableBrotli: true,
52
- index: false,
53
- serveStatic: options
54
- }) :
55
- (0, serve_static_1.default)(staticPath, options), baseHref);
56
- router.get(staticBase, serveStatic);
57
- router.head(staticBase, serveStatic);
58
- return router;
59
- };
60
- exports.default = statics;
@@ -1,3 +0,0 @@
1
- import { type Router } from 'express';
2
- declare const stats: () => Router;
3
- export default stats;
@@ -1,25 +0,0 @@
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/dist/server.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { type Express } from 'express';
2
- import { type Server } from 'node:http';
3
- export default function (app: Express): 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
- }