miqro 6.2.13 → 7.0.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/README.md +9 -17
- package/build/editor.bundle.js +11601 -10129
- package/build/esm/src/bin/types.js +10 -5
- package/build/esm/src/cluster.js +1 -1
- package/build/esm/src/common/arguments.d.ts +2 -1
- package/build/esm/src/common/arguments.js +42 -18
- package/build/esm/src/common/assets.d.ts +1 -1
- package/build/esm/src/common/assets.js +34 -13
- package/build/esm/src/common/esbuild.d.ts +4 -1
- package/build/esm/src/common/esbuild.js +31 -26
- package/build/esm/src/common/exit.js +4 -4
- package/build/esm/src/common/help.d.ts +1 -1
- package/build/esm/src/common/help.js +2 -2
- package/build/esm/src/common/jsx.d.ts +2 -3
- package/build/esm/src/common/jsx.js +70 -75
- package/build/esm/src/common/paths.d.ts +0 -1
- package/build/esm/src/common/paths.js +3 -3
- package/build/esm/src/common/watch.d.ts +0 -1
- package/build/esm/src/common/watch.js +4 -1
- package/build/esm/src/inflate/inflate-sea.js +35 -24
- package/build/esm/src/inflate/inflate.js +4 -4
- package/build/esm/src/inflate/setup-auth.js +1 -1
- package/build/esm/src/inflate/setup-cors.js +1 -1
- package/build/esm/src/inflate/setup-db.js +2 -2
- package/build/esm/src/inflate/setup-error.js +1 -1
- package/build/esm/src/inflate/setup-http.js +16 -16
- package/build/esm/src/inflate/setup-log.js +1 -1
- package/build/esm/src/inflate/setup-middleware.js +1 -1
- package/build/esm/src/inflate/setup-server-config.js +1 -1
- package/build/esm/src/inflate/setup-ws.js +1 -1
- package/build/esm/src/inflate/setup.doc.d.ts +2 -2
- package/build/esm/src/inflate/setup.doc.js +23 -2
- package/build/esm/src/inflate/utils/sea-utils.js +2 -2
- package/build/esm/src/lib.d.ts +10 -1
- package/build/esm/src/lib.js +16 -1
- package/build/esm/src/main.js +2 -1
- package/build/esm/src/services/app.d.ts +1 -0
- package/build/esm/src/services/app.js +4 -5
- package/build/esm/src/services/migrations.js +2 -2
- package/build/esm/src/services/utils/jwt.d.ts +2 -0
- package/build/esm/src/services/utils/jwt.js +23 -0
- package/build/esm/src/services/utils/middleware.d.ts +9 -0
- package/build/esm/src/services/utils/middleware.js +9 -0
- package/build/esm/src/services/utils/server-interface.js +33 -4
- package/build/esm/src/types.d.ts +50 -83
- package/build/lib.cjs +15694 -15619
- package/package.json +6 -8
- package/sea/basic-compile.base64.sh +1 -1
- package/sea/basic-compile.sh +1 -1
- package/sea/install-nodejs.sh +1 -1
- package/sea/node.version.tag +1 -1
- package/.eslintrc +0 -15
- package/build/esm/editor/auth.d.ts +0 -6
- package/build/esm/editor/auth.js +0 -41
- package/build/esm/editor/common/admin-interface.d.ts +0 -36
- package/build/esm/editor/common/admin-interface.js +0 -44
- package/build/esm/editor/common/constants.d.ts +0 -4
- package/build/esm/editor/common/constants.js +0 -20
- package/build/esm/editor/common/constants.server.d.ts +0 -2
- package/build/esm/editor/common/constants.server.js +0 -4
- package/build/esm/editor/common/editor-index.d.ts +0 -2
- package/build/esm/editor/common/editor-index.js +0 -14
- package/build/esm/editor/common/html-encode.d.ts +0 -1
- package/build/esm/editor/common/html-encode.js +0 -14
- package/build/esm/editor/common/log-socket.d.ts +0 -15
- package/build/esm/editor/common/log-socket.js +0 -70
- package/build/esm/editor/common/templates.d.ts +0 -11
- package/build/esm/editor/common/templates.js +0 -477
- package/build/esm/editor/components/api-preview.d.ts +0 -11
- package/build/esm/editor/components/api-preview.js +0 -90
- package/build/esm/editor/components/editor.d.ts +0 -16
- package/build/esm/editor/components/editor.js +0 -365
- package/build/esm/editor/components/file-browser.d.ts +0 -37
- package/build/esm/editor/components/file-browser.js +0 -126
- package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
- package/build/esm/editor/components/file-editor-toolbar.js +0 -93
- package/build/esm/editor/components/file-editor.d.ts +0 -32
- package/build/esm/editor/components/file-editor.js +0 -59
- package/build/esm/editor/components/filter-query.d.ts +0 -1
- package/build/esm/editor/components/filter-query.js +0 -22
- package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
- package/build/esm/editor/components/highlight-text-area.js +0 -125
- package/build/esm/editor/components/log-viewer.d.ts +0 -6
- package/build/esm/editor/components/log-viewer.js +0 -69
- package/build/esm/editor/components/new-file.d.ts +0 -10
- package/build/esm/editor/components/new-file.js +0 -117
- package/build/esm/editor/components/scroll-query.d.ts +0 -7
- package/build/esm/editor/components/scroll-query.js +0 -21
- package/build/esm/editor/components/start-page.d.ts +0 -13
- package/build/esm/editor/components/start-page.js +0 -30
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -29
- package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -5
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -49
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -4
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -39
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +0 -26
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +0 -149
- package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js +0 -38
- package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js +0 -46
- package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js +0 -45
- package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
- package/build/esm/editor/http/admin/editor/editor.js +0 -7
- package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/index.api.js +0 -21
- package/build/esm/editor/server.d.ts +0 -3
- package/build/esm/editor/server.js +0 -49
- package/build/esm/editor/ws.d.ts +0 -3
- package/build/esm/editor/ws.js +0 -11
- package/build/esm/src/services/globals.d.ts +0 -3
- package/build/esm/src/services/globals.js +0 -182
- package/build/jsx.dom.js +0 -1587
- package/build/postject.base64.cjs +0 -1
- package/editor/auth.ts +0 -51
- package/editor/common/admin-interface.ts +0 -84
- package/editor/common/constants.server.ts +0 -5
- package/editor/common/constants.ts +0 -21
- package/editor/common/editor-index.tsx +0 -17
- package/editor/common/html-encode.ts +0 -14
- package/editor/common/log-socket.tsx +0 -85
- package/editor/common/templates.ts +0 -481
- package/editor/components/api-preview.tsx +0 -116
- package/editor/components/editor.tsx +0 -494
- package/editor/components/file-browser.tsx +0 -308
- package/editor/components/file-editor-toolbar.tsx +0 -191
- package/editor/components/file-editor.tsx +0 -122
- package/editor/components/filter-query.tsx +0 -22
- package/editor/components/highlight-text-area.tsx +0 -145
- package/editor/components/log-viewer.tsx +0 -110
- package/editor/components/new-file.tsx +0 -169
- package/editor/components/scroll-query.tsx +0 -22
- package/editor/components/start-page.tsx +0 -49
- package/editor/http/admin/editor/api/fs/delete.api.tsx +0 -32
- package/editor/http/admin/editor/api/fs/read.api.tsx +0 -55
- package/editor/http/admin/editor/api/fs/rename.api.tsx +0 -41
- package/editor/http/admin/editor/api/fs/scan.api.tsx +0 -181
- package/editor/http/admin/editor/api/fs/write.api.tsx +0 -41
- package/editor/http/admin/editor/api/server/reload.api.ts +0 -53
- package/editor/http/admin/editor/api/server/restart.api.tsx +0 -52
- package/editor/http/admin/editor/editor.tsx +0 -8
- package/editor/http/admin/editor/index.api.tsx +0 -39
- package/editor/server.ts +0 -57
- package/editor/ws.ts +0 -15
- package/sea/types.json +0 -1
- package/src/bin/compile.ts +0 -35
- package/src/bin/doc-md.ts +0 -210
- package/src/bin/generate-doc.ts +0 -64
- package/src/bin/test.ts +0 -92
- package/src/bin/types.ts +0 -29
- package/src/cluster.ts +0 -27
- package/src/common/arguments.ts +0 -733
- package/src/common/assets.ts +0 -128
- package/src/common/checksum.ts +0 -58
- package/src/common/constants.ts +0 -18
- package/src/common/content-type.ts +0 -84
- package/src/common/esbuild.ts +0 -94
- package/src/common/exit.ts +0 -91
- package/src/common/fs.ts +0 -82
- package/src/common/help.ts +0 -60
- package/src/common/jsx.ts +0 -547
- package/src/common/jwt.ts +0 -85
- package/src/common/paths.ts +0 -107
- package/src/common/watch.ts +0 -85
- package/src/inflate/inflate-sea.ts +0 -226
- package/src/inflate/inflate.ts +0 -101
- package/src/inflate/md.ts +0 -25
- package/src/inflate/setup-auth.ts +0 -41
- package/src/inflate/setup-cors.ts +0 -41
- package/src/inflate/setup-db.ts +0 -117
- package/src/inflate/setup-error.ts +0 -44
- package/src/inflate/setup-http.ts +0 -704
- package/src/inflate/setup-log.ts +0 -45
- package/src/inflate/setup-middleware.ts +0 -47
- package/src/inflate/setup-server-config.ts +0 -48
- package/src/inflate/setup-test.ts +0 -23
- package/src/inflate/setup-ws.ts +0 -50
- package/src/inflate/setup.doc.ts +0 -68
- package/src/inflate/utils/sea-utils.ts +0 -14
- package/src/lib.ts +0 -19
- package/src/main.ts +0 -100
- package/src/services/app.ts +0 -698
- package/src/services/editor.tsx +0 -101
- package/src/services/globals.ts +0 -186
- package/src/services/hot-reload.ts +0 -51
- package/src/services/migrations.ts +0 -68
- package/src/services/utils/admin-interface.ts +0 -37
- package/src/services/utils/cache.ts +0 -88
- package/src/services/utils/cluster-cache.ts +0 -230
- package/src/services/utils/cluster-ws.ts +0 -202
- package/src/services/utils/db-manager.ts +0 -92
- package/src/services/utils/get-route.ts +0 -70
- package/src/services/utils/log-transport.ts +0 -81
- package/src/services/utils/log.ts +0 -92
- package/src/services/utils/server-interface.ts +0 -92
- package/src/services/utils/websocketmanager.ts +0 -157
- package/src/types/@esbuild.d.ts +0 -1
- package/src/types/@miqro/core.d.ts +0 -2
- package/src/types/@miqro/jsx.d.ts +0 -2
- package/src/types/@miqro/parser.d.ts +0 -2
- package/src/types/@miqro/query.d.ts +0 -2
- package/src/types/@miqro/request.d.ts +0 -2
- package/src/types/@miqro/test.d.ts +0 -2
- package/src/types/@miqro.d.ts +0 -1
- package/src/types/@types.d.ts +0 -1
- package/src/types/browser.globals.d.ts +0 -1
- package/src/types/cookie.d.ts +0 -2
- package/src/types/globals.d.ts +0 -2
- package/src/types/jose.d.ts +0 -2
- package/src/types/jsx.globals.d.ts +0 -38
- package/src/types/miqro.d.ts +0 -228
- package/src/types/postject.d.ts +0 -1
- package/src/types/server.globals.d.ts +0 -47
- package/src/types.ts +0 -304
- package/tsconfig.json +0 -35
|
@@ -5,99 +5,93 @@ import { Parser } from "@miqro/parser";
|
|
|
5
5
|
import { APIRouteSchema, SessionHandlerOptionsSchema } from "@miqro/core";
|
|
6
6
|
import { cwd } from "node:process";
|
|
7
7
|
import { esBuild } from "./esbuild.js";
|
|
8
|
-
import {
|
|
9
|
-
import { getJSXJSPath, JSX_TMP_DIR } from "./paths.js";
|
|
8
|
+
import { JSX_TMP_DIR } from "./paths.js";
|
|
10
9
|
import { CLEAR_JSX_CACHE } from "./constants.js";
|
|
11
|
-
import { getAsset, initAsset, validateAsset } from "./assets.js";
|
|
12
|
-
import { calculateChecksumFromBuffer } from "./checksum.js";
|
|
13
10
|
import { HandlerWithOptionsSchema, RouteOptionsSchema } from "@miqro/core/build/types.js";
|
|
14
11
|
import { mkdirASync, rmdirASync, unlinkASync, writeFileASync } from "./fs.js";
|
|
15
12
|
let jsxJSBuffer = null; // Buffer.from(getAsset("jsx.dom.js"));
|
|
16
13
|
let jsxJSBufferChecksumPromise = null; // calculateChecksumFromBuffer(jsxJSBuffer);
|
|
17
|
-
export async function initJSXJS(logger) {
|
|
18
|
-
jsxJSBuffer = jsxJSBuffer ? jsxJSBuffer : Buffer.from(getAsset("jsx.dom.js"));
|
|
19
|
-
jsxJSBufferChecksumPromise = jsxJSBufferChecksumPromise ? jsxJSBufferChecksumPromise : calculateChecksumFromBuffer(jsxJSBuffer);
|
|
20
|
-
return initAsset(logger, getJSXJSPath(), jsxJSBuffer, true, jsxJSBufferChecksumPromise, false);
|
|
21
|
-
}
|
|
22
|
-
export async function validateJSXJS(logger) {
|
|
23
|
-
const checksum = await jsxJSBufferChecksumPromise;
|
|
24
|
-
if (!checksum) {
|
|
25
|
-
throw new Error("error calculating checksum");
|
|
26
|
-
}
|
|
27
|
-
return validateAsset(logger, getJSXJSPath(), checksum);
|
|
28
|
-
}
|
|
29
14
|
const parser = new Parser();
|
|
30
15
|
const DEFAULT_ESOPTION = {
|
|
31
16
|
platform: "neutral",
|
|
17
|
+
mainFields: "module,main",
|
|
18
|
+
// platform: "node",
|
|
32
19
|
bundle: true,
|
|
33
20
|
jsxFactory: "JSX.createElement",
|
|
34
21
|
jsxFragment: "JSX.Fragment"
|
|
35
22
|
};
|
|
23
|
+
function JSXTemplate(inFile /*, jsxPath: string | false = false*/, useExport = true) {
|
|
24
|
+
// const PRE = ``;
|
|
25
|
+
// return `${jsxPath ? PRE : ""}\n${useExport ? `export * from "${inFile}";import * as lib from "${inFile}";export default lib.default;` : `import * as lib from "${inFile}"`}`;
|
|
26
|
+
return `${useExport ? `export * from "${inFile}";import * as lib from "${inFile}";export default lib.default;` : `import * as lib from "${inFile}"`}`;
|
|
27
|
+
}
|
|
36
28
|
export async function inflateJSX(inFile, options) {
|
|
37
29
|
const tmpBuildDir = resolve(JSX_TMP_DIR, String(process.pid), "build", Date.now() + "-" + randomUUID());
|
|
38
30
|
const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
|
|
39
|
-
const jsxJSPath = getJSXJSPath()
|
|
31
|
+
//const jsxJSPath = getJSXJSPath();//resolve(tmpBuildDir, "jsx.js");
|
|
40
32
|
const logger = options.logger; //getLogger(`${SERVER_IDENTIFIER}_JSX`);
|
|
41
33
|
try {
|
|
42
|
-
if (!options.embemedJSX) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
await mkdirASync(tmpBuildDir, {
|
|
64
|
-
recursive: true
|
|
65
|
-
});
|
|
66
|
-
//await writeFileASync(jsxJSPath, Buffer.from(getAsset("jsx-dom-bundle")));
|
|
67
|
-
await writeFileASync(inFileTmp, browserJSXGlobals(inFile, jsxJSPath));
|
|
68
|
-
//await writeFileASync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), relative(tmpBuildDir, jsxJSPath)));
|
|
69
|
-
logger?.trace("inflating [%s] from [%s] with jsx.js embedded. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
70
|
-
const { outputFiles: [{ contents }] } = await esBuild({
|
|
71
|
-
...DEFAULT_ESOPTION,
|
|
72
|
-
entryPoints: [inFileTmp],
|
|
73
|
-
minify: options.minify,
|
|
74
|
-
platform: options.platform ? options.platform : DEFAULT_ESOPTION.platform
|
|
75
|
-
});
|
|
76
|
-
if (CLEAR_JSX_CACHE) {
|
|
77
|
-
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
78
|
-
await unlinkASync(inFileTmp);
|
|
79
|
-
//await unlinkASync(jsxJSPath);
|
|
80
|
-
await rmdirASync(tmpBuildDir);
|
|
81
|
-
}
|
|
82
|
-
return contents;
|
|
34
|
+
// if (!options.embemedJSX) {
|
|
35
|
+
await mkdirASync(tmpBuildDir, {
|
|
36
|
+
recursive: true
|
|
37
|
+
});
|
|
38
|
+
await writeFileASync(inFileTmp, JSXTemplate(inFile /*, false*/, options.useExport));
|
|
39
|
+
//await writeFileASync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), false));
|
|
40
|
+
logger?.trace("inflating [%s] from [%s]. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
41
|
+
const { outputFiles: [{ contents }] } = await esBuild({
|
|
42
|
+
...DEFAULT_ESOPTION,
|
|
43
|
+
entryPoints: [inFileTmp],
|
|
44
|
+
minify: options.minify,
|
|
45
|
+
platform: options.platform !== undefined ? options.platform : DEFAULT_ESOPTION.platform,
|
|
46
|
+
mainFields: options.mainFields !== undefined ? options.mainFields : DEFAULT_ESOPTION.mainFields,
|
|
47
|
+
external: options.external ? options.external : undefined,
|
|
48
|
+
});
|
|
49
|
+
if (CLEAR_JSX_CACHE) {
|
|
50
|
+
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
51
|
+
await unlinkASync(inFileTmp);
|
|
52
|
+
await rmdirASync(tmpBuildDir);
|
|
83
53
|
}
|
|
54
|
+
return contents;
|
|
55
|
+
/*} else {
|
|
56
|
+
await mkdirASync(tmpBuildDir, {
|
|
57
|
+
recursive: true
|
|
58
|
+
});
|
|
59
|
+
//await writeFileASync(jsxJSPath, Buffer.from(getAsset("jsx-dom-bundle")));
|
|
60
|
+
await writeFileASync(inFileTmp, browserJSXGlobals(inFile, false));
|
|
61
|
+
//await writeFileASync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), relative(tmpBuildDir, jsxJSPath)));
|
|
62
|
+
logger?.trace("inflating [%s] from [%s] with jsx.js embedded. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
63
|
+
const { outputFiles: [{ contents }] } = await esBuild({
|
|
64
|
+
...DEFAULT_ESOPTION,
|
|
65
|
+
entryPoints: [inFileTmp],
|
|
66
|
+
minify: options.minify,
|
|
67
|
+
platform: options.platform !== undefined ? options.platform : DEFAULT_ESOPTION.platform,
|
|
68
|
+
mainFields: options.mainFields !== undefined ? options.mainFields : DEFAULT_ESOPTION.mainFields,
|
|
69
|
+
external: options.external ? options.external : undefined
|
|
70
|
+
});
|
|
71
|
+
if (CLEAR_JSX_CACHE) {
|
|
72
|
+
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
73
|
+
await unlinkASync(inFileTmp);
|
|
74
|
+
//await unlinkASync(jsxJSPath);
|
|
75
|
+
await rmdirASync(tmpBuildDir);
|
|
76
|
+
}
|
|
77
|
+
return contents;
|
|
78
|
+
}*/
|
|
84
79
|
}
|
|
85
80
|
catch (e) {
|
|
86
81
|
logger?.error("error with: " + inFile);
|
|
87
82
|
logger?.error(e);
|
|
88
|
-
if (options.embemedJSX) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
83
|
+
/*if (options.embemedJSX) {
|
|
84
|
+
if (CLEAR_JSX_CACHE) {
|
|
85
|
+
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
86
|
+
await unlinkASync(inFileTmp);
|
|
87
|
+
//await unlinkASync(jsxJSPath);
|
|
88
|
+
await rmdirASync(tmpBuildDir);
|
|
89
|
+
} else {
|
|
90
|
+
//console.error("errors on: " + tmpBuildDir);
|
|
91
|
+
logger?.error("error with: %s", inFileTmp);
|
|
92
|
+
logger?.trace("NOT clearing cache. to change this behaivor set CLEAR_JSX_CACHE to 1", tmpBuildDir);
|
|
93
|
+
}
|
|
94
|
+
}*/
|
|
101
95
|
throw e;
|
|
102
96
|
}
|
|
103
97
|
}
|
|
@@ -417,14 +411,14 @@ export async function importServerConfigModule(inFile, logger) {
|
|
|
417
411
|
}
|
|
418
412
|
export async function importJSXFile(inFile, logger) {
|
|
419
413
|
const inflatedCode = await inflateJSX(inFile, {
|
|
420
|
-
embemedJSX: false,
|
|
414
|
+
// embemedJSX: false,
|
|
421
415
|
minify: false,
|
|
422
416
|
useExport: true,
|
|
423
417
|
platform: "node",
|
|
424
418
|
logger
|
|
425
419
|
});
|
|
426
420
|
const tmpBuildDir = resolve(JSX_TMP_DIR, String(process.pid), "import", Date.now() + "-" + randomUUID());
|
|
427
|
-
//const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
|
|
421
|
+
// const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
|
|
428
422
|
const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".cjs");
|
|
429
423
|
//const logger = getLogger(`${SERVER_IDENTIFIER}_JSX`);
|
|
430
424
|
await mkdirASync(tmpBuildDir, {
|
|
@@ -432,11 +426,12 @@ export async function importJSXFile(inFile, logger) {
|
|
|
432
426
|
});
|
|
433
427
|
try {
|
|
434
428
|
await writeFileASync(inFileTmp, inflatedCode);
|
|
435
|
-
assertGlobalTampered();
|
|
429
|
+
// assertGlobalTampered();
|
|
436
430
|
logger?.trace("importing [%s] from [%s]. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
437
431
|
logger?.debug("importing [%s]", relative(cwd(), inFile));
|
|
438
432
|
const module = await import(resolve(inFileTmp));
|
|
439
|
-
|
|
433
|
+
// console.dir(module);
|
|
434
|
+
// assertGlobalTampered();
|
|
440
435
|
if (CLEAR_JSX_CACHE) {
|
|
441
436
|
logger?.trace("clearing cache at [%s]. to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
442
437
|
await unlinkASync(inFileTmp);
|
|
@@ -15,4 +15,3 @@ export declare function getAuthConfigPath(servicePath: string): string | false;
|
|
|
15
15
|
export declare function getHTTPRouterPath(servicePath: string): string | false;
|
|
16
16
|
export declare function getMigrationsPath(servicePath: string): string | false;
|
|
17
17
|
export declare function getESBuildBinaryPath(): string;
|
|
18
|
-
export declare function getJSXJSPath(): string;
|
|
@@ -82,6 +82,6 @@ export function getESBuildBinaryPath() {
|
|
|
82
82
|
return resolve(JSX_TMP_DIR, String(process.pid), "esbuild");
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
export function getJSXJSPath() {
|
|
86
|
-
|
|
87
|
-
}
|
|
85
|
+
/*export function getJSXJSPath() {
|
|
86
|
+
return resolve(JSX_TMP_DIR, String(process.pid), "jsx.js");
|
|
87
|
+
}*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../services/globals.js";
|
|
1
|
+
//import "../services/globals.js";
|
|
2
2
|
import { existsSync, readdirSync, statSync, watch } from "node:fs";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
export async function watchAndServer(app) {
|
|
@@ -43,6 +43,7 @@ export async function watchAndServer(app) {
|
|
|
43
43
|
}, 2000);
|
|
44
44
|
}
|
|
45
45
|
function watchDir(toWatch) {
|
|
46
|
+
clearTimeout(timeout);
|
|
46
47
|
const files = existsSync(toWatch) ? readdirSync(toWatch) : [];
|
|
47
48
|
for (const file of files) {
|
|
48
49
|
const filePath = resolve(toWatch, file);
|
|
@@ -56,6 +57,7 @@ export async function watchAndServer(app) {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
function stopWatch() {
|
|
60
|
+
clearTimeout(timeout);
|
|
59
61
|
const toClose = watchers.splice(0, watchers.length);
|
|
60
62
|
for (const watcher of toClose) {
|
|
61
63
|
watcher.close();
|
|
@@ -63,6 +65,7 @@ export async function watchAndServer(app) {
|
|
|
63
65
|
}
|
|
64
66
|
function reWatch() {
|
|
65
67
|
stopWatch();
|
|
68
|
+
clearTimeout(timeout);
|
|
66
69
|
for (const service of app.options.services) {
|
|
67
70
|
const toWatch = resolve(process.cwd(), service);
|
|
68
71
|
watchDir(toWatch);
|
|
@@ -24,7 +24,7 @@ export async function inflateSeaAssets(logger, inflateDir) {
|
|
|
24
24
|
writeFile(logger, resolve(inflateDir, "sea", "esbuild"), esbuildBinaryBuffer);
|
|
25
25
|
chmodSync(resolve(inflateDir, "sea", "esbuild"), constants.S_IXUSR | constants.S_IRUSR | constants.S_IWUSR);
|
|
26
26
|
}
|
|
27
|
-
writeFile(logger, resolve(inflateDir, "sea", "postject.cjs"), Buffer.from(Buffer.from(getAsset("postject.base64.cjs")).toString(), "base64"));
|
|
27
|
+
// writeFile(logger, resolve(inflateDir, "sea", "postject.cjs"), Buffer.from(Buffer.from(getAsset("postject.base64.cjs")).toString(), "base64"));
|
|
28
28
|
writeFile(logger, resolve(inflateDir, "sea", "config.json"), Buffer.from(getAsset("sea.basic.config.json")));
|
|
29
29
|
writeFile(logger, resolve(inflateDir, "sea", "run.sh"), Buffer.from(getAsset("app.sh")));
|
|
30
30
|
writeFile(logger, resolve(inflateDir, "sea", "node.sh"), Buffer.from(getAsset("node.sh")));
|
|
@@ -38,16 +38,16 @@ export async function inflateAppForSea(logger, inflateDir, services, port) {
|
|
|
38
38
|
inflateSeaAssets(logger, inflateDir);
|
|
39
39
|
writeFile(logger, resolve(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
|
|
40
40
|
const WSLIST = services.filter(service => getWSConfigPath(resolve(cwd(), service))).map(service => {
|
|
41
|
-
return `(await
|
|
41
|
+
return `(await require("../${service}/ws.cjs")).default`;
|
|
42
42
|
}).join(",");
|
|
43
43
|
const SERVERCONFIGLIST = services.filter(service => getServerConfigPath(resolve(cwd(), service))).map(service => {
|
|
44
|
-
return `(await
|
|
44
|
+
return `(await require("../${service}/server.cjs")).default`;
|
|
45
45
|
}).join(",\n");
|
|
46
46
|
const DBCONFIGLIST = services.filter(service => getDBConfigPath(resolve(cwd(), service))).map(service => {
|
|
47
47
|
return `new Promise(async (resolve, reject) => {
|
|
48
48
|
try {
|
|
49
|
-
const db = await dbManager.setupDB((await
|
|
50
|
-
await (await
|
|
49
|
+
const db = await dbManager.setupDB((await require("../${service}/db.cjs")).default);
|
|
50
|
+
await (await require("./${service}/migration-up.cjs")).runMigrations(db);
|
|
51
51
|
resolve();
|
|
52
52
|
} catch(e) {
|
|
53
53
|
reject(e);
|
|
@@ -56,7 +56,7 @@ export async function inflateAppForSea(logger, inflateDir, services, port) {
|
|
|
56
56
|
})`;
|
|
57
57
|
}).join(",");
|
|
58
58
|
writeFile(logger, join(inflateDir, "sea", "package.json"), `{ "type": "module", "private": true }`);
|
|
59
|
-
writeFile(logger, join(inflateDir, "sea", "app.cjs"), `const { createServerInterface, ServerRequestHandler, WebSocketManager,
|
|
59
|
+
writeFile(logger, join(inflateDir, "sea", "app.cjs"), `const { createServerInterface, ServerRequestHandler, WebSocketManager, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
|
|
60
60
|
|
|
61
61
|
async function main() {
|
|
62
62
|
const PORT = "${PORT}";
|
|
@@ -65,7 +65,6 @@ async function main() {
|
|
|
65
65
|
const cache = new ClusterCache();
|
|
66
66
|
const webSocketManager = new WebSocketManager();
|
|
67
67
|
const dbManager = new DBManager();
|
|
68
|
-
await initGlobals();
|
|
69
68
|
const serverInterface = createServerInterface({
|
|
70
69
|
cache,
|
|
71
70
|
localCache,
|
|
@@ -85,7 +84,7 @@ async function main() {
|
|
|
85
84
|
${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.preload).map(config=>config.preload(serverInterface)));\n` : ""}
|
|
86
85
|
app.use(ServerRequestHandler(serverInterface));
|
|
87
86
|
app.use(LoggerHandler());
|
|
88
|
-
${services.map(service => `app.use(await (await
|
|
87
|
+
${services.map(service => `app.use(await (await require("./${join(service, "router.cjs")}")).setupRouter());`).join("\n")}
|
|
89
88
|
${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.load).map(config=>config.load(serverInterface)));\n` : ""}
|
|
90
89
|
|
|
91
90
|
await app.listen(PORT);
|
|
@@ -112,20 +111,20 @@ main().catch(e=>console.error(e));
|
|
|
112
111
|
export async function inflateServiceForSea(logger, inflateDir, service, servicePath /*, serviceMigrations: string[]*/, serviceRouteFileMap, serviceStaticFileMap) {
|
|
113
112
|
const migrationsFolderPath = getMigrationsPath(servicePath);
|
|
114
113
|
const serviceMigrations = migrationsFolderPath ? migration.getSortedMigrations(migrationsFolderPath) : [];
|
|
115
|
-
writeFile(logger, join(inflateDir, "sea", service, "router.
|
|
116
|
-
|
|
114
|
+
writeFile(logger, join(inflateDir, "sea", service, "router.cjs"), `const { appendAPIModule, Router, middleware } = require("./../lib.cjs");\n
|
|
115
|
+
async function setupRouter() {
|
|
117
116
|
const router = new Router();
|
|
118
117
|
${getErrorConfigPath(servicePath) ? `
|
|
119
|
-
const errorConfig = (await
|
|
118
|
+
const errorConfig = (await require("../../${service}/catch.cjs")).default;
|
|
120
119
|
if(errorConfig && errorConfig.catch) {
|
|
121
120
|
for(const m of errorConfig.catch) {
|
|
122
121
|
router.catch(m);
|
|
123
122
|
}
|
|
124
123
|
}` : ""}
|
|
125
|
-
${getCORSConfigPath(servicePath) ? ` router.use(
|
|
126
|
-
${getAuthConfigPath(servicePath) ? ` router.use(
|
|
124
|
+
${getCORSConfigPath(servicePath) ? ` router.use(middleware.cors((await require("../../${service}/cors.cjs")).default));` : ""}
|
|
125
|
+
${getAuthConfigPath(servicePath) ? ` router.use(middleware.session((await require("../../${service}/auth.cjs")).default));` : ""}
|
|
127
126
|
${getMiddlewareConfigPath(servicePath) ? `
|
|
128
|
-
const middlewareConfig = (await
|
|
127
|
+
const middlewareConfig = (await require("../../${service}/middleware.cjs")).default;
|
|
129
128
|
if(middlewareConfig && middlewareConfig.middleware) {
|
|
130
129
|
for(const m of middlewareConfig.middleware) {
|
|
131
130
|
router.use(m);
|
|
@@ -139,14 +138,14 @@ ${Object.keys(serviceRouteFileMap)
|
|
|
139
138
|
if (rPath) {
|
|
140
139
|
const rPathExt = extname(rPath);
|
|
141
140
|
const apiInflatedPath = join("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".cjs");
|
|
142
|
-
return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await
|
|
141
|
+
return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await require("./${apiInflatedPath}")).default);`;
|
|
143
142
|
}
|
|
144
143
|
else {
|
|
145
144
|
return "";
|
|
146
145
|
}
|
|
147
146
|
}).filter(l => l)[0])
|
|
148
147
|
.join("\n")}
|
|
149
|
-
router.use(await (await
|
|
148
|
+
router.use(await (await require("./static-router.cjs")).setupRouter())
|
|
150
149
|
|
|
151
150
|
${getMiddlewareConfigPath(servicePath) ? `
|
|
152
151
|
if(middlewareConfig && middlewareConfig.post) {
|
|
@@ -156,29 +155,38 @@ ${getMiddlewareConfigPath(servicePath) ? `
|
|
|
156
155
|
}` : ""}
|
|
157
156
|
|
|
158
157
|
return router;
|
|
158
|
+
}
|
|
159
|
+
module.exports = {
|
|
160
|
+
setupRouter
|
|
159
161
|
}`);
|
|
160
|
-
writeFile(logger, join(inflateDir, "sea", service, "migration-up.
|
|
161
|
-
|
|
162
|
+
writeFile(logger, join(inflateDir, "sea", service, "migration-up.cjs"), `const { migration } = require("./../lib.cjs");\n
|
|
163
|
+
async function runMigrations(db) {
|
|
162
164
|
await migration.init(db);
|
|
163
165
|
${serviceMigrations.map(file => {
|
|
164
166
|
const name = `${file.substring(0, file.length - extname(file).length)}`;
|
|
165
|
-
return ` await migration.up.module(db, "${file}", (await
|
|
167
|
+
return ` await migration.up.module(db, "${file}", (await require("../../${service}/migration/${name}.cjs")).default)`;
|
|
166
168
|
}).join("\n")}
|
|
169
|
+
}
|
|
170
|
+
module.exports = {
|
|
171
|
+
runMigrations
|
|
167
172
|
}`);
|
|
168
|
-
writeFile(logger, join(inflateDir, "sea", service, "migration-down.
|
|
169
|
-
|
|
173
|
+
writeFile(logger, join(inflateDir, "sea", service, "migration-down.cjs"), `const { migration } = require("./../lib.cjs");\n
|
|
174
|
+
async function runMigrations(db) {
|
|
170
175
|
await migration.init(db);
|
|
171
176
|
${serviceMigrations.reverse().map(file => {
|
|
172
177
|
const name = `${file.substring(0, file.length - extname(file).length)}`;
|
|
173
|
-
return ` await migration.down.module(db, "${file}", (await
|
|
178
|
+
return ` await migration.down.module(db, "${file}", (await require("../../${service}/migration/${name}.cjs")).default)`;
|
|
174
179
|
}).join("\n")}
|
|
180
|
+
}
|
|
181
|
+
module.exports = {
|
|
182
|
+
runMigrations
|
|
175
183
|
}`);
|
|
176
184
|
const staticFiles = Object.keys(serviceStaticFileMap);
|
|
177
185
|
/*if (staticFiles.length !== 0) {
|
|
178
186
|
writeFile(logger, join(inflateDir, "sea", service, "static.base64.json"), JSON.stringify(serviceStaticFileMap));
|
|
179
187
|
}*/
|
|
180
|
-
writeFile(logger, join(inflateDir, "sea", service, "static-router.
|
|
181
|
-
|
|
188
|
+
writeFile(logger, join(inflateDir, "sea", service, "static-router.cjs"), `const { appendAPIModule, Router } = require("./../lib.cjs");\n
|
|
189
|
+
async function setupRouter() {
|
|
182
190
|
const router = new Router();
|
|
183
191
|
${staticFiles.length === 0 ? "" : `
|
|
184
192
|
${staticFiles.map((filePath) => {
|
|
@@ -194,6 +202,9 @@ ${staticFiles.map((filePath) => {
|
|
|
194
202
|
}).join("\n")}
|
|
195
203
|
`}
|
|
196
204
|
return router;
|
|
205
|
+
}
|
|
206
|
+
module.exports = {
|
|
207
|
+
setupRouter
|
|
197
208
|
}`);
|
|
198
209
|
}
|
|
199
210
|
function writeFile(logger, path, buffer) {
|
|
@@ -2,7 +2,7 @@ import { Router } from "@miqro/core";
|
|
|
2
2
|
import { setupHTTPRouter } from "./setup-http.js";
|
|
3
3
|
//import { WSMapConfig } from "./utils/websocketmanager.js";
|
|
4
4
|
//import { ServerConfigMap, setupServerConfig } from "./setup-server-config.js";
|
|
5
|
-
import { assertGlobalTampered } from "../services/globals.js";
|
|
5
|
+
// import { assertGlobalTampered } from "../services/globals.js";
|
|
6
6
|
import { getServicePath } from "../common/paths.js";
|
|
7
7
|
import { inflateWSConfig } from "./setup-ws.js";
|
|
8
8
|
import { inflateAppForSea, inflateServiceForSea } from "./inflate-sea.js";
|
|
@@ -17,7 +17,7 @@ export async function inflateApp({ inflateParallel, serverInterface, logger, hot
|
|
|
17
17
|
const router = new Router();
|
|
18
18
|
const logConfigMap = {};
|
|
19
19
|
//const serverConfigMap: ServerConfigMap = {};
|
|
20
|
-
router.use(assertGlobalTampered);
|
|
20
|
+
// router.use(assertGlobalTampered);
|
|
21
21
|
/*if (editor) {
|
|
22
22
|
logger.info("setting up editor on %s", BASEEDITOR_PATH);
|
|
23
23
|
const editorRouter = await createEditorRouter();
|
|
@@ -48,7 +48,7 @@ export async function inflateApp({ inflateParallel, serverInterface, logger, hot
|
|
|
48
48
|
...routeFileMap,
|
|
49
49
|
...serviceRouteFileMap
|
|
50
50
|
};
|
|
51
|
-
await setupDoc(logger, servicePath, service, router, routeFileMap, inflateDir, errors);
|
|
51
|
+
await setupDoc(logger, servicePath, service, router, routeFileMap, serviceStaticFileMap, inflateDir, errors);
|
|
52
52
|
await inflateWSConfig(logger, servicePath, service, wsConfigList, inflateSea ? inflateDir : undefined, errors);
|
|
53
53
|
//await setupServerConfig(logger, servicePath, service, serverConfigMap, inflateSea ? inflateDir : undefined, errors);
|
|
54
54
|
if (inflateDir && inflateSea) {
|
|
@@ -61,6 +61,6 @@ export async function inflateApp({ inflateParallel, serverInterface, logger, hot
|
|
|
61
61
|
if (inflateDir && inflateSea) {
|
|
62
62
|
await inflateAppForSea(logger, inflateDir, services, port);
|
|
63
63
|
}
|
|
64
|
-
router.use(assertGlobalTampered);
|
|
64
|
+
// router.use(assertGlobalTampered);
|
|
65
65
|
return errors.length === 0 ? [router, null, routeFileMap /*, migrations*/, wsConfigList /*, serverConfigMap*/, logConfigMap] : [router, errors, routeFileMap /*, migrations*/, wsConfigList /*, serverConfigMap*/, logConfigMap];
|
|
66
66
|
}
|
|
@@ -18,7 +18,7 @@ export async function setupAUTH(logger, servicePath, service, mainRouter, inflat
|
|
|
18
18
|
});
|
|
19
19
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
20
20
|
writeFileSync(inflatePath, await inflateJSX(authPath, {
|
|
21
|
-
embemedJSX: false,
|
|
21
|
+
// embemedJSX: false,
|
|
22
22
|
minify: false,
|
|
23
23
|
useExport: true,
|
|
24
24
|
platform: "node",
|
|
@@ -18,7 +18,7 @@ export async function setupCORS(logger, servicePath, service, mainRouter, inflat
|
|
|
18
18
|
});
|
|
19
19
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
20
20
|
writeFileSync(inflatePath, await inflateJSX(corsPath, {
|
|
21
|
-
embemedJSX: false,
|
|
21
|
+
// embemedJSX: false,
|
|
22
22
|
minify: false,
|
|
23
23
|
useExport: true,
|
|
24
24
|
platform: "node",
|
|
@@ -28,7 +28,7 @@ export async function inflateDBConfig(logger, service, dbConfigList, inflateDir,
|
|
|
28
28
|
});
|
|
29
29
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
30
30
|
writeFileSync(inflatePath, await inflateJSX(dbConfigPath, {
|
|
31
|
-
embemedJSX: false,
|
|
31
|
+
// embemedJSX: false,
|
|
32
32
|
minify: false,
|
|
33
33
|
useExport: true,
|
|
34
34
|
platform: "node",
|
|
@@ -76,7 +76,7 @@ export async function inflateDBMigrations(logger, service, dbName, inflateDir, e
|
|
|
76
76
|
});
|
|
77
77
|
logger?.log("writing [%s]", relative(cwd(), inflatePath));
|
|
78
78
|
writeFileSync(inflatePath, await inflateJSX(resolve(migrationsFolderPath, migrationName), {
|
|
79
|
-
embemedJSX: false,
|
|
79
|
+
// embemedJSX: false,
|
|
80
80
|
minify: false,
|
|
81
81
|
useExport: true,
|
|
82
82
|
platform: "node",
|
|
@@ -21,7 +21,7 @@ export async function setupError(logger, servicePath, service, mainRouter, infla
|
|
|
21
21
|
});
|
|
22
22
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
23
23
|
writeFileSync(inflatePath, await inflateJSX(errorPath, {
|
|
24
|
-
embemedJSX: false,
|
|
24
|
+
// embemedJSX: false,
|
|
25
25
|
minify: false,
|
|
26
26
|
useExport: true,
|
|
27
27
|
platform: "node",
|
|
@@ -6,7 +6,7 @@ import { importHTMLModule, importAPIRoute, inflateJSX, importJSONModule, jsx2HTM
|
|
|
6
6
|
import { createNodeRuntime } from "@miqro/jsx-node";
|
|
7
7
|
import { getHotReloadScript } from "../services/hot-reload.js";
|
|
8
8
|
import { cwd } from "node:process";
|
|
9
|
-
import { assertGlobalTampered } from "../services/globals.js";
|
|
9
|
+
// import { assertGlobalTampered } from "../services/globals.js";
|
|
10
10
|
import { getHTTPRouterPath, getStaticFilesPath } from "../common/paths.js";
|
|
11
11
|
import { setupCORS } from "./setup-cors.js";
|
|
12
12
|
import { setupAUTH } from "./setup-auth.js";
|
|
@@ -84,7 +84,7 @@ async function createStaticRoute(service, logger, router, dir, file, inflateDir,
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
router.use(assertGlobalTampered);
|
|
87
|
+
// router.use(assertGlobalTampered);
|
|
88
88
|
router.get(path, async function (_req, res) {
|
|
89
89
|
await new Promise((resolve, reject) => {
|
|
90
90
|
try {
|
|
@@ -145,7 +145,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
145
145
|
const maxParallel = inflateParallel ? inflateParallel : 1;
|
|
146
146
|
server.logger.debug("loading http directory with parallel [%s]", maxParallel);
|
|
147
147
|
let tR = [];
|
|
148
|
-
router.use(assertGlobalTampered);
|
|
148
|
+
// router.use(assertGlobalTampered);
|
|
149
149
|
const files = scanFiles(dir);
|
|
150
150
|
for (const file of files) {
|
|
151
151
|
tR.push(new Promise(async (resolve) => {
|
|
@@ -172,7 +172,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
172
172
|
previewMethod: "api"
|
|
173
173
|
};
|
|
174
174
|
const inflatedCode = inflateDir ? await inflateJSX(file.filePath, {
|
|
175
|
-
embemedJSX: false,
|
|
175
|
+
// embemedJSX: false,
|
|
176
176
|
minify: false,
|
|
177
177
|
useExport: true,
|
|
178
178
|
platform: "node",
|
|
@@ -197,7 +197,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
197
197
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
198
198
|
await writeFileASync(inflatePath, inflatedCode);
|
|
199
199
|
}
|
|
200
|
-
router.use(assertGlobalTampered);
|
|
200
|
+
// router.use(assertGlobalTampered);
|
|
201
201
|
router.use(module.handler, r.path, r.method, r.options);
|
|
202
202
|
}
|
|
203
203
|
return resolve();
|
|
@@ -243,7 +243,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
router.use(assertGlobalTampered);
|
|
246
|
+
// router.use(assertGlobalTampered);
|
|
247
247
|
router.use(async function (req, res) {
|
|
248
248
|
const JSON = await getJSON(req, res, newURL(req.path), module.apiOptions?.basePath, module.default);
|
|
249
249
|
return res.asyncEnd({
|
|
@@ -298,7 +298,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
-
router.use(assertGlobalTampered);
|
|
301
|
+
// router.use(assertGlobalTampered);
|
|
302
302
|
router.use(async function (req, res) {
|
|
303
303
|
const toRender = typeof module.default === "function" ? module.default(req, res) : module.default;
|
|
304
304
|
const HTML = await getHTML(hotreload, req, res, newURL(req.path), module.apiOptions?.basePath, await toRender);
|
|
@@ -319,9 +319,9 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
319
319
|
// allow fall-through when extension is .js and .ts because is a static route without embemedJSX
|
|
320
320
|
if (file.ext !== ".js" && file.ext !== ".ts") {
|
|
321
321
|
const code = await inflateJSX(file.filePath, {
|
|
322
|
-
embemedJSX: true,
|
|
322
|
+
// embemedJSX: true,
|
|
323
323
|
minify: file.subExt === ".min" ? true : false,
|
|
324
|
-
useExport:
|
|
324
|
+
useExport: true,
|
|
325
325
|
logger
|
|
326
326
|
});
|
|
327
327
|
const contentType = CONTENT_TYPE_MAP[".js"];
|
|
@@ -354,7 +354,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
354
354
|
};
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
|
-
router.use(assertGlobalTampered);
|
|
357
|
+
// router.use(assertGlobalTampered);
|
|
358
358
|
router.get(path, async function (req, res) {
|
|
359
359
|
return res.asyncEnd({
|
|
360
360
|
status: 200,
|
|
@@ -403,7 +403,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
403
403
|
};
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
router.use(assertGlobalTampered);
|
|
406
|
+
// router.use(assertGlobalTampered);
|
|
407
407
|
router.get(path, async function (_req, res) {
|
|
408
408
|
res.asyncEnd({
|
|
409
409
|
status: 200,
|
|
@@ -427,9 +427,9 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
427
427
|
case ".bundle":
|
|
428
428
|
case ".min": {
|
|
429
429
|
const code = await inflateJSX(file.filePath, {
|
|
430
|
-
embemedJSX: false,
|
|
430
|
+
// embemedJSX: false,
|
|
431
431
|
minify: file.subExt === ".min" ? true : false,
|
|
432
|
-
useExport:
|
|
432
|
+
useExport: true,
|
|
433
433
|
logger
|
|
434
434
|
});
|
|
435
435
|
const contentType = CONTENT_TYPE_MAP[".js"];
|
|
@@ -462,7 +462,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
462
462
|
};
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
|
-
router.use(assertGlobalTampered);
|
|
465
|
+
// router.use(assertGlobalTampered);
|
|
466
466
|
router.get(path, async function (_req, res) {
|
|
467
467
|
res.asyncEnd({
|
|
468
468
|
status: 200,
|
|
@@ -519,7 +519,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
519
519
|
};
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
-
router.use(assertGlobalTampered);
|
|
522
|
+
// router.use(assertGlobalTampered);
|
|
523
523
|
router.get(path, async function (_req, res) {
|
|
524
524
|
res.asyncEnd({
|
|
525
525
|
status: 200,
|
|
@@ -558,7 +558,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
558
558
|
await Promise.all(tR);
|
|
559
559
|
tR = [];
|
|
560
560
|
}
|
|
561
|
-
router.use(assertGlobalTampered);
|
|
561
|
+
// router.use(assertGlobalTampered);
|
|
562
562
|
return {
|
|
563
563
|
routeFileMap,
|
|
564
564
|
router,
|
|
@@ -17,7 +17,7 @@ export async function setupLogConfig(logger, servicePath, service, logConfigMap,
|
|
|
17
17
|
});
|
|
18
18
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
19
19
|
writeFileSync(inflatePath, await inflateJSX(logPath, {
|
|
20
|
-
embemedJSX: false,
|
|
20
|
+
// embemedJSX: false,
|
|
21
21
|
minify: false,
|
|
22
22
|
useExport: true,
|
|
23
23
|
platform: "node",
|
|
@@ -21,7 +21,7 @@ export async function setupMiddleware(logger, servicePath, service, mainRouter,
|
|
|
21
21
|
});
|
|
22
22
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
23
23
|
writeFileSync(inflatePath, await inflateJSX(middlewarePath, {
|
|
24
|
-
embemedJSX: false,
|
|
24
|
+
// embemedJSX: false,
|
|
25
25
|
minify: false,
|
|
26
26
|
platform: "node",
|
|
27
27
|
useExport: true,
|