miqro 7.2.6 → 7.2.7
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 +1 -21
- package/build/esm/src/bin/compile.js +0 -1
- package/build/esm/src/bin/doc-md.js +0 -1
- package/build/esm/src/bin/generate-doc.js +0 -1
- package/build/esm/src/bin/test.js +0 -1
- package/build/esm/src/bin/types.js +0 -1
- package/build/esm/src/cluster.js +0 -1
- package/build/esm/src/common/arguments.js +0 -1
- package/build/esm/src/common/assets.js +2 -3
- package/build/esm/src/common/checksum.js +0 -1
- package/build/esm/src/common/constants.js +0 -1
- package/build/esm/src/common/content-type.js +0 -1
- package/build/esm/src/common/esbuild.js +0 -1
- package/build/esm/src/common/exit.js +0 -1
- package/build/esm/src/common/fs.js +0 -1
- package/build/esm/src/common/help.js +0 -1
- package/build/esm/src/common/jsx.js +0 -1
- package/build/esm/src/common/jwt.js +0 -1
- package/build/esm/src/common/paths.js +0 -1
- package/build/esm/src/common/watch.js +0 -1
- package/build/esm/src/inflate/inflate-sea.js +0 -1
- package/build/esm/src/inflate/inflate.js +0 -1
- package/build/esm/src/inflate/md.js +0 -1
- package/build/esm/src/inflate/setup-auth.js +0 -1
- package/build/esm/src/inflate/setup-cors.js +0 -1
- package/build/esm/src/inflate/setup-db.js +0 -1
- package/build/esm/src/inflate/setup-error.js +0 -1
- package/build/esm/src/inflate/setup-http.js +0 -1
- package/build/esm/src/inflate/setup-log.js +0 -1
- package/build/esm/src/inflate/setup-middleware.js +0 -1
- package/build/esm/src/inflate/setup-server-config.js +0 -1
- package/build/esm/src/inflate/setup-test.js +0 -1
- package/build/esm/src/inflate/setup-ws.js +0 -1
- package/build/esm/src/inflate/setup.doc.js +0 -1
- package/build/esm/src/inflate/utils/sea-utils.js +0 -1
- package/build/esm/src/lib.js +0 -1
- package/build/esm/src/main.js +0 -1
- package/build/esm/src/services/app.js +1 -1
- package/build/esm/src/services/editor.js +10 -12
- package/build/esm/src/services/hot-reload.js +0 -1
- package/build/esm/src/services/migrations.js +0 -1
- package/build/esm/src/services/utils/admin-interface.js +0 -1
- package/build/esm/src/services/utils/cache.js +0 -1
- package/build/esm/src/services/utils/cluster-cache.js +0 -1
- package/build/esm/src/services/utils/cluster-ws.js +0 -1
- package/build/esm/src/services/utils/db-manager.js +0 -1
- package/build/esm/src/services/utils/get-route.js +0 -1
- package/build/esm/src/services/utils/jwt.js +0 -1
- package/build/esm/src/services/utils/log-transport.js +0 -1
- package/build/esm/src/services/utils/log.js +0 -1
- package/build/esm/src/services/utils/middleware.js +0 -1
- package/build/esm/src/services/utils/server-interface.js +0 -1
- package/build/esm/src/services/utils/websocketmanager.d.ts +2 -0
- package/build/esm/src/services/utils/websocketmanager.js +8 -2
- package/build/esm/src/types.js +0 -1
- package/build/lib.cjs +27 -29
- package/build/style.css +3 -3
- package/package.json +2 -2
- package/build/esm/editor/auth.d.ts +0 -6
- package/build/esm/editor/auth.js +0 -43
- package/build/esm/editor/auth.js.map +0 -1
- package/build/esm/editor/common/admin-interface.d.ts +0 -36
- package/build/esm/editor/common/admin-interface.js +0 -45
- package/build/esm/editor/common/admin-interface.js.map +0 -1
- package/build/esm/editor/common/constants.d.ts +0 -4
- package/build/esm/editor/common/constants.js +0 -21
- package/build/esm/editor/common/constants.js.map +0 -1
- package/build/esm/editor/common/constants.server.d.ts +0 -2
- package/build/esm/editor/common/constants.server.js +0 -5
- package/build/esm/editor/common/constants.server.js.map +0 -1
- package/build/esm/editor/common/editor-index.d.ts +0 -2
- package/build/esm/editor/common/editor-index.js +0 -15
- package/build/esm/editor/common/editor-index.js.map +0 -1
- package/build/esm/editor/common/html-encode.d.ts +0 -1
- package/build/esm/editor/common/html-encode.js +0 -15
- package/build/esm/editor/common/html-encode.js.map +0 -1
- package/build/esm/editor/common/log-socket.d.ts +0 -15
- package/build/esm/editor/common/log-socket.js +0 -72
- package/build/esm/editor/common/log-socket.js.map +0 -1
- package/build/esm/editor/common/templates.d.ts +0 -11
- package/build/esm/editor/common/templates.js +0 -478
- package/build/esm/editor/common/templates.js.map +0 -1
- package/build/esm/editor/components/api-preview.d.ts +0 -11
- package/build/esm/editor/components/api-preview.js +0 -93
- package/build/esm/editor/components/api-preview.js.map +0 -1
- package/build/esm/editor/components/editor.d.ts +0 -16
- package/build/esm/editor/components/editor.js +0 -368
- package/build/esm/editor/components/editor.js.map +0 -1
- package/build/esm/editor/components/file-browser.d.ts +0 -37
- package/build/esm/editor/components/file-browser.js +0 -128
- package/build/esm/editor/components/file-browser.js.map +0 -1
- package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
- package/build/esm/editor/components/file-editor-toolbar.js +0 -96
- package/build/esm/editor/components/file-editor-toolbar.js.map +0 -1
- package/build/esm/editor/components/file-editor.d.ts +0 -32
- package/build/esm/editor/components/file-editor.js +0 -62
- package/build/esm/editor/components/file-editor.js.map +0 -1
- package/build/esm/editor/components/filter-query.d.ts +0 -1
- package/build/esm/editor/components/filter-query.js +0 -24
- package/build/esm/editor/components/filter-query.js.map +0 -1
- package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
- package/build/esm/editor/components/highlight-text-area.js +0 -128
- package/build/esm/editor/components/highlight-text-area.js.map +0 -1
- package/build/esm/editor/components/log-viewer.d.ts +0 -6
- package/build/esm/editor/components/log-viewer.js +0 -72
- package/build/esm/editor/components/log-viewer.js.map +0 -1
- package/build/esm/editor/components/new-file.d.ts +0 -10
- package/build/esm/editor/components/new-file.js +0 -120
- package/build/esm/editor/components/new-file.js.map +0 -1
- package/build/esm/editor/components/scroll-query.d.ts +0 -7
- package/build/esm/editor/components/scroll-query.js +0 -23
- package/build/esm/editor/components/scroll-query.js.map +0 -1
- package/build/esm/editor/components/start-page.d.ts +0 -13
- package/build/esm/editor/components/start-page.js +0 -33
- package/build/esm/editor/components/start-page.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -4
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -31
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -7
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -51
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -7
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -41
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js.map +0 -1
- 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 -151
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js.map +0 -1
- 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 -40
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js.map +0 -1
- 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 -47
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js.map +0 -1
- 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 -47
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js.map +0 -1
- package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
- package/build/esm/editor/http/admin/editor/editor.js +0 -9
- package/build/esm/editor/http/admin/editor/editor.js.map +0 -1
- package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/index.api.js +0 -23
- package/build/esm/editor/http/admin/editor/index.api.js.map +0 -1
- package/build/esm/editor/server.d.ts +0 -3
- package/build/esm/editor/server.js +0 -50
- package/build/esm/editor/server.js.map +0 -1
- package/build/esm/editor/ws.d.ts +0 -3
- package/build/esm/editor/ws.js +0 -12
- package/build/esm/editor/ws.js.map +0 -1
- package/build/esm/src/bin/compile.js.map +0 -1
- package/build/esm/src/bin/doc-md.js.map +0 -1
- package/build/esm/src/bin/generate-doc.js.map +0 -1
- package/build/esm/src/bin/test.js.map +0 -1
- package/build/esm/src/bin/types.js.map +0 -1
- package/build/esm/src/cluster.js.map +0 -1
- package/build/esm/src/common/arguments.js.map +0 -1
- package/build/esm/src/common/assets.js.map +0 -1
- package/build/esm/src/common/checksum.js.map +0 -1
- package/build/esm/src/common/constants.js.map +0 -1
- package/build/esm/src/common/content-type.js.map +0 -1
- package/build/esm/src/common/esbuild.js.map +0 -1
- package/build/esm/src/common/exit.js.map +0 -1
- package/build/esm/src/common/fs.js.map +0 -1
- package/build/esm/src/common/help.js.map +0 -1
- package/build/esm/src/common/jsx.js.map +0 -1
- package/build/esm/src/common/jwt.js.map +0 -1
- package/build/esm/src/common/paths.js.map +0 -1
- package/build/esm/src/common/watch.js.map +0 -1
- package/build/esm/src/inflate/inflate-sea.js.map +0 -1
- package/build/esm/src/inflate/inflate.js.map +0 -1
- package/build/esm/src/inflate/md.js.map +0 -1
- package/build/esm/src/inflate/setup-auth.js.map +0 -1
- package/build/esm/src/inflate/setup-cors.js.map +0 -1
- package/build/esm/src/inflate/setup-db.js.map +0 -1
- package/build/esm/src/inflate/setup-error.js.map +0 -1
- package/build/esm/src/inflate/setup-http.js.map +0 -1
- package/build/esm/src/inflate/setup-log.js.map +0 -1
- package/build/esm/src/inflate/setup-middleware.js.map +0 -1
- package/build/esm/src/inflate/setup-server-config.js.map +0 -1
- package/build/esm/src/inflate/setup-test.js.map +0 -1
- package/build/esm/src/inflate/setup-ws.js.map +0 -1
- package/build/esm/src/inflate/setup.doc.js.map +0 -1
- package/build/esm/src/inflate/utils/sea-utils.js.map +0 -1
- package/build/esm/src/lib.js.map +0 -1
- package/build/esm/src/main.js.map +0 -1
- package/build/esm/src/services/app.js.map +0 -1
- package/build/esm/src/services/editor.js.map +0 -1
- package/build/esm/src/services/hot-reload.js.map +0 -1
- package/build/esm/src/services/migrations.js.map +0 -1
- package/build/esm/src/services/utils/admin-interface.js.map +0 -1
- package/build/esm/src/services/utils/cache.js.map +0 -1
- package/build/esm/src/services/utils/cluster-cache.js.map +0 -1
- package/build/esm/src/services/utils/cluster-ws.js.map +0 -1
- package/build/esm/src/services/utils/db-manager.js.map +0 -1
- package/build/esm/src/services/utils/get-route.js.map +0 -1
- package/build/esm/src/services/utils/jwt.js.map +0 -1
- package/build/esm/src/services/utils/log-transport.js.map +0 -1
- package/build/esm/src/services/utils/log.js.map +0 -1
- package/build/esm/src/services/utils/middleware.js.map +0 -1
- package/build/esm/src/services/utils/server-interface.js.map +0 -1
- package/build/esm/src/services/utils/websocketmanager.js.map +0 -1
- package/build/esm/src/types.js.map +0 -1
- package/build/font.ttf +0 -0
- package/editor/auth.ts +0 -52
- 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 -87
- package/editor/common/templates.ts +0 -481
- package/editor/components/api-preview.tsx +0 -118
- package/editor/components/editor.tsx +0 -496
- package/editor/components/file-browser.tsx +0 -311
- package/editor/components/file-editor-toolbar.tsx +0 -194
- package/editor/components/file-editor.tsx +0 -125
- package/editor/components/filter-query.tsx +0 -26
- package/editor/components/highlight-text-area.tsx +0 -148
- package/editor/components/log-viewer.tsx +0 -113
- package/editor/components/new-file.tsx +0 -172
- package/editor/components/scroll-query.tsx +0 -25
- package/editor/components/start-page.tsx +0 -52
- 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 -10
- package/editor/http/admin/editor/index.api.tsx +0 -42
- package/editor/server.ts +0 -57
- package/editor/ws.ts +0 -15
- 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 -93
- package/src/bin/types.ts +0 -34
- package/src/cluster.ts +0 -27
- package/src/common/arguments.ts +0 -853
- package/src/common/assets.ts +0 -148
- package/src/common/checksum.ts +0 -58
- package/src/common/constants.ts +0 -19
- package/src/common/content-type.ts +0 -84
- package/src/common/esbuild.ts +0 -103
- package/src/common/exit.ts +0 -91
- package/src/common/fs.ts +0 -82
- package/src/common/help.ts +0 -65
- package/src/common/jsx.ts +0 -574
- package/src/common/jwt.ts +0 -85
- package/src/common/paths.ts +0 -107
- package/src/common/watch.ts +0 -88
- package/src/inflate/inflate-sea.ts +0 -268
- package/src/inflate/inflate.ts +0 -105
- package/src/inflate/md.ts +0 -25
- package/src/inflate/setup-auth.ts +0 -41
- package/src/inflate/setup-cors.ts +0 -42
- package/src/inflate/setup-db.ts +0 -117
- package/src/inflate/setup-error.ts +0 -44
- package/src/inflate/setup-http.ts +0 -720
- 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 -92
- package/src/inflate/utils/sea-utils.ts +0 -14
- package/src/lib.ts +0 -35
- package/src/main.ts +0 -107
- package/src/services/app.ts +0 -750
- package/src/services/editor.tsx +0 -101
- package/src/services/globals.ts.ignore +0 -186
- package/src/services/hot-reload.ts +0 -55
- 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 -255
- 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/jwt.ts +0 -25
- package/src/services/utils/log-transport.ts +0 -81
- package/src/services/utils/log.ts +0 -92
- package/src/services/utils/middleware.ts +0 -10
- package/src/services/utils/server-interface.ts +0 -122
- package/src/services/utils/websocketmanager.ts +0 -158
- package/src/types.ts +0 -287
package/src/common/paths.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { checkEnvVariable } from "@miqro/core";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { existsSync, statSync } from "node:fs";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { resolve } from "node:path";
|
|
6
|
-
import { cwd, platform } from "node:process";
|
|
7
|
-
|
|
8
|
-
export const JSX_TMP_DIR = checkEnvVariable(`JSX_TMP`, resolve(tmpdir(), "jsx_tmp"));
|
|
9
|
-
|
|
10
|
-
export const TEST_SOCKET = resolve(JSX_TMP_DIR, `test.${randomUUID()}.sock`);
|
|
11
|
-
|
|
12
|
-
export function getServicePath(service: string) {
|
|
13
|
-
return resolve(cwd(), service);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const EXTENSIONS = [".ts", ".js", ".cjs"];
|
|
17
|
-
|
|
18
|
-
function getFilePath(dirname: string, name: string, extensions: string[]) {
|
|
19
|
-
for (const ex of extensions) {
|
|
20
|
-
const path = resolve(dirname, name + ex);
|
|
21
|
-
if (existsSync(path) && !statSync(path).isDirectory()) {
|
|
22
|
-
return path;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function getLogConfigPath(servicePath: string) {
|
|
29
|
-
return getFilePath(servicePath, "log", EXTENSIONS);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function getCORSConfigPath(servicePath: string) {
|
|
33
|
-
return getFilePath(servicePath, "cors", EXTENSIONS);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function getServerConfigPath(servicePath: string) {
|
|
37
|
-
return getFilePath(servicePath, "server", EXTENSIONS);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function getWSConfigPath(servicePath: string) {
|
|
41
|
-
return getFilePath(servicePath, "ws", EXTENSIONS);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getDBConfigPath(servicePath: string) {
|
|
45
|
-
return getFilePath(servicePath, "db", EXTENSIONS);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function getStaticFilesPath(servicePath: string) {
|
|
49
|
-
const staticFilesPath = resolve(servicePath, "static");
|
|
50
|
-
if (existsSync(staticFilesPath) && statSync(staticFilesPath).isDirectory()) {
|
|
51
|
-
return staticFilesPath;
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function getMiddlewareConfigPath(servicePath: string) {
|
|
57
|
-
return getFilePath(servicePath, "middleware", EXTENSIONS);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function getErrorConfigPath(servicePath: string) {
|
|
61
|
-
return getFilePath(servicePath, "catch", EXTENSIONS);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function getDocConfigPath(servicePath: string) {
|
|
65
|
-
return getFilePath(servicePath, "doc", EXTENSIONS);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function getMiqroJSONPath() {
|
|
69
|
-
const miqroRCPath = resolve(cwd(), "miqro.json");
|
|
70
|
-
if (existsSync(miqroRCPath) && !statSync(miqroRCPath).isDirectory()) {
|
|
71
|
-
return miqroRCPath;
|
|
72
|
-
}
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function getAuthConfigPath(servicePath: string) {
|
|
77
|
-
return getFilePath(servicePath, "auth", EXTENSIONS);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function getHTTPRouterPath(servicePath: string) {
|
|
81
|
-
const apiRouterPath = resolve(servicePath, "http");
|
|
82
|
-
if (existsSync(apiRouterPath) && statSync(apiRouterPath).isDirectory()) {
|
|
83
|
-
return apiRouterPath;
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function getMigrationsPath(servicePath: string) {
|
|
89
|
-
const migrationsFolderPath = resolve(servicePath, "migration");
|
|
90
|
-
if (existsSync(migrationsFolderPath) && statSync(migrationsFolderPath).isDirectory()) {
|
|
91
|
-
return migrationsFolderPath;
|
|
92
|
-
}
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function getESBuildBinaryPath() {
|
|
97
|
-
if (platform === "win32") {
|
|
98
|
-
return resolve(JSX_TMP_DIR, String(process.pid), "esbuild.exe");
|
|
99
|
-
} else {
|
|
100
|
-
return resolve(JSX_TMP_DIR, String(process.pid), "esbuild");
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/*export function getJSXJSPath() {
|
|
105
|
-
return resolve(JSX_TMP_DIR, String(process.pid), "jsx.js");
|
|
106
|
-
}*/
|
|
107
|
-
|
package/src/common/watch.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
//import "../services/globals.js";
|
|
2
|
-
import { FSWatcher, existsSync, readdirSync, statSync, watch } from "node:fs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
import { Miqro } from "../services/app.js";
|
|
5
|
-
|
|
6
|
-
export async function watchAndServer(app: Miqro) {
|
|
7
|
-
let timeout: any;
|
|
8
|
-
const watchLogger = app.logger;
|
|
9
|
-
const watchers: FSWatcher[] = [];
|
|
10
|
-
|
|
11
|
-
/*await start({
|
|
12
|
-
logger,
|
|
13
|
-
webSocketManager,
|
|
14
|
-
dbManager,
|
|
15
|
-
services,
|
|
16
|
-
editor,
|
|
17
|
-
inflateTests: false,
|
|
18
|
-
inflateDir: false,
|
|
19
|
-
inflateSea: false,
|
|
20
|
-
runOnTestPort: false
|
|
21
|
-
});*/
|
|
22
|
-
|
|
23
|
-
//await app.start();
|
|
24
|
-
|
|
25
|
-
function watchHandler(eventType: any, filename: any) {
|
|
26
|
-
stopWatch();
|
|
27
|
-
watchLogger?.debug(`event type is: ${eventType}`);
|
|
28
|
-
if (filename) {
|
|
29
|
-
watchLogger?.debug(`filename provided: ${filename}`);
|
|
30
|
-
} else {
|
|
31
|
-
watchLogger?.debug('filename not provided');
|
|
32
|
-
}
|
|
33
|
-
watchLogger?.info(`${eventType} on ${filename}`);
|
|
34
|
-
clearTimeout(timeout);
|
|
35
|
-
timeout = setTimeout(async () => {
|
|
36
|
-
try {
|
|
37
|
-
stopWatch();
|
|
38
|
-
setTimeout(async () => {
|
|
39
|
-
watchLogger?.debug("closed");
|
|
40
|
-
await app.reload();
|
|
41
|
-
reWatch();
|
|
42
|
-
}, 500);
|
|
43
|
-
} catch (e) {
|
|
44
|
-
watchLogger?.error(e);
|
|
45
|
-
}
|
|
46
|
-
}, 2000);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function watchDir(toWatch: string) {
|
|
50
|
-
clearTimeout(timeout);
|
|
51
|
-
const files = existsSync(toWatch) ? readdirSync(toWatch) : [];
|
|
52
|
-
for (const file of files) {
|
|
53
|
-
const filePath = resolve(toWatch, file);
|
|
54
|
-
if (statSync(filePath).isDirectory()) {
|
|
55
|
-
watchDir(filePath);
|
|
56
|
-
} else {
|
|
57
|
-
//console.log("toWatch=" + filePath);
|
|
58
|
-
watchers.push(watch(filePath, watchHandler));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function stopWatch() {
|
|
64
|
-
clearTimeout(timeout);
|
|
65
|
-
const toClose = watchers.splice(0, watchers.length);
|
|
66
|
-
for (const watcher of toClose) {
|
|
67
|
-
watcher.close();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
function reWatch() {
|
|
73
|
-
stopWatch();
|
|
74
|
-
clearTimeout(timeout);
|
|
75
|
-
for (const service of app.options.services) {
|
|
76
|
-
const toWatch = resolve(process.cwd(), service);
|
|
77
|
-
watchDir(toWatch);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
watchLogger?.info("watching for changes on [%s]", app.options.services.join(","));
|
|
82
|
-
reWatch();
|
|
83
|
-
return {
|
|
84
|
-
stopWatch: () => {
|
|
85
|
-
stopWatch();
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
}
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { Logger } from "@miqro/core";
|
|
2
|
-
import { chmodSync, constants, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { basename, dirname, extname, join, relative, resolve } from "node:path";
|
|
4
|
-
import { cwd, platform } from "node:process";
|
|
5
|
-
|
|
6
|
-
import { RouteFileMap, StaticFileMap } from "./setup-http.js";
|
|
7
|
-
import { getAuthConfigPath, getCORSConfigPath, getDBConfigPath, getErrorConfigPath, getLogConfigPath, getMiddlewareConfigPath, getMigrationsPath, getMiqroJSONPath, getServerConfigPath, getServicePath, getWSConfigPath } from "../common/paths.js";
|
|
8
|
-
import { getAsset } from "../common/assets.js";
|
|
9
|
-
import { migration } from "@miqro/query";
|
|
10
|
-
import { esBuild } from "../common/esbuild.js";
|
|
11
|
-
|
|
12
|
-
//export const libCJSBuffer = Buffer.from(getAsset("lib.cjs"));
|
|
13
|
-
/*export const COMPILESH = Buffer.from(Buffer.from(getAsset("compile.base64.sh")).toString(), "base64");
|
|
14
|
-
export const SIGN_REMOVESH = Buffer.from(getAsset("sign-remove.sh"));
|
|
15
|
-
export const SIGN_ADDSH = Buffer.from(getAsset("sign-add.sh"));
|
|
16
|
-
export const INSTALLNODEJSSH = Buffer.from(getAsset("install-nodejs.sh"));
|
|
17
|
-
export const APPSH = Buffer.from(getAsset("app.sh"));
|
|
18
|
-
export const NODESH = Buffer.from(getAsset("node.sh"));
|
|
19
|
-
export const SEACONFIGJSON = Buffer.from(getAsset("sea.basic.config.json"));
|
|
20
|
-
export const POSTJECTCJS = Buffer.from(Buffer.from(getAsset("postject.base64.cjs")).toString(), "base64");*/
|
|
21
|
-
|
|
22
|
-
export async function inflateSeaAssets(logger: Logger, inflateDir: string) {
|
|
23
|
-
const esbuildBinaryBuffer = Buffer.from(getAsset("esbuild-binary"));
|
|
24
|
-
if (platform === "win32") {
|
|
25
|
-
writeFile(logger, resolve(inflateDir, "sea", "esbuild.exe"), esbuildBinaryBuffer);
|
|
26
|
-
chmodSync(resolve(inflateDir, "sea", "esbuild.exe"), constants.S_IXUSR | constants.S_IRUSR | constants.S_IWUSR);
|
|
27
|
-
} else {
|
|
28
|
-
writeFile(logger, resolve(inflateDir, "sea", "esbuild"), esbuildBinaryBuffer);
|
|
29
|
-
chmodSync(resolve(inflateDir, "sea", "esbuild"), constants.S_IXUSR | constants.S_IRUSR | constants.S_IWUSR);
|
|
30
|
-
}
|
|
31
|
-
// writeFile(logger, resolve(inflateDir, "sea", "postject.cjs"), Buffer.from(Buffer.from(getAsset("postject.base64.cjs")).toString(), "base64"));
|
|
32
|
-
writeFile(logger, resolve(inflateDir, "sea", "config.json"), Buffer.from(getAsset("sea.basic.config.json")));
|
|
33
|
-
writeFile(logger, resolve(inflateDir, "sea", "run.sh"), Buffer.from(getAsset("app.sh")));
|
|
34
|
-
writeFile(logger, resolve(inflateDir, "sea", "node.sh"), Buffer.from(getAsset("node.sh")));
|
|
35
|
-
writeFile(logger, resolve(inflateDir, "compile.sh"), Buffer.from(Buffer.from(getAsset("compile.base64.sh")).toString(), "base64"));
|
|
36
|
-
writeFile(logger, resolve(inflateDir, "sea", "sign-add.sh"), Buffer.from(getAsset("sign-add.sh")));
|
|
37
|
-
writeFile(logger, resolve(inflateDir, "sea", "sign-remove.sh"), Buffer.from(getAsset("sign-remove.sh")));
|
|
38
|
-
writeFile(logger, resolve(inflateDir, "install-nodejs.sh"), Buffer.from(getAsset("install-nodejs.sh")));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export async function inflateAppForSea(logger: Logger, inflateDir: string, services: string[], port: string) {
|
|
42
|
-
|
|
43
|
-
const PORT = port;
|
|
44
|
-
|
|
45
|
-
inflateSeaAssets(logger, inflateDir);
|
|
46
|
-
|
|
47
|
-
writeFile(logger, resolve(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
|
|
48
|
-
|
|
49
|
-
const WSLIST = services.filter(service => getWSConfigPath(resolve(cwd(), service))).map(service => {
|
|
50
|
-
return `(await require("./../${service}/ws.cjs")).default`;
|
|
51
|
-
}).join(",");
|
|
52
|
-
|
|
53
|
-
const LOGCONFIGLIST = services.filter(service => getLogConfigPath(resolve(cwd(), service))).map(service => {
|
|
54
|
-
return `{config: (await require("./../${service}/log.cjs")).default, service: "${service}" }`;
|
|
55
|
-
}).join(",");
|
|
56
|
-
|
|
57
|
-
const SERVERCONFIGLIST = services.filter(service => getServerConfigPath(resolve(cwd(), service))).map(service => {
|
|
58
|
-
return `(await require("./../${service}/server.cjs")).default`;
|
|
59
|
-
}).join(",\n");
|
|
60
|
-
|
|
61
|
-
const DBCONFIGLIST = services.filter(service => getDBConfigPath(resolve(cwd(), service))).map(service => {
|
|
62
|
-
return `new Promise(async (resolve, reject) => {
|
|
63
|
-
try {
|
|
64
|
-
const db = await dbManager.setupDB((await require("../${service}/db.cjs")).default);
|
|
65
|
-
await (await require("./${service}/migration-up.cjs")).runMigrations(db);
|
|
66
|
-
resolve();
|
|
67
|
-
} catch(e) {
|
|
68
|
-
reject(e);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
})`;
|
|
72
|
-
}).join(",");
|
|
73
|
-
|
|
74
|
-
writeFile(logger, join(inflateDir, "sea", "package.json"), `{ "type": "module", "private": true }`);
|
|
75
|
-
|
|
76
|
-
writeFile(logger, join(inflateDir, "sea", "app.cjs"), `const { createLogProviderOptions, createServerInterface, ServerRequestHandler, WebSocketManager, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
|
|
77
|
-
|
|
78
|
-
async function main() {
|
|
79
|
-
const PORT = "${PORT}";
|
|
80
|
-
|
|
81
|
-
const logConfigList = await Promise.all([${LOGCONFIGLIST}]);
|
|
82
|
-
|
|
83
|
-
const loggerProvider = new LogProvider(createLogProviderOptions({
|
|
84
|
-
inflated: {
|
|
85
|
-
logConfigMap: logConfigList.reduce((ret, config)=>{
|
|
86
|
-
ret[config.service] = config.config;
|
|
87
|
-
return ret;
|
|
88
|
-
}, {})
|
|
89
|
-
}
|
|
90
|
-
}));
|
|
91
|
-
const logger = loggerProvider.getLogger("SERVER");
|
|
92
|
-
const localCache = new LocalCache();
|
|
93
|
-
const cache = new ClusterCache();
|
|
94
|
-
const webSocketManager = new WebSocketManager({
|
|
95
|
-
loggerProvider,
|
|
96
|
-
logger
|
|
97
|
-
});
|
|
98
|
-
const dbManager = new DBManager({
|
|
99
|
-
loggerProvider,
|
|
100
|
-
logger
|
|
101
|
-
});
|
|
102
|
-
const serverInterface = createServerInterface({
|
|
103
|
-
cache,
|
|
104
|
-
localCache,
|
|
105
|
-
loggerProvider,
|
|
106
|
-
webSocketManager,
|
|
107
|
-
logger,
|
|
108
|
-
dbManager,
|
|
109
|
-
port: PORT
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
await Promise.all([${DBCONFIGLIST}]);
|
|
113
|
-
|
|
114
|
-
${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.preload).map(config=>config.preload(serverInterface)));\n` : ""}
|
|
115
|
-
|
|
116
|
-
${!WSLIST ? "" : `\n webSocketManager.replaceALLWS(await Promise.all([${WSLIST}]))`}
|
|
117
|
-
const app = new App({
|
|
118
|
-
loggerFactory: loggerProvider.requestLoggerFactory,
|
|
119
|
-
onUpgrade: (req, socket, head) => {
|
|
120
|
-
try {
|
|
121
|
-
req.server = serverInterface;
|
|
122
|
-
return webSocketManager.onUpgrade(req, socket, head);
|
|
123
|
-
} catch(e) {
|
|
124
|
-
console.error(e);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
app.use(ServerRequestHandler(serverInterface));
|
|
130
|
-
app.use(LoggerHandler());
|
|
131
|
-
${services.map(service => `app.use(await (await require("./${join(service, "router.cjs")}")).setupRouter());`).join("\n")}
|
|
132
|
-
${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.load).map(config=>config.load(serverInterface)));\n` : ""}
|
|
133
|
-
|
|
134
|
-
await app.listen(PORT);
|
|
135
|
-
${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.start).map(config=>config.start(serverInterface)));` : ""}
|
|
136
|
-
loggerProvider.getLogger("server").info("listening on [%s]", PORT);
|
|
137
|
-
}
|
|
138
|
-
main().catch(e=>console.error(e));
|
|
139
|
-
`
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
logger.log("writing [%s]", relative(cwd(), join(inflateDir, "sea", "app.bundle.cjs")));
|
|
143
|
-
await esBuild({
|
|
144
|
-
entryPoints: [join(inflateDir, "sea", "app.cjs")],
|
|
145
|
-
bundle: true,
|
|
146
|
-
minify: true,
|
|
147
|
-
jsxFactory: "JSX.createElement",
|
|
148
|
-
jsxFragment: "JSX.Fragment",
|
|
149
|
-
platform: "node",
|
|
150
|
-
outfile: join(inflateDir, "sea", "app.bundle.cjs")
|
|
151
|
-
});
|
|
152
|
-
const miqroRCPath = getMiqroJSONPath();
|
|
153
|
-
if (miqroRCPath) {
|
|
154
|
-
writeFile(logger, join(inflateDir, "miqro.json"), readFileSync(miqroRCPath));
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export async function inflateServiceForSea(logger: Logger, inflateDir: string, service: string, servicePath: string/*, serviceMigrations: string[]*/, serviceRouteFileMap: RouteFileMap, serviceStaticFileMap: StaticFileMap) {
|
|
159
|
-
const migrationsFolderPath = getMigrationsPath(servicePath);
|
|
160
|
-
|
|
161
|
-
const serviceMigrations: string[] = migrationsFolderPath ? migration.getSortedMigrations(migrationsFolderPath) : [];
|
|
162
|
-
writeFile(logger, join(inflateDir, "sea", service, "router.cjs"), `const { appendAPIModule, Router, middleware } = require("./${relative(service, "")}/lib.cjs");\n
|
|
163
|
-
async function setupRouter() {
|
|
164
|
-
const router = new Router();
|
|
165
|
-
${getErrorConfigPath(servicePath) ? `
|
|
166
|
-
const errorConfig = (await require("../${relative(service, "")}/${service}/catch.cjs")).default;
|
|
167
|
-
if(errorConfig && errorConfig.catch) {
|
|
168
|
-
for(const m of errorConfig.catch) {
|
|
169
|
-
router.catch(m);
|
|
170
|
-
}
|
|
171
|
-
}` : ""}
|
|
172
|
-
${getCORSConfigPath(servicePath) ? ` router.use(middleware.cors((await require("../${relative(service, "")}/${service}/cors.cjs")).default));` : ""}
|
|
173
|
-
${getAuthConfigPath(servicePath) ? ` router.use(middleware.session((await require("../${relative(service, "")}/${service}/auth.cjs")).default));` : ""}
|
|
174
|
-
${getMiddlewareConfigPath(servicePath) ? `
|
|
175
|
-
const middlewareConfig = (await require("../${relative(service, "")}/${service}/middleware.cjs")).default;
|
|
176
|
-
if(middlewareConfig && middlewareConfig.middleware) {
|
|
177
|
-
for(const m of middlewareConfig.middleware) {
|
|
178
|
-
router.use(m);
|
|
179
|
-
}
|
|
180
|
-
}` : ""}
|
|
181
|
-
${Object.keys(serviceRouteFileMap)
|
|
182
|
-
.map(filePath => serviceRouteFileMap[filePath])
|
|
183
|
-
.filter(data => data.previewMethod === "api")
|
|
184
|
-
.map(data => data.routes.map(r => {
|
|
185
|
-
const rPath = join(relative(cwd(), dirname(data.filePath)), basename(data.filePath));
|
|
186
|
-
if (rPath) {
|
|
187
|
-
const rPathExt = extname(rPath);
|
|
188
|
-
const apiInflatedPath = join("..", relative(service, ""), rPath.substring(0, rPath.length - rPathExt.length) + ".cjs");
|
|
189
|
-
return ` await appendAPIModule(router, "../${relative(service, "")}/${service}/http", "./${apiInflatedPath}", (await require("./${apiInflatedPath}")).default);`;
|
|
190
|
-
} else {
|
|
191
|
-
return "";
|
|
192
|
-
}
|
|
193
|
-
}).filter(l => l)[0])
|
|
194
|
-
.join("\n")}
|
|
195
|
-
router.use(await (await require("./static-router.cjs")).setupRouter())
|
|
196
|
-
|
|
197
|
-
${getMiddlewareConfigPath(servicePath) ? `
|
|
198
|
-
if(middlewareConfig && middlewareConfig.post) {
|
|
199
|
-
for(const m of middlewareConfig.post) {
|
|
200
|
-
router.use(m);
|
|
201
|
-
}
|
|
202
|
-
}` : ""}
|
|
203
|
-
|
|
204
|
-
return router;
|
|
205
|
-
}
|
|
206
|
-
module.exports = {
|
|
207
|
-
setupRouter
|
|
208
|
-
}`);
|
|
209
|
-
|
|
210
|
-
writeFile(logger, join(inflateDir, "sea", service, "migration-up.cjs"), `const { migration } = require("./${relative(service, "")}/lib.cjs");\n
|
|
211
|
-
async function runMigrations(db) {
|
|
212
|
-
await migration.init(db);
|
|
213
|
-
${serviceMigrations.map(file => {
|
|
214
|
-
const name = `${file.substring(0, file.length - extname(file).length)}`;
|
|
215
|
-
return ` await migration.up.module(db, (await require("../${relative(service, "")}/${service}/migration/${name}.cjs")).default.name ?? "${file}", (await require("../${relative(service, "")}/${service}/migration/${name}.cjs")).default)`;
|
|
216
|
-
}).join("\n")}
|
|
217
|
-
}
|
|
218
|
-
module.exports = {
|
|
219
|
-
runMigrations
|
|
220
|
-
}`);
|
|
221
|
-
|
|
222
|
-
writeFile(logger, join(inflateDir, "sea", service, "migration-down.cjs"), `const { migration } = require("./${relative(service, "")}/lib.cjs");\n
|
|
223
|
-
async function runMigrations(db) {
|
|
224
|
-
await migration.init(db);
|
|
225
|
-
${serviceMigrations.reverse().map(file => {
|
|
226
|
-
const name = `${file.substring(0, file.length - extname(file).length)}`;
|
|
227
|
-
return ` await migration.down.module(db, (await require("../${relative(service, "")}/${service}/migration/${name}.cjs")).default.name ?? "${file}", (await require("../${relative(service, "")}/${service}/migration/${name}.cjs")).default)`;
|
|
228
|
-
}).join("\n")}
|
|
229
|
-
}
|
|
230
|
-
module.exports = {
|
|
231
|
-
runMigrations
|
|
232
|
-
}`);
|
|
233
|
-
|
|
234
|
-
const staticFiles = Object.keys(serviceStaticFileMap);
|
|
235
|
-
/*if (staticFiles.length !== 0) {
|
|
236
|
-
writeFile(logger, join(inflateDir, "sea", service, "static.base64.json"), JSON.stringify(serviceStaticFileMap));
|
|
237
|
-
}*/
|
|
238
|
-
writeFile(logger, join(inflateDir, "sea", service, "static-router.cjs"), `const { appendAPIModule, Router } = require("./${relative(service, "")}/lib.cjs");\n
|
|
239
|
-
async function setupRouter() {
|
|
240
|
-
const router = new Router();
|
|
241
|
-
${staticFiles.length === 0 ? "" : `
|
|
242
|
-
${staticFiles.map((filePath) => {
|
|
243
|
-
return ` router.get("${serviceStaticFileMap[filePath].path}", async (_, res) => {
|
|
244
|
-
return res.asyncEnd({
|
|
245
|
-
status: 200,
|
|
246
|
-
headers: {
|
|
247
|
-
["Content-Type"]: "${serviceStaticFileMap[filePath].contentType}"
|
|
248
|
-
},
|
|
249
|
-
body: Buffer.from("${serviceStaticFileMap[filePath].body.toString("base64")}", "base64")
|
|
250
|
-
});
|
|
251
|
-
});`;
|
|
252
|
-
}).join("\n")}
|
|
253
|
-
`}
|
|
254
|
-
return router;
|
|
255
|
-
}
|
|
256
|
-
module.exports = {
|
|
257
|
-
setupRouter
|
|
258
|
-
}`);
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function writeFile(logger: Logger, path: string, buffer: Buffer | string) {
|
|
263
|
-
logger.log("writing [%s]", relative(cwd(), path));
|
|
264
|
-
mkdirSync(dirname(path), {
|
|
265
|
-
recursive: true
|
|
266
|
-
});
|
|
267
|
-
writeFileSync(path, buffer);
|
|
268
|
-
}
|
package/src/inflate/inflate.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { InflateError } from "../common/jsx.js";
|
|
2
|
-
import { Logger, Router } from "@miqro/core";
|
|
3
|
-
import { RouteFileMap, setupHTTPRouter, StaticFileMap } from "./setup-http.js";
|
|
4
|
-
//import { WSMapConfig } from "./utils/websocketmanager.js";
|
|
5
|
-
//import { ServerConfigMap, setupServerConfig } from "./setup-server-config.js";
|
|
6
|
-
// import { assertGlobalTampered } from "../services/globals.js";
|
|
7
|
-
import { getServicePath } from "../common/paths.js";
|
|
8
|
-
import { inflateWSConfig } from "./setup-ws.js";
|
|
9
|
-
import { inflateAppForSea, inflateServiceForSea } from "./inflate-sea.js";
|
|
10
|
-
import { ServerInterface, WSConfig } from "../types.js";
|
|
11
|
-
import { LogConfigMap, setupLogConfig } from "./setup-log.js";
|
|
12
|
-
import { setupDoc } from "./setup.doc.js";
|
|
13
|
-
|
|
14
|
-
export interface InflateAppOptions {
|
|
15
|
-
logger?: Logger;
|
|
16
|
-
services: string[];
|
|
17
|
-
//dbManager: DBManager;
|
|
18
|
-
inflateDir: string | undefined | false;
|
|
19
|
-
inflateSea: boolean;
|
|
20
|
-
//editor: boolean;
|
|
21
|
-
//inflateTests: boolean;
|
|
22
|
-
hotreload?: boolean;
|
|
23
|
-
port: string;
|
|
24
|
-
serverInterface: ServerInterface;
|
|
25
|
-
inflateParallel?: number;
|
|
26
|
-
noBuild?: boolean;
|
|
27
|
-
noMinify?: boolean;
|
|
28
|
-
inflateOnlyAssets?: boolean;
|
|
29
|
-
inflateFlat?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export async function inflateApp({ inflateParallel, serverInterface, logger, hotreload, services/*, dbManager*/, inflateDir, inflateSea/*, editor, inflateTests*/, port, noBuild, noMinify, inflateOnlyAssets, inflateFlat }: InflateAppOptions): Promise<[Router, InflateError[] | null, RouteFileMap, WSConfig[]/*, ServerConfigMap*/, LogConfigMap]> {
|
|
33
|
-
logger.trace("inflateApp");
|
|
34
|
-
const errors: InflateError[] = [];
|
|
35
|
-
//const migrations: string[] = [];
|
|
36
|
-
let routeFileMap: RouteFileMap = {};
|
|
37
|
-
const wsConfigList: WSConfig[] = [];
|
|
38
|
-
const router = new Router();
|
|
39
|
-
const logConfigMap: LogConfigMap = {};
|
|
40
|
-
//const serverConfigMap: ServerConfigMap = {};
|
|
41
|
-
|
|
42
|
-
// router.use(assertGlobalTampered);
|
|
43
|
-
|
|
44
|
-
/*if (editor) {
|
|
45
|
-
logger.info("setting up editor on %s", BASEEDITOR_PATH);
|
|
46
|
-
const editorRouter = await createEditorRouter();
|
|
47
|
-
router.use(editorRouter);
|
|
48
|
-
logger.info("setting up ws on [%s]", LOG_SOCKET_PATH);
|
|
49
|
-
wsConfigList.push(editorWSConfig);
|
|
50
|
-
serverConfigMap[EDITOR_CONFIG_KEY] = editorServerConfig;
|
|
51
|
-
}*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
for (const service of services) {
|
|
56
|
-
const serviceRouteFileMap: RouteFileMap = {};
|
|
57
|
-
const serviceStaticFileMap: StaticFileMap | null = inflateSea ? {} : null;
|
|
58
|
-
const servicePath = getServicePath(service);
|
|
59
|
-
|
|
60
|
-
/*const migrationsFolderPath = getMigrationsPath(servicePath);
|
|
61
|
-
|
|
62
|
-
const serviceMigrations: string[] = migrationsFolderPath ? migration.getSortedMigrations(migrationsFolderPath) : [];*/
|
|
63
|
-
|
|
64
|
-
/*const db = dbManager.getDB(service) ? dbManager.getDB(service) : await setupDB(logger, service, dbManager, inflateDir);;
|
|
65
|
-
|
|
66
|
-
if (db && (cluster.isPrimary || process.env["CLUSTER_NODE_NUMBER"] === "0")) {
|
|
67
|
-
await runMigrations(logger, db, servicePath, service, inflateDir, serviceMigrations);
|
|
68
|
-
}
|
|
69
|
-
if (db) {
|
|
70
|
-
migrations.push(...serviceMigrations);
|
|
71
|
-
}*/
|
|
72
|
-
|
|
73
|
-
//await setupDB(logger, service, dbConfigList, inflateDir);
|
|
74
|
-
|
|
75
|
-
await setupLogConfig(logger, servicePath, service, logConfigMap, inflateSea ? inflateDir : false, { noBuild }, errors);
|
|
76
|
-
|
|
77
|
-
router.use(await setupHTTPRouter({ noBuild }, { noMinify, inflateOnlyAssets, inflateFlat }, serverInterface, logger, hotreload ? hotreload : false, servicePath, service, serviceRouteFileMap, serviceStaticFileMap, inflateDir, inflateSea, errors, inflateParallel));
|
|
78
|
-
routeFileMap = {
|
|
79
|
-
...routeFileMap,
|
|
80
|
-
...serviceRouteFileMap
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
await setupDoc(logger, servicePath, service, router, routeFileMap, serviceStaticFileMap, inflateDir, errors, { noBuild }, inflateFlat);
|
|
84
|
-
|
|
85
|
-
await inflateWSConfig(logger, servicePath, service, wsConfigList, inflateSea ? inflateDir : undefined, errors, { noBuild });
|
|
86
|
-
|
|
87
|
-
//await setupServerConfig(logger, servicePath, service, serverConfigMap, inflateSea ? inflateDir : undefined, errors);
|
|
88
|
-
|
|
89
|
-
if (inflateDir && inflateSea) {
|
|
90
|
-
await inflateServiceForSea(logger, inflateDir, service, servicePath /*, serviceMigrations*/, serviceRouteFileMap, serviceStaticFileMap);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/*if (inflateTests) {
|
|
94
|
-
await setupTests(logger, servicePath);
|
|
95
|
-
}*/
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (inflateDir && inflateSea) {
|
|
99
|
-
await inflateAppForSea(logger, inflateDir, services, port);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// router.use(assertGlobalTampered);
|
|
103
|
-
|
|
104
|
-
return errors.length === 0 ? [router, null, routeFileMap/*, migrations*/, wsConfigList/*, serverConfigMap*/, logConfigMap] : [router, errors, routeFileMap/*, migrations*/, wsConfigList/*, serverConfigMap*/, logConfigMap];
|
|
105
|
-
}
|
package/src/inflate/md.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import * as showdown from "showdown";
|
|
3
|
-
import { readFileSync } from "node:fs";
|
|
4
|
-
import { Logger } from "@miqro/core";
|
|
5
|
-
|
|
6
|
-
export function inflateMD2HTML(inFile: string, logger?: Logger): string {
|
|
7
|
-
try {
|
|
8
|
-
const text = readFileSync(inFile).toString();
|
|
9
|
-
const html = inflateMDString2HTML(text);
|
|
10
|
-
return html;
|
|
11
|
-
} catch (e) {
|
|
12
|
-
logger?.error("error with: " + inFile);
|
|
13
|
-
logger?.error(e);
|
|
14
|
-
throw e;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function inflateMDString2HTML(text: string, logger?: Logger): string {
|
|
19
|
-
const converter = new (showdown as any).default.Converter();
|
|
20
|
-
converter.setFlavor('github');
|
|
21
|
-
/*converter.setOption("tables", true);
|
|
22
|
-
converter.setOption("rawHeaderId", true);*/
|
|
23
|
-
const html = converter.makeHtml(text);
|
|
24
|
-
return html;
|
|
25
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Logger, Router, SessionHandler } from "@miqro/core";
|
|
2
|
-
import { importAuthModule, ImportJSXFileOptions, InflateError, inflateJSX } from "../common/jsx.js";
|
|
3
|
-
import { getAuthConfigPath } from "../common/paths.js";
|
|
4
|
-
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
5
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
6
|
-
import { cwd } from "node:process";
|
|
7
|
-
|
|
8
|
-
export async function setupAUTH(logger: Logger, servicePath: string, service: string, mainRouter: Router, inflateDir: string | undefined | false, inflateSea: boolean, options: ImportJSXFileOptions, errors: InflateError[]) {
|
|
9
|
-
const authPath = getAuthConfigPath(servicePath); //resolve(process.cwd(), service, "auth.ts");
|
|
10
|
-
|
|
11
|
-
if (authPath) {
|
|
12
|
-
try {
|
|
13
|
-
const authModule = await importAuthModule(authPath, options, logger);
|
|
14
|
-
logger.debug("setting up authentication from [%s]", join(service, basename(authPath)));
|
|
15
|
-
mainRouter.use(SessionHandler(authModule));
|
|
16
|
-
|
|
17
|
-
if (inflateDir && inflateSea) {
|
|
18
|
-
const inflatePath = resolve(inflateDir, service, "auth.cjs");
|
|
19
|
-
mkdirSync(dirname(inflatePath), {
|
|
20
|
-
recursive: true
|
|
21
|
-
});
|
|
22
|
-
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
23
|
-
writeFileSync(inflatePath, await inflateJSX(authPath, {
|
|
24
|
-
// embemedJSX: false,
|
|
25
|
-
minify: false,
|
|
26
|
-
useExport: true,
|
|
27
|
-
platform: "node",
|
|
28
|
-
logger
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
} catch (e) {
|
|
33
|
-
errors.push({
|
|
34
|
-
filePath: authPath,
|
|
35
|
-
error: e
|
|
36
|
-
});
|
|
37
|
-
logger.error("error with " + authPath);
|
|
38
|
-
logger.error(e);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { importCORSModule, ImportJSXFileOptions, InflateError, inflateJSX } from "../common/jsx.js";
|
|
3
|
-
import { getCORSConfigPath } from "../common/paths.js";
|
|
4
|
-
import { CORS, Logger, Router } from "@miqro/core";
|
|
5
|
-
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
6
|
-
import { cwd } from "node:process";
|
|
7
|
-
|
|
8
|
-
export async function setupCORS(logger: Logger, servicePath: string, service: string, mainRouter: Router, inflateDir: string | undefined | false, inflateSea: boolean, options: ImportJSXFileOptions, errors: InflateError[]) {
|
|
9
|
-
const corsPath = getCORSConfigPath(servicePath);
|
|
10
|
-
|
|
11
|
-
if (corsPath) {
|
|
12
|
-
try {
|
|
13
|
-
logger.debug("setting up cors from [%s]", join(service, basename(corsPath)));
|
|
14
|
-
const corsOptions = await importCORSModule(corsPath, options, logger);
|
|
15
|
-
|
|
16
|
-
mainRouter.use(CORS(corsOptions));
|
|
17
|
-
|
|
18
|
-
if (inflateDir && inflateSea) {
|
|
19
|
-
const inflatePath = resolve(inflateDir, service, "cors.cjs");
|
|
20
|
-
mkdirSync(dirname(inflatePath), {
|
|
21
|
-
recursive: true
|
|
22
|
-
});
|
|
23
|
-
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
24
|
-
writeFileSync(inflatePath, await inflateJSX(corsPath, {
|
|
25
|
-
// embemedJSX: false,
|
|
26
|
-
minify: false,
|
|
27
|
-
useExport: true,
|
|
28
|
-
platform: "node",
|
|
29
|
-
logger
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
} catch (e) {
|
|
34
|
-
errors.push({
|
|
35
|
-
filePath: corsPath,
|
|
36
|
-
error: e
|
|
37
|
-
});
|
|
38
|
-
logger.error("error with " + corsPath);
|
|
39
|
-
logger.error(e);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|