miqro 7.3.6 → 8.0.2
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 +3 -7
- package/build/esm/{src/bin → bin}/types.js +1 -2
- package/build/esm/{src/common → common}/arguments.d.ts +0 -2
- package/build/esm/{src/common → common}/arguments.js +5 -38
- package/build/esm/{src/common → common}/assets.js +1 -1
- package/build/esm/{src/common → common}/constants.d.ts +11 -0
- package/build/esm/{editor/common/templates.js → common/constants.js} +14 -0
- package/build/esm/{src/common → common}/esbuild.js +0 -1
- package/build/esm/common/help.d.ts +3 -0
- package/build/esm/{src/common → common}/help.js +0 -1
- package/build/esm/{src/inflate → inflate}/inflate-sea.js +3 -0
- package/build/esm/inflate/md.d.ts +1 -0
- package/build/esm/inflate/md.js +4 -0
- package/build/esm/{src/inflate → inflate}/setup-http.js +2 -3
- package/build/esm/{src/main.js → main.js} +0 -1
- package/build/esm/{src/services → services}/app.d.ts +0 -1
- package/build/esm/{src/services → services}/app.js +1 -53
- package/build/esm/{src/services → services}/utils/server-interface.js +18 -3
- package/build/esm/{src/services → services}/utils/websocketmanager.d.ts +0 -1
- package/build/esm/{src/services → services}/utils/websocketmanager.js +10 -20
- package/build/esm/{src/types.d.ts → types.d.ts} +2 -1
- package/build/lib.cjs +8391 -11627
- package/package.json +11 -23
- package/build/editor.bundle.js +0 -12329
- package/build/esm/editor/auth.d.ts +0 -6
- package/build/esm/editor/auth.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 -71
- package/build/esm/editor/common/templates.d.ts +0 -11
- package/build/esm/editor/components/api-preview.d.ts +0 -11
- package/build/esm/editor/components/api-preview.js +0 -92
- package/build/esm/editor/components/editor.d.ts +0 -16
- package/build/esm/editor/components/editor.js +0 -367
- package/build/esm/editor/components/file-browser.d.ts +0 -37
- package/build/esm/editor/components/file-browser.js +0 -127
- package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
- package/build/esm/editor/components/file-editor-toolbar.js +0 -95
- package/build/esm/editor/components/file-editor.d.ts +0 -32
- package/build/esm/editor/components/file-editor.js +0 -61
- package/build/esm/editor/components/filter-query.d.ts +0 -1
- package/build/esm/editor/components/filter-query.js +0 -23
- package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
- package/build/esm/editor/components/highlight-text-area.js +0 -127
- package/build/esm/editor/components/log-viewer.d.ts +0 -6
- package/build/esm/editor/components/log-viewer.js +0 -71
- package/build/esm/editor/components/new-file.d.ts +0 -10
- package/build/esm/editor/components/new-file.js +0 -119
- package/build/esm/editor/components/scroll-query.d.ts +0 -7
- package/build/esm/editor/components/scroll-query.js +0 -22
- package/build/esm/editor/components/start-page.d.ts +0 -13
- package/build/esm/editor/components/start-page.js +0 -32
- 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 -30
- 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 -50
- 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 -40
- 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 -150
- 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 -39
- 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 -46
- package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
- package/build/esm/editor/http/admin/editor/editor.js +0 -8
- 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/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 -12
- package/build/esm/src/common/constants.js +0 -14
- package/build/esm/src/common/help.d.ts +0 -3
- package/build/esm/src/inflate/md.d.ts +0 -3
- package/build/esm/src/inflate/md.js +0 -22
- package/build/esm/src/services/editor.d.ts +0 -3
- package/build/esm/src/services/editor.js +0 -66
- package/build/esm/src/services/utils/admin-interface.d.ts +0 -3
- package/build/esm/src/services/utils/admin-interface.js +0 -33
- package/build/style.css +0 -620
- package/editor/auth.ts +0 -53
- 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 -43
- package/editor/server.ts +0 -57
- package/editor/ws.ts +0 -17
- /package/build/esm/{src/bin → bin}/compile.d.ts +0 -0
- /package/build/esm/{src/bin → bin}/compile.js +0 -0
- /package/build/esm/{src/bin → bin}/doc-md.d.ts +0 -0
- /package/build/esm/{src/bin → bin}/doc-md.js +0 -0
- /package/build/esm/{src/bin → bin}/generate-doc.d.ts +0 -0
- /package/build/esm/{src/bin → bin}/generate-doc.js +0 -0
- /package/build/esm/{src/bin → bin}/test.d.ts +0 -0
- /package/build/esm/{src/bin → bin}/test.js +0 -0
- /package/build/esm/{src/bin → bin}/types.d.ts +0 -0
- /package/build/esm/{src/cluster.d.ts → cluster.d.ts} +0 -0
- /package/build/esm/{src/cluster.js → cluster.js} +0 -0
- /package/build/esm/{src/common → common}/admin-interface.d.ts +0 -0
- /package/build/esm/{src/common → common}/admin-interface.js +0 -0
- /package/build/esm/{src/common → common}/assets.d.ts +0 -0
- /package/build/esm/{src/common → common}/checksum.d.ts +0 -0
- /package/build/esm/{src/common → common}/checksum.js +0 -0
- /package/build/esm/{src/common → common}/content-type.d.ts +0 -0
- /package/build/esm/{src/common → common}/content-type.js +0 -0
- /package/build/esm/{src/common → common}/esbuild.d.ts +0 -0
- /package/build/esm/{src/common → common}/exit.d.ts +0 -0
- /package/build/esm/{src/common → common}/exit.js +0 -0
- /package/build/esm/{src/common → common}/fs.d.ts +0 -0
- /package/build/esm/{src/common → common}/fs.js +0 -0
- /package/build/esm/{src/common → common}/jsx.d.ts +0 -0
- /package/build/esm/{src/common → common}/jsx.js +0 -0
- /package/build/esm/{src/common → common}/jwt.d.ts +0 -0
- /package/build/esm/{src/common → common}/jwt.js +0 -0
- /package/build/esm/{src/common → common}/paths.d.ts +0 -0
- /package/build/esm/{src/common → common}/paths.js +0 -0
- /package/build/esm/{src/common → common}/watch.d.ts +0 -0
- /package/build/esm/{src/common → common}/watch.js +0 -0
- /package/build/esm/{src/inflate → inflate}/inflate-sea.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/inflate.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/inflate.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-auth.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-auth.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-cors.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-cors.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-db.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-db.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-error.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-error.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-http.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-log.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-log.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-middleware.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-middleware.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-server-config.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-server-config.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-test.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-test.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-ws.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup-ws.js +0 -0
- /package/build/esm/{src/inflate → inflate}/setup.doc.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/setup.doc.js +0 -0
- /package/build/esm/{src/inflate → inflate}/utils/sea-utils.d.ts +0 -0
- /package/build/esm/{src/inflate → inflate}/utils/sea-utils.js +0 -0
- /package/build/esm/{src/lib.d.ts → lib.d.ts} +0 -0
- /package/build/esm/{src/lib.js → lib.js} +0 -0
- /package/build/esm/{src/main.d.ts → main.d.ts} +0 -0
- /package/build/esm/{src/services → services}/hot-reload.d.ts +0 -0
- /package/build/esm/{src/services → services}/hot-reload.js +0 -0
- /package/build/esm/{src/services → services}/migrations.d.ts +0 -0
- /package/build/esm/{src/services → services}/migrations.js +0 -0
- /package/build/esm/{src/services → services}/utils/cache.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/cache.js +0 -0
- /package/build/esm/{src/services → services}/utils/cluster-cache.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/cluster-cache.js +0 -0
- /package/build/esm/{src/services → services}/utils/cluster-ws.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/cluster-ws.js +0 -0
- /package/build/esm/{src/services → services}/utils/db-manager.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/db-manager.js +0 -0
- /package/build/esm/{src/services → services}/utils/get-route.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/get-route.js +0 -0
- /package/build/esm/{src/services → services}/utils/jwt.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/jwt.js +0 -0
- /package/build/esm/{src/services → services}/utils/log-transport.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/log-transport.js +0 -0
- /package/build/esm/{src/services → services}/utils/log.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/log.js +0 -0
- /package/build/esm/{src/services → services}/utils/middleware.d.ts +0 -0
- /package/build/esm/{src/services → services}/utils/middleware.js +0 -0
- /package/build/esm/{src/services → services}/utils/server-interface.d.ts +0 -0
- /package/build/esm/{src/types.js → types.js} +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
fully typed TypeScript · REST · WebSocket · SQL · JWT · HTTP
|
|
6
6
|
|
|
7
|
-
runtime dependencies: `jose`, `esbuild`, `cookie`, `
|
|
7
|
+
runtime dependencies: `jose`, `esbuild`, `cookie`, `marked`
|
|
8
8
|
|
|
9
9
|
- **Web Components** using JSX — server-rendered and client-side
|
|
10
10
|
- **static site generation** — `.html.tsx` handlers run against a live DB at build time
|
|
@@ -12,7 +12,7 @@ runtime dependencies: `jose`, `esbuild`, `cookie`, `showdown`
|
|
|
12
12
|
- **database** — `sqlite3`, `node:sqlite`, `postgres` with migrations
|
|
13
13
|
- **cluster** — multi-worker with shared cache and hot reload
|
|
14
14
|
- **NODE:SEA** — compile to single binary, no Node.js required on target machine
|
|
15
|
-
- **
|
|
15
|
+
- **test runner**, **API doc generation**
|
|
16
16
|
|
|
17
17
|
## packages
|
|
18
18
|
|
|
@@ -169,7 +169,6 @@ all files and folders are optional.
|
|
|
169
169
|
|
|
170
170
|
```
|
|
171
171
|
miqro --service app/
|
|
172
|
-
miqro --service app/ --editor
|
|
173
172
|
```
|
|
174
173
|
|
|
175
174
|
## http folder
|
|
@@ -899,8 +898,7 @@ const app = new Miqro({
|
|
|
899
898
|
services: ["app/"],
|
|
900
899
|
port: "3000",
|
|
901
900
|
name: "myapp", // required in cluster mode
|
|
902
|
-
hotreload: false
|
|
903
|
-
editor: false
|
|
901
|
+
hotreload: false
|
|
904
902
|
});
|
|
905
903
|
|
|
906
904
|
await app.inflate({ inflateDir: "build/" }); // generate static files
|
|
@@ -1023,7 +1021,6 @@ via env or `miqro.json`:
|
|
|
1023
1021
|
```
|
|
1024
1022
|
miqro --service app/
|
|
1025
1023
|
miqro --watch --service app/
|
|
1026
|
-
miqro --editor --service app/
|
|
1027
1024
|
miqro --test --service app/
|
|
1028
1025
|
miqro --migrate-up --service app/
|
|
1029
1026
|
miqro --migrate-down --service app/
|
|
@@ -1042,7 +1039,6 @@ flags:
|
|
|
1042
1039
|
--migrate-down run migrations down
|
|
1043
1040
|
--inflate generate static files
|
|
1044
1041
|
--inflate-dir output directory (default: inflated/)
|
|
1045
|
-
--editor run with built-in editor
|
|
1046
1042
|
--generate-doc generate API documentation
|
|
1047
1043
|
--generate-doc-out output file (default: API.md)
|
|
1048
1044
|
--generate-doc-type MD | JSON | HTML (default: MD)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// import { initTypes } from "../common/assets.js";
|
|
2
2
|
import { existsSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { TEMPLATES } from "
|
|
4
|
-
import { EXIT_CODES } from "../common/constants.js";
|
|
3
|
+
import { EXIT_CODES, TEMPLATES } from "../common/constants.js";
|
|
5
4
|
import { installAsset } from "../common/assets.js";
|
|
6
5
|
export async function installTypings(args, logger) {
|
|
7
6
|
/*if (args.installTypes) {
|
|
@@ -6,7 +6,6 @@ interface MiqroJSON {
|
|
|
6
6
|
name?: string;
|
|
7
7
|
browser?: string | boolean;
|
|
8
8
|
logFile?: string | boolean;
|
|
9
|
-
editor?: boolean;
|
|
10
9
|
etag?: boolean;
|
|
11
10
|
https?: boolean;
|
|
12
11
|
serverOptions?: ServerOptions;
|
|
@@ -46,7 +45,6 @@ export interface Arguments {
|
|
|
46
45
|
inflateSEA: boolean;
|
|
47
46
|
inflateDir: string;
|
|
48
47
|
services: string[];
|
|
49
|
-
editor: boolean;
|
|
50
48
|
hotreload: boolean;
|
|
51
49
|
watch: boolean;
|
|
52
50
|
https: boolean;
|
|
@@ -26,7 +26,6 @@ const MiqroJSONSchema = {
|
|
|
26
26
|
inflateDir: "string?",
|
|
27
27
|
browser: "boolean?|string?",
|
|
28
28
|
logFile: "boolean?|string?",
|
|
29
|
-
editor: "boolean?",
|
|
30
29
|
https: "boolean?",
|
|
31
30
|
serverOptions: "any?",
|
|
32
31
|
httpsRedirect: "number?",
|
|
@@ -84,7 +83,6 @@ export function parseArguments() {
|
|
|
84
83
|
generateDocAll: null,
|
|
85
84
|
generateDocOut: null,
|
|
86
85
|
generateDocType: null,
|
|
87
|
-
editor: null,
|
|
88
86
|
inflateDir: null
|
|
89
87
|
};
|
|
90
88
|
const services = [];
|
|
@@ -395,22 +393,6 @@ export function parseArguments() {
|
|
|
395
393
|
flags.inflateSEA = true;
|
|
396
394
|
flags.inflate = true;
|
|
397
395
|
continue;
|
|
398
|
-
/*case "--install-types":
|
|
399
|
-
if (flags.inflate !== null || flags.installTypes !== null) {
|
|
400
|
-
console.error("bad arguments.");
|
|
401
|
-
console.error(usage);
|
|
402
|
-
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
403
|
-
}
|
|
404
|
-
flags.installTypes = true;
|
|
405
|
-
continue;*/
|
|
406
|
-
case "--editor":
|
|
407
|
-
if (flags.editor !== null) {
|
|
408
|
-
console.error("bad arguments.");
|
|
409
|
-
console.error(usage);
|
|
410
|
-
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
411
|
-
}
|
|
412
|
-
flags.editor = true;
|
|
413
|
-
continue;
|
|
414
396
|
case "--install-miqrojson":
|
|
415
397
|
if (flags.installMiqroJSON !== null) {
|
|
416
398
|
console.error("bad arguments. --install-miqrojson already set.");
|
|
@@ -611,18 +593,12 @@ export function parseArguments() {
|
|
|
611
593
|
flags.browser = miqroRC.browser;
|
|
612
594
|
}
|
|
613
595
|
}
|
|
614
|
-
if (flags.editor === null) {
|
|
615
|
-
if (miqroRC.editor !== undefined) {
|
|
616
|
-
flags.editor = miqroRC.editor;
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
596
|
if (flags.inflateParallel === null) {
|
|
620
597
|
if (miqroRC.inflateParallel !== undefined) {
|
|
621
598
|
flags.inflateParallel = miqroRC.inflateParallel;
|
|
622
599
|
}
|
|
623
600
|
}
|
|
624
601
|
}
|
|
625
|
-
flags.editor = flags.editor ? flags.editor : false;
|
|
626
602
|
if (services.length === 0 && (!flags.installTSConfig /* && !flags.installTypes*/ && !flags.installMiqroJSON)) {
|
|
627
603
|
flags.inflateDir = flags.inflateDir ? flags.inflateDir : undefined;
|
|
628
604
|
console.error(`bad arguments. missing --service argument`);
|
|
@@ -653,10 +629,6 @@ export function parseArguments() {
|
|
|
653
629
|
console.error("bad arguments. cannot use --install with --inflate");
|
|
654
630
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
655
631
|
}
|
|
656
|
-
if (flags.inflate && flags.editor) {
|
|
657
|
-
console.error("bad arguments. cannot use --inflate with --editor");
|
|
658
|
-
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
659
|
-
}
|
|
660
632
|
if (flags.inflate && ( /*flags.installTypes || */flags.installTSConfig || flags.installMiqroJSON || flags.install)) {
|
|
661
633
|
console.error("bad arguments. cannot use --inflate with --install, --install-tsconfig or --install-miqrojson");
|
|
662
634
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
@@ -677,23 +649,19 @@ export function parseArguments() {
|
|
|
677
649
|
console.error("bad arguments. cannot use --inflate-only-assets with --inflate-sea");
|
|
678
650
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
679
651
|
}
|
|
680
|
-
if (flags.
|
|
681
|
-
console.error("bad arguments. cannot use --
|
|
682
|
-
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
683
|
-
}
|
|
684
|
-
if (flags.test && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.inflate)) {
|
|
685
|
-
console.error("bad arguments. cannot use --editor with --test");
|
|
652
|
+
if (flags.test && (flags.watch || flags.hotreload || flags.compile || flags.inflate)) {
|
|
653
|
+
console.error("bad arguments. cannot use --inflage with --test");
|
|
686
654
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
687
655
|
}
|
|
688
|
-
if (flags.migrateUp && (flags.watch || flags.hotreload || flags.
|
|
656
|
+
if (flags.migrateUp && (flags.watch || flags.hotreload || flags.compile || flags.test || flags.migrateDown || flags.inflate)) {
|
|
689
657
|
console.error("bad arguments. cannot use with --migrate-up");
|
|
690
658
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
691
659
|
}
|
|
692
|
-
if (flags.migrateDown && (flags.watch || flags.hotreload || flags.
|
|
660
|
+
if (flags.migrateDown && (flags.watch || flags.hotreload || flags.compile || flags.test || flags.migrateUp || flags.inflate)) {
|
|
693
661
|
console.error("bad arguments. cannot use with --migrate-down");
|
|
694
662
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
695
663
|
}
|
|
696
|
-
if (flags.generateDoc && (flags.watch || flags.hotreload || flags.
|
|
664
|
+
if (flags.generateDoc && (flags.watch || flags.hotreload || flags.compile || flags.test || flags.migrateUp || flags.inflate || flags.migrateDown)) {
|
|
697
665
|
console.error("bad arguments. cannot use with --generate-doc");
|
|
698
666
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
699
667
|
}
|
|
@@ -745,7 +713,6 @@ export function parseArguments() {
|
|
|
745
713
|
generateDocOut: flags.generateDocOut ? resolve(process.cwd(), flags.generateDocOut) : generateDocType === "MD" ? resolve(process.cwd(), "API.md") : resolve(process.cwd(), "API.json"),
|
|
746
714
|
generateDocType,
|
|
747
715
|
services,
|
|
748
|
-
editor: flags.editor ? true : false,
|
|
749
716
|
https: flags.https ? true : false,
|
|
750
717
|
httpsRedirect: flags.httpsRedirect ? flags.httpsRedirect : undefined,
|
|
751
718
|
serverOptions: flags.serverOptions
|
|
@@ -8,7 +8,7 @@ import { initESBuild } from "./esbuild.js";
|
|
|
8
8
|
import { mkdirASync, unlinkASync, writeFileASync } from "./fs.js";
|
|
9
9
|
// import { initJSXJS } from "./jsx.js";
|
|
10
10
|
//const require = createRequire(import.meta.url);
|
|
11
|
-
export const __package_dirname = import.meta.url ? resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", ".."
|
|
11
|
+
export const __package_dirname = import.meta.url ? resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..") : null;
|
|
12
12
|
const ASSETS_ROUTER = {
|
|
13
13
|
"lib.cjs": "build/lib.cjs",
|
|
14
14
|
"version.tag": "sea/version.tag",
|
|
@@ -10,3 +10,14 @@ export declare const CLEAR_JSX_CACHE: boolean;
|
|
|
10
10
|
export declare const EDITOR_CONFIG_KEY = "$$editor$$";
|
|
11
11
|
export declare const HOT_RELOAD_PATH = "/hot-reload";
|
|
12
12
|
export declare const HOT_RELOAD_SCRIPT_PATH = "/hot-reload.js";
|
|
13
|
+
export declare const TEMPLATES: {
|
|
14
|
+
[name: string]: {
|
|
15
|
+
displayName: string;
|
|
16
|
+
template?: ((filename: string, httpPath: string) => string);
|
|
17
|
+
httpSufix?: string;
|
|
18
|
+
sufix?: string;
|
|
19
|
+
prefix?: string;
|
|
20
|
+
language: string;
|
|
21
|
+
filename?: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
export const EXIT_CODES = {
|
|
2
|
+
BAD_ARGUMENTS: 10,
|
|
3
|
+
NORMAL_EXIT: 0,
|
|
4
|
+
GLOBALS_ALTERED: 80,
|
|
5
|
+
ABNORMAL: 98,
|
|
6
|
+
ABNORMAL_UNCONTROLLED: 99,
|
|
7
|
+
TEST_FAILED: 30,
|
|
8
|
+
};
|
|
9
|
+
export const CLEAR_JSX_CACHE = (process.env["CLEAR_JSX_CACHE"] !== undefined ? process.env["CLEAR_JSX_CACHE"] : "1") === "1";
|
|
10
|
+
export const EDITOR_CONFIG_KEY = "$$editor$$";
|
|
11
|
+
export const HOT_RELOAD_PATH = "/hot-reload";
|
|
12
|
+
export const HOT_RELOAD_SCRIPT_PATH = "/hot-reload.js";
|
|
13
|
+
//export const SERVER_IDENTIFIER = cluster.isPrimary ? "SERVER" : process.env["CLUSTER_NODE_NUMBER"] ? `WORKER_${process.env["CLUSTER_NODE_NUMBER"]}` : "WORKER";
|
|
14
|
+
//export const DB_IDENTIFIER = cluster.isPrimary ? "DATABASE" : process.env["CLUSTER_NODE_NUMBER"] ? `WORKER_${process.env["CLUSTER_NODE_NUMBER"]}_DATABASE` : "WORKER_DATABASE";
|
|
1
15
|
export const TEMPLATES = {
|
|
2
16
|
EMPTY: {
|
|
3
17
|
displayName: "empty file",
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const BIN_NAME = "miqro";
|
|
2
|
+
export declare const usage = "usage: miqro [...FLAGS] --service app/\n\n==examples==\n\nmiqro --watch --service front/\nPORT=8181 miqro --service api/ --service front/\nmiqro --test --service front/\nmiqro --inflate --service front/\nmiqro --generate-doc --generate-doc-out API.md --service front/\nCLUSTER_COUNT=10 miqro-cluster --service api/";
|
|
3
|
+
export declare const help = "\n==flags==\n\n-v, --version\n\toutputs the version number\n-h, --help\n\toutputs this page.\n--disable-etag\n\tuse to disable etag generation by default. each route can still enable this.\n--enable-etag\n\tuse to enable etag generation by default. each route can still disable this. ( by default etag is enabled )\n--watch\n\tuse to auto reload the server when files change.\n--hot-reload\n\tenables the hot-reload functionality use with --watch.\n--test\n\trun the tests for a service.\n--migrate-up\n\tmigrations up.\n--migrate-down\n\tmigrations down.\n--inflate\n\tinflates the application into a directory using esbuild.\n--inflate-dir\n\tto set the output directory of the --inflate command. default value is inflated/.\n--generate-doc\n\tgenerates a documentation for the api endpoints of the service.\n--generate-doc-out\n\tthe output file for the generated documentation. default value is API.md.\n--generate-doc-type\n\tthe format of the generated documentation. it can be JSON or MD. default value is MD.\n--generate-doc-all\n\toutputs all the server routes in the documentation output.\n--compile\n\tinflates the application and tries to create a NODE SEA binary.\n--no-build\n\tdisables calling esbuild during imports in runtime. Notice that to use jsx you will need to run tsc or esbuild on your jsx files to transpile them to js.\n--no-minify\n\tdisables calling minifing min.js files.\n--inflate-only-assets\n\tinflates ONLY the application assets. must be used with --inflate.\n--inflate-flat\n\tinflates files into the inflate-dir directly.\n--inflate-sea\n\tinflates the application with sea compilation scripts.\n--install-tsconfig\n\tcreates a tsconfig.json configured to use with --install-types.\n--install-miqrojson\n\tcreates a default miqro.json file.\n--install\n\tcreates a node_modules folder from binary cache (only available in sea binary).\n--disable-miqrojson\n\tdisables the load of miqro.json file.\n--log-file\n\toverrides the default log file from LOG_FILE.\n--browser\n\toverrides the default browser from BROWSER.\n--config\n\toverrides the default miqro.json path.\n--port\n\toverrides the default port from PORT.\n--name\n\toverrides the default name of the server.\n--https\n\tserves the server in https instead of http\n--https-key\n\tpoint to a server.key file for https.\n--https-cert\n\tpoint to a server.cert file for https.\n--https-redirect\n\tserves an aditional http server that redirects to https. it needs a port number.\n--inflate-parallel\n\tsets the max parallel esbuild instances. defaults to 1.\n\n==environment variables==\n\nPORT\n\toverride the default 8080 port.\nBROWSER\n\toverride the default browser. change to none to disable.\".\nLOG_FILE\n\toverride the default ./server.log file\nDB\n\tenable the server.db features\nDB_STORAGE\n\toverride the default local db location ./db.sqlite3\nDB_DIALECT\n\toverride the default node:sqlite\nDB_CONNECTION\n\toverride the default connection url\nCLEAR_JSX_CACHE\n\tset to 1 or 0 to enable or disable the clearing of the esbuild cache defaults to 1.\nJSX_TMP\n\tset custom location of esbuild builds defaults to /tmp/jsx_tmp.\n";
|
|
@@ -24,7 +24,6 @@ export const help = `
|
|
|
24
24
|
--migrate-down\n\tmigrations down.
|
|
25
25
|
--inflate\n\tinflates the application into a directory using esbuild.
|
|
26
26
|
--inflate-dir\n\tto set the output directory of the --inflate command. default value is inflated/.
|
|
27
|
-
--editor\n\truns the application with a built-in editor.
|
|
28
27
|
--generate-doc\n\tgenerates a documentation for the api endpoints of the service.
|
|
29
28
|
--generate-doc-out\n\tthe output file for the generated documentation. default value is API.md.
|
|
30
29
|
--generate-doc-type\n\tthe format of the generated documentation. it can be JSON or MD. default value is MD.
|
|
@@ -61,6 +61,8 @@ export async function inflateAppForSea(logger, inflateDir, services, port) {
|
|
|
61
61
|
writeFile(logger, join(inflateDir, "sea", "package.json"), `{ "type": "module", "private": true }`);
|
|
62
62
|
writeFile(logger, join(inflateDir, "sea", "app.cjs"), `const { createLogProviderOptions, createServerInterface, ServerRequestHandler, WebSocketManager, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
|
|
63
63
|
|
|
64
|
+
const pg = require("pg");
|
|
65
|
+
|
|
64
66
|
async function main() {
|
|
65
67
|
const PORT = "${PORT}";
|
|
66
68
|
|
|
@@ -131,6 +133,7 @@ main().catch(e=>console.error(e));
|
|
|
131
133
|
jsxFactory: "JSX.createElement",
|
|
132
134
|
jsxFragment: "JSX.Fragment",
|
|
133
135
|
platform: "node",
|
|
136
|
+
external: ["node:*"],
|
|
134
137
|
outfile: join(inflateDir, "sea", "app.bundle.cjs")
|
|
135
138
|
});
|
|
136
139
|
const miqroRCPath = getMiqroJSONPath();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function inflateMDString2HTML(text: string): Promise<string>;
|
|
@@ -6,13 +6,12 @@ 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";
|
|
10
9
|
import { getHTTPRouterPath, getStaticFilesPath } from "../common/paths.js";
|
|
11
10
|
import { setupCORS } from "./setup-cors.js";
|
|
12
11
|
import { setupAUTH } from "./setup-auth.js";
|
|
13
12
|
import { getRoutes } from "../services/utils/get-route.js";
|
|
14
13
|
import { describeFilePath, mkdirASync, writeFileASync } from "../common/fs.js";
|
|
15
|
-
import {
|
|
14
|
+
import { inflateMDString2HTML } from "./md.js";
|
|
16
15
|
import { setupMiddleware } from "./setup-middleware.js";
|
|
17
16
|
import { setupError } from "./setup-error.js";
|
|
18
17
|
export async function setupHTTPRouter(importOptions, inflateOptions, server, logger, hotreload, servicePath, service, routeFileMap, staticFileMap, inflateDir, inflateSea, errors, inflateParallel) {
|
|
@@ -387,7 +386,7 @@ async function createRouterFromDirectory(importOptions, inflateJSXOptions, serve
|
|
|
387
386
|
case ".md": {
|
|
388
387
|
switch (file.subExt) {
|
|
389
388
|
case ".html": {
|
|
390
|
-
const code = await
|
|
389
|
+
const code = await inflateMDString2HTML(readFileSync(file.filePath).toString());
|
|
391
390
|
const contentType = CONTENT_TYPE_MAP[".html"];
|
|
392
391
|
const path = join("/", dirname(relative(dir, file.filePath)), file.name);
|
|
393
392
|
routeFileMap[file.filePath] = {
|
|
@@ -5,11 +5,7 @@ import { WebSocketManager } from "./utils/websocketmanager.js";
|
|
|
5
5
|
import { DBManager } from "./utils/db-manager.js";
|
|
6
6
|
import { inflateApp } from "../inflate/inflate.js";
|
|
7
7
|
import { setupServerConfig } from "../inflate/setup-server-config.js";
|
|
8
|
-
import { BASEEDITOR_PATH, LOG_SOCKET_PATH, LOG_WRITE_EVENT } from "../../editor/common/constants.js";
|
|
9
|
-
import editorWSConfig from "../../editor/ws.js";
|
|
10
|
-
import editorServerConfig from "../../editor/server.js";
|
|
11
8
|
import { ClusterCache } from "./utils/cluster-cache.js";
|
|
12
|
-
import { createEditorRouter } from "./editor.js";
|
|
13
9
|
import { EDITOR_CONFIG_KEY, HOT_RELOAD_PATH, HOT_RELOAD_SCRIPT_PATH } from "../common/constants.js";
|
|
14
10
|
import { watchAndServer } from "../common/watch.js";
|
|
15
11
|
import { LocalCache } from "./utils/cache.js";
|
|
@@ -21,7 +17,6 @@ import { getServicePath } from "../common/paths.js";
|
|
|
21
17
|
import { createServerInterface } from "./utils/server-interface.js";
|
|
22
18
|
import { getPORT, importMiqroJSON } from "../common/arguments.js";
|
|
23
19
|
import { createLogProviderOptions } from "./utils/log-transport.js";
|
|
24
|
-
import { createAdminInterface } from "./utils/admin-interface.js";
|
|
25
20
|
import { dirname, join, relative, resolve } from "node:path";
|
|
26
21
|
import { cwd } from "node:process";
|
|
27
22
|
import { HOT_RELOAD_JS_SCRIPT } from "./hot-reload.js";
|
|
@@ -48,7 +43,6 @@ export class Miqro {
|
|
|
48
43
|
this.options = {
|
|
49
44
|
noMinify: false,
|
|
50
45
|
etag: true,
|
|
51
|
-
editor: false,
|
|
52
46
|
name: "server",
|
|
53
47
|
noBuild: false,
|
|
54
48
|
port: getPORT(),
|
|
@@ -56,7 +50,6 @@ export class Miqro {
|
|
|
56
50
|
...(options ? options : {})
|
|
57
51
|
};
|
|
58
52
|
const loggerOptions = createLogProviderOptions(this);
|
|
59
|
-
loggerOptions.transports.push(createEditorLoggerTransport(this));
|
|
60
53
|
this.loggerProvider = new LogProvider(loggerOptions);
|
|
61
54
|
//if (!this.options.logger) {
|
|
62
55
|
const SERVER_IDENTIFIER = cluster.isPrimary ?
|
|
@@ -97,8 +90,7 @@ export class Miqro {
|
|
|
97
90
|
this.webSocketManager = new WebSocketManager({
|
|
98
91
|
logger: this.logger,
|
|
99
92
|
loggerProvider: this.loggerProvider,
|
|
100
|
-
name: `MiqroApplicationWebsocketManager[${this.options.name}]
|
|
101
|
-
avoidLogSocket: this.options.editor
|
|
93
|
+
name: `MiqroApplicationWebsocketManager[${this.options.name}]`
|
|
102
94
|
});
|
|
103
95
|
this.listener = this.listener.bind(this);
|
|
104
96
|
//this.requestLoggerFactory = this.requestLoggerFactory.bind(this);
|
|
@@ -118,7 +110,6 @@ export class Miqro {
|
|
|
118
110
|
port: this.options.port
|
|
119
111
|
});
|
|
120
112
|
this.serverRequestHandler = ServerRequestHandler(this.serverInterface);
|
|
121
|
-
this.adminInterface = createAdminInterface(this);
|
|
122
113
|
this.webSocketManager.adminInterface = this.adminInterface;
|
|
123
114
|
setupExitHandlers(this);
|
|
124
115
|
}
|
|
@@ -272,15 +263,6 @@ export class Miqro {
|
|
|
272
263
|
await Promise.all(dbList.map(db => this.dbManager.setupDB(db.dbConfig)));
|
|
273
264
|
/* setup server config before inflate app router and ws and bs for preload*/
|
|
274
265
|
const { errors: serviceConfigErrors, serverConfigMap } = await this.loadServerConfig(options);
|
|
275
|
-
// editor WSConfig must be put a head of the service WSConfig to avoid LOG_SOCKET replacement
|
|
276
|
-
if (this.options.editor) {
|
|
277
|
-
this.logger?.debug("setting up editor on %s", BASEEDITOR_PATH);
|
|
278
|
-
const editorRouter = await createEditorRouter(this.adminInterface);
|
|
279
|
-
router.use(editorRouter);
|
|
280
|
-
this.logger?.debug("setting up log websocket on [%s]", LOG_SOCKET_PATH);
|
|
281
|
-
wsConfigList.push(editorWSConfig);
|
|
282
|
-
serverConfigMap[EDITOR_CONFIG_KEY] = editorServerConfig;
|
|
283
|
-
}
|
|
284
266
|
if (this.options?.hotreload /* && !options?.inflateTests*/) {
|
|
285
267
|
this.logger?.debug("setting up websocket on [%s]", HOT_RELOAD_PATH);
|
|
286
268
|
wsConfigList.push({
|
|
@@ -562,11 +544,6 @@ function reloadInflatedRouter(app) {
|
|
|
562
544
|
app.logger?.debug("load running server with new routes");
|
|
563
545
|
app.server.use(app.serverRequestHandler);
|
|
564
546
|
app.server.use(LoggerHandler());
|
|
565
|
-
if (app.options.editor) {
|
|
566
|
-
app.server.use(async (req, res) => {
|
|
567
|
-
res.setHeader("x-uuid", req.uuid);
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
547
|
app.server.use(app.inflated.router);
|
|
571
548
|
}
|
|
572
549
|
async function notifiyServerConfig(logger, serverInterface, adminInterface, serverConfigMap, method) {
|
|
@@ -610,32 +587,3 @@ export function notifiyServerConfigSync(app, method) {
|
|
|
610
587
|
});
|
|
611
588
|
}
|
|
612
589
|
}
|
|
613
|
-
function createEditorLoggerTransport(app) {
|
|
614
|
-
return {
|
|
615
|
-
level: "trace",
|
|
616
|
-
write: async (args) => {
|
|
617
|
-
try {
|
|
618
|
-
if (app.options.editor) {
|
|
619
|
-
try {
|
|
620
|
-
const ws = app.webSocketManager.getWS(LOG_SOCKET_PATH);
|
|
621
|
-
if (ws) {
|
|
622
|
-
//console.log("\n\n" + process.pid + " broadcasting " + LOG_SOCKET_PATH + "\n\n\n")
|
|
623
|
-
await ws.broadcast(JSON.stringify({
|
|
624
|
-
type: LOG_WRITE_EVENT,
|
|
625
|
-
level: args.level,
|
|
626
|
-
identifier: args.identifier,
|
|
627
|
-
out: args.out
|
|
628
|
-
}));
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
catch (e) {
|
|
632
|
-
console.error(e);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
catch (e) {
|
|
637
|
-
console.error(e);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
};
|
|
641
|
-
}
|
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
import cluster from "node:cluster";
|
|
2
2
|
import { execSync } from "node:child_process";
|
|
3
|
-
import { HTMLEncode } from "../../../editor/common/html-encode.js";
|
|
4
|
-
import { inflateMD2HTML } from "../../inflate/md.js";
|
|
5
3
|
import { Parser } from "@miqro/parser";
|
|
6
4
|
import { ClusterCache } from "./cluster-cache.js";
|
|
7
5
|
import { LocalCache } from "./cache.js";
|
|
8
6
|
import { middleware } from "./middleware.js";
|
|
9
7
|
import { jwt } from "./jwt.js";
|
|
8
|
+
import { inflateMDString2HTML } from "../../inflate/md.js";
|
|
9
|
+
import { jsx2HTML } from "../../lib.js";
|
|
10
|
+
function HTMLEncode(str) {
|
|
11
|
+
let i = str.length;
|
|
12
|
+
const aRet = [];
|
|
13
|
+
while (i--) {
|
|
14
|
+
const iC = str[i].charCodeAt(0);
|
|
15
|
+
if (iC < 65 || iC > 127 || (iC > 90 && iC < 97)) {
|
|
16
|
+
aRet[i] = '&#' + iC + ';';
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
aRet[i] = str[i];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return aRet.join('');
|
|
23
|
+
}
|
|
10
24
|
export function createServerInterface(options) {
|
|
11
25
|
// initGlobals();
|
|
12
26
|
return Object.freeze({
|
|
13
27
|
middleware,
|
|
28
|
+
getHTML: jsx2HTML,
|
|
14
29
|
encodeHTML: HTMLEncode,
|
|
15
|
-
inflateMDtoHTML:
|
|
30
|
+
inflateMDtoHTML: inflateMDString2HTML,
|
|
16
31
|
newParser() {
|
|
17
32
|
return new Parser();
|
|
18
33
|
},
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LOG_SOCKET_PATH } from "../../../editor/common/constants.js";
|
|
2
1
|
import { ClusterWebSocketServer2 } from "./cluster-ws.js";
|
|
3
2
|
export class WebSocketManager {
|
|
4
3
|
runningGlobalWSMap = new Map();
|
|
@@ -12,7 +11,6 @@ export class WebSocketManager {
|
|
|
12
11
|
this.logger = options && options.logger ? options.logger : null;
|
|
13
12
|
this.name = options && options.name ? options.name : "WebSocketManager";
|
|
14
13
|
this.loggerProvider = options && options.loggerProvider;
|
|
15
|
-
this.avoidLogSocket = options && options.avoidLogSocket ? options.avoidLogSocket : false;
|
|
16
14
|
}
|
|
17
15
|
deleteWS(path) {
|
|
18
16
|
const ws = this.runningGlobalWSMap.get(path);
|
|
@@ -46,22 +44,18 @@ export class WebSocketManager {
|
|
|
46
44
|
}
|
|
47
45
|
replaceALLWSBuLOGSocket(list) {
|
|
48
46
|
for (const path of this.runningGlobalWSMap.keys()) {
|
|
49
|
-
|
|
50
|
-
this.deleteWS(path);
|
|
51
|
-
}
|
|
47
|
+
this.deleteWS(path);
|
|
52
48
|
}
|
|
53
49
|
for (const wsConfig of list) {
|
|
54
50
|
if (!wsConfig.disabled) {
|
|
55
|
-
if (wsConfig.path
|
|
56
|
-
|
|
57
|
-
throw new Error(`ws on path ${wsConfig.path} already setup!`);
|
|
58
|
-
}
|
|
59
|
-
this.logger?.debug("setting up websocket on [%s]", wsConfig.path);
|
|
60
|
-
const identifier = wsConfig.path.replaceAll("/", "_").toUpperCase();
|
|
61
|
-
const logger = this.loggerProvider && identifier.length >= 0 ? this.loggerProvider.getLogger(identifier.substring(identifier.charAt(0) === "_" ? 1 : 0)) : this.logger;
|
|
62
|
-
const server = new ClusterWebSocketServer2(this.name + wsConfig.path, wsConfig.path, logger, wsConfig);
|
|
63
|
-
this.runningGlobalWSMap.set(wsConfig.path, server);
|
|
51
|
+
if (this.runningGlobalWSMap.has(wsConfig.path)) {
|
|
52
|
+
throw new Error(`ws on path ${wsConfig.path} already setup!`);
|
|
64
53
|
}
|
|
54
|
+
this.logger?.debug("setting up websocket on [%s]", wsConfig.path);
|
|
55
|
+
const identifier = wsConfig.path.replaceAll("/", "_").toUpperCase();
|
|
56
|
+
const logger = this.loggerProvider && identifier.length >= 0 ? this.loggerProvider.getLogger(identifier.substring(identifier.charAt(0) === "_" ? 1 : 0)) : this.logger;
|
|
57
|
+
const server = new ClusterWebSocketServer2(this.name + wsConfig.path, wsConfig.path, logger, wsConfig);
|
|
58
|
+
this.runningGlobalWSMap.set(wsConfig.path, server);
|
|
65
59
|
}
|
|
66
60
|
}
|
|
67
61
|
}
|
|
@@ -99,9 +93,7 @@ export class WebSocketManager {
|
|
|
99
93
|
disconnectAllButLOGSocket() {
|
|
100
94
|
try {
|
|
101
95
|
for (const wsPath of this.runningGlobalWSMap.keys()) {
|
|
102
|
-
|
|
103
|
-
this.disconnectAllFrom(wsPath);
|
|
104
|
-
}
|
|
96
|
+
this.disconnectAllFrom(wsPath);
|
|
105
97
|
}
|
|
106
98
|
}
|
|
107
99
|
catch (e) {
|
|
@@ -124,9 +116,7 @@ export class WebSocketManager {
|
|
|
124
116
|
try {
|
|
125
117
|
const wsServer = this.getWS(req.path);
|
|
126
118
|
if (wsServer) {
|
|
127
|
-
|
|
128
|
-
req.editor = this.adminInterface;
|
|
129
|
-
}
|
|
119
|
+
req.editor = this.adminInterface;
|
|
130
120
|
const ret = wsServer.onUpgrade(req, socket, head);
|
|
131
121
|
delete req.editor;
|
|
132
122
|
return ret;
|
|
@@ -75,8 +75,9 @@ export interface JWTInterface {
|
|
|
75
75
|
decode: <PayloadType = JWTPayload>(jwt: string) => PayloadType & JWTPayload;
|
|
76
76
|
}
|
|
77
77
|
export interface ServerGlobal {
|
|
78
|
+
getHTML: (out: JSX.Element, runtime?: Runtime) => string;
|
|
78
79
|
encodeHTML: (str: string) => string;
|
|
79
|
-
inflateMDtoHTML: (str: string) => string
|
|
80
|
+
inflateMDtoHTML: (str: string) => Promise<string>;
|
|
80
81
|
middleware: {
|
|
81
82
|
buffer: typeof ReadBuffer;
|
|
82
83
|
url: typeof URLEncodedParser;
|