structured-fw 1.6.0 → 1.7.0
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/Config.ts
CHANGED
|
@@ -15,11 +15,11 @@ export const config: StructuredConfig = {
|
|
|
15
15
|
// setting this to false disallows the use of ClientComponent.redraw and ClientComponent.add
|
|
16
16
|
componentRender: '/componentRender',
|
|
17
17
|
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
// array of glob patterns that should be treated as static assets
|
|
19
|
+
// make sure to only include files you want to be publicly accessible
|
|
20
|
+
staticAssets: [
|
|
21
|
+
'/assets/**/*'
|
|
22
|
+
]
|
|
23
23
|
},
|
|
24
24
|
routes: {
|
|
25
25
|
path: '/app/routes'
|
|
@@ -4,6 +4,7 @@ import { Document } from "./Document.js";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { existsSync, readFileSync, ReadStream } from "node:fs";
|
|
6
6
|
import { StructuredError } from "../StructuredError.js";
|
|
7
|
+
import { minimatch } from "minimatch";
|
|
7
8
|
export class RequestContext {
|
|
8
9
|
executionStartedAt = null;
|
|
9
10
|
executionCompletedAt = null;
|
|
@@ -281,7 +282,7 @@ export class RequestContext {
|
|
|
281
282
|
}
|
|
282
283
|
else {
|
|
283
284
|
let staticAsset = false;
|
|
284
|
-
if (this.
|
|
285
|
+
if (this.isAsset()) {
|
|
285
286
|
const basePath = this.request.url?.startsWith('/assets/ts/') ? './' : '../';
|
|
286
287
|
const assetPath = path.resolve(basePath + this.request.url);
|
|
287
288
|
if (existsSync(assetPath)) {
|
|
@@ -319,4 +320,15 @@ export class RequestContext {
|
|
|
319
320
|
complete() {
|
|
320
321
|
return this.executionCompletedAt !== null;
|
|
321
322
|
}
|
|
323
|
+
isAsset() {
|
|
324
|
+
return this.app.config.url.staticAssets.some((pattern) => {
|
|
325
|
+
return minimatch(this.uri, pattern, {
|
|
326
|
+
nonegate: true,
|
|
327
|
+
nobrace: true,
|
|
328
|
+
noext: true,
|
|
329
|
+
nocomment: true,
|
|
330
|
+
partial: false,
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
}
|
|
322
334
|
}
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"type": "module",
|
|
21
21
|
"main": "build/index",
|
|
22
|
-
"version": "1.
|
|
22
|
+
"version": "1.7.0",
|
|
23
23
|
"scripts": {
|
|
24
24
|
"develop": "tsc --watch",
|
|
25
25
|
"startDev": "cd build && nodemon --watch '../app/**/*' --watch '../build/**/*' -e js,html,hbs,css index.js",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"handlebars": "^4.7.9",
|
|
40
|
-
"mime-types": "^3.0.0"
|
|
40
|
+
"mime-types": "^3.0.0",
|
|
41
|
+
"minimatch": "^10.2.5"
|
|
41
42
|
},
|
|
42
43
|
"files": [
|
|
43
44
|
"build/system/*",
|