structured-fw 1.6.0 → 1.7.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/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,8 @@ 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";
|
|
8
|
+
import { Transform } from "node:stream";
|
|
7
9
|
export class RequestContext {
|
|
8
10
|
executionStartedAt = null;
|
|
9
11
|
executionCompletedAt = null;
|
|
@@ -69,7 +71,7 @@ export class RequestContext {
|
|
|
69
71
|
else if (data === undefined || data === null) {
|
|
70
72
|
this.sendResponse('', 'text/plain; charset=utf-8');
|
|
71
73
|
}
|
|
72
|
-
else if (data instanceof ReadStream) {
|
|
74
|
+
else if (data instanceof ReadStream || data instanceof Transform) {
|
|
73
75
|
this.streamingData = true;
|
|
74
76
|
data.once('end', () => {
|
|
75
77
|
this.response.end();
|
|
@@ -281,7 +283,7 @@ export class RequestContext {
|
|
|
281
283
|
}
|
|
282
284
|
else {
|
|
283
285
|
let staticAsset = false;
|
|
284
|
-
if (this.
|
|
286
|
+
if (this.isAsset()) {
|
|
285
287
|
const basePath = this.request.url?.startsWith('/assets/ts/') ? './' : '../';
|
|
286
288
|
const assetPath = path.resolve(basePath + this.request.url);
|
|
287
289
|
if (existsSync(assetPath)) {
|
|
@@ -319,4 +321,15 @@ export class RequestContext {
|
|
|
319
321
|
complete() {
|
|
320
322
|
return this.executionCompletedAt !== null;
|
|
321
323
|
}
|
|
324
|
+
isAsset() {
|
|
325
|
+
return this.app.config.url.staticAssets.some((pattern) => {
|
|
326
|
+
return minimatch(this.uri, pattern, {
|
|
327
|
+
nonegate: true,
|
|
328
|
+
nobrace: true,
|
|
329
|
+
noext: true,
|
|
330
|
+
nocomment: true,
|
|
331
|
+
partial: false,
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
}
|
|
322
335
|
}
|
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.1",
|
|
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/*",
|