miqro 6.3.0 → 7.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 +9 -17
- package/build/editor.bundle.js +11601 -10129
- package/build/esm/editor/common/log-socket.js +1 -0
- package/build/esm/editor/common/templates.js +90 -90
- package/build/esm/editor/components/api-preview.js +2 -0
- package/build/esm/editor/components/editor.js +2 -0
- package/build/esm/editor/components/file-browser.js +1 -0
- package/build/esm/editor/components/file-editor-toolbar.js +2 -0
- package/build/esm/editor/components/file-editor.js +2 -0
- package/build/esm/editor/components/filter-query.js +1 -0
- package/build/esm/editor/components/highlight-text-area.js +2 -0
- package/build/esm/editor/components/log-viewer.js +2 -0
- package/build/esm/editor/components/new-file.js +2 -0
- package/build/esm/editor/components/scroll-query.js +1 -0
- package/build/esm/editor/components/start-page.js +2 -0
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +2 -1
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +2 -1
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +2 -1
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +2 -1
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js +2 -1
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js +2 -1
- package/build/esm/editor/http/admin/editor/editor.js +2 -1
- package/build/esm/editor/http/admin/editor/index.api.js +1 -0
- 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 +1 -1
- package/build/esm/src/common/arguments.js +28 -14
- 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 +0 -1
- 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 +1 -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 +1 -1
- package/build/esm/src/services/app.js +3 -4
- 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 +15684 -15612
- package/editor/common/log-socket.tsx +2 -0
- package/editor/common/templates.ts +12 -12
- package/editor/components/api-preview.tsx +2 -0
- package/editor/components/editor.tsx +2 -0
- package/editor/components/file-browser.tsx +3 -0
- package/editor/components/file-editor-toolbar.tsx +3 -0
- package/editor/components/file-editor.tsx +3 -0
- package/editor/components/filter-query.tsx +4 -0
- package/editor/components/highlight-text-area.tsx +3 -0
- package/editor/components/log-viewer.tsx +3 -0
- package/editor/components/new-file.tsx +3 -0
- package/editor/components/scroll-query.tsx +3 -0
- package/editor/components/start-page.tsx +3 -0
- package/editor/http/admin/editor/api/fs/delete.api.tsx +2 -2
- package/editor/http/admin/editor/api/fs/read.api.tsx +2 -2
- package/editor/http/admin/editor/api/fs/rename.api.tsx +2 -2
- package/editor/http/admin/editor/api/fs/scan.api.tsx +2 -2
- package/editor/http/admin/editor/api/fs/write.api.tsx +2 -2
- package/editor/http/admin/editor/api/server/restart.api.tsx +2 -2
- package/editor/http/admin/editor/editor.tsx +3 -1
- package/editor/http/admin/editor/index.api.tsx +3 -0
- 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/src/bin/types.ts +7 -2
- package/src/cluster.ts +1 -1
- package/src/common/arguments.ts +27 -10
- package/src/common/assets.ts +32 -12
- package/src/common/esbuild.ts +11 -3
- package/src/common/exit.ts +3 -3
- package/src/common/help.ts +0 -1
- package/src/common/jsx.ts +50 -35
- package/src/common/paths.ts +2 -2
- package/src/common/watch.ts +1 -1
- package/src/inflate/inflate-sea.ts +35 -24
- package/src/inflate/inflate.ts +4 -4
- package/src/inflate/setup-auth.ts +1 -1
- package/src/inflate/setup-cors.ts +1 -1
- package/src/inflate/setup-db.ts +2 -2
- package/src/inflate/setup-error.ts +1 -1
- package/src/inflate/setup-http.ts +16 -16
- package/src/inflate/setup-log.ts +1 -1
- package/src/inflate/setup-middleware.ts +1 -1
- package/src/inflate/setup-server-config.ts +1 -1
- package/src/inflate/setup-ws.ts +1 -1
- package/src/inflate/setup.doc.ts +27 -3
- package/src/inflate/utils/sea-utils.ts +2 -2
- package/src/lib.ts +17 -2
- package/src/main.ts +1 -1
- package/src/services/app.ts +4 -4
- package/src/services/migrations.ts +2 -2
- package/src/services/utils/jwt.ts +25 -0
- package/src/services/utils/middleware.ts +10 -0
- package/src/services/utils/server-interface.ts +37 -7
- package/src/types.ts +56 -53
- package/.eslintrc +0 -15
- 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/sea/types.json +0 -1
- 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/tsconfig.json +0 -35
- /package/src/services/{globals.ts → globals.ts.ignore} +0 -0
|
@@ -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,
|
|
@@ -17,7 +17,7 @@ export async function setupServerConfig(logger, servicePath, service, serverConf
|
|
|
17
17
|
});
|
|
18
18
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
19
19
|
writeFileSync(inflatePath, await inflateJSX(serverPath, {
|
|
20
|
-
embemedJSX: false,
|
|
20
|
+
// embemedJSX: false,
|
|
21
21
|
minify: false,
|
|
22
22
|
platform: "node",
|
|
23
23
|
useExport: true,
|
|
@@ -24,7 +24,7 @@ export async function inflateWSConfig(logger, servicePath, service, wsConfigList
|
|
|
24
24
|
});
|
|
25
25
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
26
26
|
writeFileSync(inflatePath, await inflateJSX(wsPath, {
|
|
27
|
-
embemedJSX: false,
|
|
27
|
+
// embemedJSX: false,
|
|
28
28
|
minify: false,
|
|
29
29
|
platform: "node",
|
|
30
30
|
useExport: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Logger, Router } from "@miqro/core";
|
|
2
2
|
import { InflateError } from "../common/jsx.js";
|
|
3
|
-
import { RouteFileMap } from "./setup-http.js";
|
|
4
|
-
export declare function setupDoc(logger: Logger, servicePath: string, service: string, mainRouter: Router, fileMap: RouteFileMap, inflateDir: string | undefined | false, errors: InflateError[]): Promise<any>;
|
|
3
|
+
import { RouteFileMap, StaticFileMap } from "./setup-http.js";
|
|
4
|
+
export declare function setupDoc(logger: Logger, servicePath: string, service: string, mainRouter: Router, fileMap: RouteFileMap, staticFileMap: StaticFileMap, inflateDir: string | undefined | false, errors: InflateError[]): Promise<any>;
|
|
@@ -5,7 +5,7 @@ import { mkdirSync, writeFileSync } from "node:fs";
|
|
|
5
5
|
import { cwd } from "node:process";
|
|
6
6
|
import { getDocOutput } from "../bin/generate-doc.js";
|
|
7
7
|
import { CONTENT_TYPE_MAP } from "../common/content-type.js";
|
|
8
|
-
export async function setupDoc(logger, servicePath, service, mainRouter, fileMap, inflateDir, errors) {
|
|
8
|
+
export async function setupDoc(logger, servicePath, service, mainRouter, fileMap, staticFileMap, inflateDir, errors) {
|
|
9
9
|
const docPath = getDocConfigPath(servicePath); //resolve(process.cwd(), service, "auth.ts");
|
|
10
10
|
if (docPath) {
|
|
11
11
|
try {
|
|
@@ -15,11 +15,12 @@ export async function setupDoc(logger, servicePath, service, mainRouter, fileMap
|
|
|
15
15
|
const paths = Object.keys(docModule.publish);
|
|
16
16
|
for (const path of paths) {
|
|
17
17
|
const config = docModule.publish[path];
|
|
18
|
+
const contentType = config.type === "MD" ? CONTENT_TYPE_MAP[".md"] :
|
|
19
|
+
config.type === "JSON" ? CONTENT_TYPE_MAP[".json"] : CONTENT_TYPE_MAP[".html"];
|
|
18
20
|
const body = await getDocOutput(mainRouter, fileMap, config.all, config.type);
|
|
19
21
|
mainRouter.get(path, async (_, res) => {
|
|
20
22
|
switch (config.type) {
|
|
21
23
|
case "MD": {
|
|
22
|
-
const contentType = CONTENT_TYPE_MAP[".md"];
|
|
23
24
|
return await res.asyncEnd({
|
|
24
25
|
headers: {
|
|
25
26
|
"content-type": contentType
|
|
@@ -45,6 +46,26 @@ export async function setupDoc(logger, servicePath, service, mainRouter, fileMap
|
|
|
45
46
|
});
|
|
46
47
|
logger.log("writing [%s]", relative(cwd(), inflatePath));
|
|
47
48
|
writeFileSync(inflatePath, body);
|
|
49
|
+
fileMap[docPath + path] = {
|
|
50
|
+
routes: [{
|
|
51
|
+
method: "GET",
|
|
52
|
+
path
|
|
53
|
+
}],
|
|
54
|
+
service,
|
|
55
|
+
filePath: docPath,
|
|
56
|
+
previewMethod: "html"
|
|
57
|
+
};
|
|
58
|
+
if (staticFileMap) {
|
|
59
|
+
staticFileMap[docPath + path] = {
|
|
60
|
+
contentType,
|
|
61
|
+
filePath: docPath,
|
|
62
|
+
previewMethod: "html",
|
|
63
|
+
method: "GET",
|
|
64
|
+
path,
|
|
65
|
+
body: Buffer.from(body),
|
|
66
|
+
inflatePath: inflateDir ? join(inflateDir, service, "static", path) : undefined
|
|
67
|
+
};
|
|
68
|
+
}
|
|
48
69
|
}
|
|
49
70
|
}
|
|
50
71
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describeFilePath } from "../../common/fs.js";
|
|
2
2
|
import { getRoutes } from "../../services/utils/get-route.js";
|
|
3
|
-
import { assertGlobalTampered } from "../../services/globals.js";
|
|
3
|
+
// import { assertGlobalTampered } from "../../services/globals.js";
|
|
4
4
|
import { dirname, join, relative } from "node:path";
|
|
5
5
|
export async function appendAPIModule(router, dir, filePath, module) {
|
|
6
6
|
const file = describeFilePath(filePath);
|
|
7
7
|
const routes = getRoutes(join("/", dirname(relative(dir, file.filePath))), file.subName, module);
|
|
8
8
|
for (const r of routes) {
|
|
9
|
-
router.use(assertGlobalTampered);
|
|
9
|
+
// router.use(assertGlobalTampered);
|
|
10
10
|
router.use(module.handler, r.path, r.method, r.options);
|
|
11
11
|
}
|
|
12
12
|
}
|
package/build/esm/src/lib.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Component, enableDebugLog, Fragment, Props } from "@miqro/jsx";
|
|
1
2
|
export * from "./types.js";
|
|
2
3
|
export { ClusterWebSocketServer2 } from "./services/utils/cluster-ws.js";
|
|
3
4
|
export { ClusterCache } from "./services/utils/cluster-cache.js";
|
|
@@ -6,8 +7,16 @@ export { WebSocketManager, WebSocketManagerOptions } from "./services/utils/webs
|
|
|
6
7
|
export { DBManager } from "./services/utils/db-manager.js";
|
|
7
8
|
export { LogProvider, LogProviderOptions } from "./services/utils/log.js";
|
|
8
9
|
export { Miqro, MiqroOptions, ServerRequestHandler } from "./services/app.js";
|
|
9
|
-
export {
|
|
10
|
+
export { jsx2HTML } from "./common/jsx.js";
|
|
10
11
|
export { appendAPIModule } from "./inflate/utils/sea-utils.js";
|
|
11
12
|
export { createServerInterface, ServerInterfaceImplOptions } from "./services/utils/server-interface.js";
|
|
12
13
|
export { App, LoggerHandler, Router } from "@miqro/core";
|
|
13
14
|
export { migration } from "@miqro/query";
|
|
15
|
+
export { middleware } from "./services/utils/middleware.js";
|
|
16
|
+
export { jwt } from "./services/utils/jwt.js";
|
|
17
|
+
export declare const JSX: {
|
|
18
|
+
createElement: (tag: string | Component<any> | typeof Fragment, attributes: Props<any>, ...children: any[]) => JSX.Element;
|
|
19
|
+
Fragment: symbol;
|
|
20
|
+
enableDebugLog: typeof enableDebugLog;
|
|
21
|
+
};
|
|
22
|
+
export * as jsx from "@miqro/jsx";
|
package/build/esm/src/lib.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { enableDebugLog, Fragment, createElement as realCreateElement } from "@miqro/jsx";
|
|
2
|
+
import { jsx2HTML } from "./common/jsx.js";
|
|
1
3
|
/*export * from "@miqro/core";
|
|
2
4
|
export * from "@miqro/query";*/
|
|
3
5
|
export * from "./types.js";
|
|
@@ -8,9 +10,22 @@ export { WebSocketManager } from "./services/utils/websocketmanager.js";
|
|
|
8
10
|
export { DBManager } from "./services/utils/db-manager.js";
|
|
9
11
|
export { LogProvider } from "./services/utils/log.js";
|
|
10
12
|
export { Miqro, ServerRequestHandler } from "./services/app.js";
|
|
11
|
-
export { initGlobals, assertGlobalTampered } from "./services/globals.js";
|
|
13
|
+
// export { initGlobals, assertGlobalTampered } from "./services/globals.js";
|
|
14
|
+
export { jsx2HTML } from "./common/jsx.js";
|
|
12
15
|
//exported for --inflate-sea
|
|
13
16
|
export { appendAPIModule } from "./inflate/utils/sea-utils.js";
|
|
14
17
|
export { createServerInterface } from "./services/utils/server-interface.js";
|
|
15
18
|
export { App, LoggerHandler, Router } from "@miqro/core";
|
|
16
19
|
export { migration } from "@miqro/query";
|
|
20
|
+
export { middleware } from "./services/utils/middleware.js";
|
|
21
|
+
export { jwt } from "./services/utils/jwt.js";
|
|
22
|
+
export const JSX = {
|
|
23
|
+
createElement: (...args) => {
|
|
24
|
+
const ret = realCreateElement(...args);
|
|
25
|
+
ret.toString = () => jsx2HTML(ret);
|
|
26
|
+
return ret;
|
|
27
|
+
},
|
|
28
|
+
Fragment,
|
|
29
|
+
enableDebugLog
|
|
30
|
+
};
|
|
31
|
+
export * as jsx from "@miqro/jsx";
|
package/build/esm/src/main.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Miqro } from "./services/app.js";
|
|
|
9
9
|
import { TEST_SOCKET } from "./common/paths.js";
|
|
10
10
|
import { Logger } from "@miqro/core";
|
|
11
11
|
async function main(args) {
|
|
12
|
-
if (args.
|
|
12
|
+
if (args.install || args.installTSConfig || args.installMiqroJSON) {
|
|
13
13
|
await installTypings(args, new Logger(""));
|
|
14
14
|
process.exit(EXIT_CODES.NORMAL_EXIT);
|
|
15
15
|
}
|
|
@@ -13,7 +13,6 @@ import { createEditorRouter } from "./editor.js";
|
|
|
13
13
|
import { EDITOR_CONFIG_KEY, HOT_RELOAD_PATH } from "../common/constants.js";
|
|
14
14
|
import { watchAndServer } from "../common/watch.js";
|
|
15
15
|
import { LocalCache } from "./utils/cache.js";
|
|
16
|
-
import { initGlobals } from "./globals.js";
|
|
17
16
|
import { LogProvider } from "./utils/log.js";
|
|
18
17
|
import { initAssets } from "../common/assets.js";
|
|
19
18
|
import { setupExitHandlers } from "../common/exit.js";
|
|
@@ -156,7 +155,7 @@ export class Miqro {
|
|
|
156
155
|
if (this.inflated !== null) {
|
|
157
156
|
throw new Error("already inflated! call deflate()");
|
|
158
157
|
}
|
|
159
|
-
initGlobals();
|
|
158
|
+
// initGlobals();
|
|
160
159
|
// block others from inflating while inflateApp is running
|
|
161
160
|
this.inflated = undefined;
|
|
162
161
|
this.inflated = {
|
|
@@ -204,7 +203,7 @@ export class Miqro {
|
|
|
204
203
|
// init assets only once for all ApplicationServer's
|
|
205
204
|
if (Miqro.initAssetsPromise === null) {
|
|
206
205
|
// init globals only once for all inflations
|
|
207
|
-
initGlobals();
|
|
206
|
+
// initGlobals();
|
|
208
207
|
Miqro.initAssetsPromise = initAssets(this.logger);
|
|
209
208
|
}
|
|
210
209
|
await Miqro.initAssetsPromise;
|
|
@@ -253,7 +252,7 @@ export class Miqro {
|
|
|
253
252
|
// init assets only once for all ApplicationServer's
|
|
254
253
|
if (Miqro.initAssetsPromise === null) {
|
|
255
254
|
// init globals only once for all inflations
|
|
256
|
-
initGlobals();
|
|
255
|
+
// initGlobals();
|
|
257
256
|
Miqro.initAssetsPromise = initAssets(this.logger);
|
|
258
257
|
}
|
|
259
258
|
await Miqro.initAssetsPromise;
|
|
@@ -21,7 +21,7 @@ export async function runMigrations(logger, db, servicePath, service, inflateDir
|
|
|
21
21
|
});
|
|
22
22
|
logger?.log("writing [%s]", relative(cwd(), inflatePath));
|
|
23
23
|
writeFileSync(inflatePath, await inflateJSX(resolve(migrationsFolderPath, migration), {
|
|
24
|
-
embemedJSX: false,
|
|
24
|
+
// embemedJSX: false,
|
|
25
25
|
minify: false,
|
|
26
26
|
useExport: true,
|
|
27
27
|
platform: "node",
|
|
@@ -49,7 +49,7 @@ export async function runMigrationsDown(logger, db, servicePath, service, inflat
|
|
|
49
49
|
});
|
|
50
50
|
logger?.log("writing [%s]", relative(cwd(), inflatePath));
|
|
51
51
|
writeFileSync(inflatePath, await inflateJSX(resolve(migrationsFolderPath, migration), {
|
|
52
|
-
embemedJSX: false,
|
|
52
|
+
// embemedJSX: false,
|
|
53
53
|
platform: "node",
|
|
54
54
|
minify: false,
|
|
55
55
|
useExport: true,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { decodeJWT, decodeProtectedHeaderJWT, decryptJWT, encryptJWT, signJWT, verifyJWT } from "../../common/jwt.js";
|
|
2
|
+
import { createSecretKey } from "node:crypto";
|
|
3
|
+
export const jwt = {
|
|
4
|
+
createSecretKey,
|
|
5
|
+
decode(jwt) {
|
|
6
|
+
return decodeJWT(jwt);
|
|
7
|
+
},
|
|
8
|
+
decodeProtectedHeader(token) {
|
|
9
|
+
return decodeProtectedHeaderJWT(token);
|
|
10
|
+
},
|
|
11
|
+
decrypt(jwt, secret, options) {
|
|
12
|
+
return decryptJWT(jwt, secret, options);
|
|
13
|
+
},
|
|
14
|
+
encrypt(payload, secret, options) {
|
|
15
|
+
return encryptJWT(payload, secret, options);
|
|
16
|
+
},
|
|
17
|
+
sign(payload, secret, options) {
|
|
18
|
+
return signJWT(payload, secret, options);
|
|
19
|
+
},
|
|
20
|
+
verify(jwt, secret, options) {
|
|
21
|
+
return verifyJWT(jwt, secret, options);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { JSONParser, ReadBuffer, SessionHandler, TextParser, URLEncodedParser } from "@miqro/core";
|
|
2
|
+
export declare const middleware: Readonly<{
|
|
3
|
+
buffer: typeof ReadBuffer;
|
|
4
|
+
url: typeof URLEncodedParser;
|
|
5
|
+
json: typeof JSONParser;
|
|
6
|
+
text: typeof TextParser;
|
|
7
|
+
cors: (options?: import("@miqro/core").CORSOptions) => import("@miqro/core").Handler<void>;
|
|
8
|
+
session: typeof SessionHandler;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CORS, JSONParser, ReadBuffer, SessionHandler, TextParser, URLEncodedParser } from "@miqro/core";
|
|
2
|
+
export const middleware = Object.freeze({
|
|
3
|
+
buffer: ReadBuffer,
|
|
4
|
+
url: URLEncodedParser,
|
|
5
|
+
json: JSONParser,
|
|
6
|
+
text: TextParser,
|
|
7
|
+
cors: CORS,
|
|
8
|
+
session: SessionHandler
|
|
9
|
+
});
|
|
@@ -1,8 +1,37 @@
|
|
|
1
|
+
import cluster from "node:cluster";
|
|
1
2
|
import { execSync } from "node:child_process";
|
|
2
|
-
import {
|
|
3
|
+
import { HTMLEncode } from "../../../editor/common/html-encode.js";
|
|
4
|
+
import { inflateMD2HTML } from "../../inflate/md.js";
|
|
5
|
+
import { Parser } from "@miqro/parser";
|
|
6
|
+
import { ClusterCache } from "./cluster-cache.js";
|
|
7
|
+
import { LocalCache } from "./cache.js";
|
|
8
|
+
import { middleware } from "./middleware.js";
|
|
9
|
+
import { jwt } from "./jwt.js";
|
|
3
10
|
export function createServerInterface(options) {
|
|
4
|
-
initGlobals();
|
|
11
|
+
// initGlobals();
|
|
5
12
|
return Object.freeze({
|
|
13
|
+
middleware,
|
|
14
|
+
encodeHTML: HTMLEncode,
|
|
15
|
+
inflateMDtoHTML: inflateMD2HTML,
|
|
16
|
+
newParser() {
|
|
17
|
+
return new Parser();
|
|
18
|
+
},
|
|
19
|
+
newClusterCache(name, logger) {
|
|
20
|
+
return new ClusterCache(name, logger);
|
|
21
|
+
},
|
|
22
|
+
newLocalCache(name, logger) {
|
|
23
|
+
return new LocalCache(name, logger);
|
|
24
|
+
},
|
|
25
|
+
getWorkerNumber() {
|
|
26
|
+
return cluster.isPrimary || process.env["CLUSTER_NODE_NUMBER"] === undefined ? 0 : parseInt(process.env["CLUSTER_NODE_NUMBER"], 10);
|
|
27
|
+
},
|
|
28
|
+
getWorkerCount() {
|
|
29
|
+
return cluster.isPrimary || process.env["CLUSTER_NODE_NUMBER"] === undefined || process.env["CLUSTER_COUNT"] === undefined ? 1 : parseInt(process.env["CLUSTER_COUNT"], 10);
|
|
30
|
+
},
|
|
31
|
+
isPrimaryWorker() {
|
|
32
|
+
return cluster.isPrimary || process.env["CLUSTER_NODE_NUMBER"] === "0";
|
|
33
|
+
},
|
|
34
|
+
jwt,
|
|
6
35
|
cache: options.cache,
|
|
7
36
|
localCache: options.localCache,
|
|
8
37
|
logger: options.logger,
|
|
@@ -67,7 +96,7 @@ export function createServerInterface(options) {
|
|
|
67
96
|
},
|
|
68
97
|
getLogger(identifier, loggerOptions) {
|
|
69
98
|
return options?.loggerProvider?.getLogger(identifier, loggerOptions);
|
|
70
|
-
}
|
|
71
|
-
...server
|
|
99
|
+
}
|
|
100
|
+
// ...server
|
|
72
101
|
});
|
|
73
102
|
}
|