miqro 7.2.2 → 7.2.3
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 +871 -492
- package/build/editor.bundle.js +44 -12
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +3 -2
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +3 -3
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js.map +1 -1
- package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +3 -1
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +3 -3
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js.map +1 -1
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +4 -1
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +3 -3
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js.map +1 -1
- package/build/esm/src/cluster.js +0 -0
- package/build/esm/src/common/jsx.d.ts +3 -3
- package/build/esm/src/common/jsx.js.map +1 -1
- package/build/esm/src/inflate/setup-http.js.map +1 -1
- package/build/esm/src/main.js +0 -0
- package/build/esm/src/services/editor.js.map +1 -1
- package/build/esm/src/types.d.ts +5 -4
- package/build/esm/src/types.js +4 -1
- package/build/esm/src/types.js.map +1 -1
- package/build/lib.cjs +45 -23
- package/editor/http/admin/editor/api/fs/delete.api.tsx +3 -3
- package/editor/http/admin/editor/api/fs/read.api.tsx +3 -3
- package/editor/http/admin/editor/api/fs/rename.api.tsx +3 -3
- package/package.json +11 -11
- package/src/common/jsx.ts +3 -3
- package/src/inflate/setup-http.ts +4 -4
- package/src/services/editor.tsx +1 -1
- package/src/types.ts +21 -41
package/build/lib.cjs
CHANGED
|
@@ -640,12 +640,6 @@ var init_lib = __esm({
|
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
642
|
parse(arg, options, name = "") {
|
|
643
|
-
if (typeof options === "string") {
|
|
644
|
-
options = {
|
|
645
|
-
type: options,
|
|
646
|
-
required: true
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
643
|
const baseOption = typeof options === "string" ? {
|
|
650
644
|
type: options,
|
|
651
645
|
required: true
|
|
@@ -706,7 +700,7 @@ function ReadBuffer(options) {
|
|
|
706
700
|
limit = parseInt(limitS, 10);
|
|
707
701
|
timeout = parseInt(timeoutS, 10);
|
|
708
702
|
}
|
|
709
|
-
return async function
|
|
703
|
+
return async function ReadBuffer3(req, res) {
|
|
710
704
|
return new Promise((resolve24, reject) => {
|
|
711
705
|
try {
|
|
712
706
|
const readTimeout = setTimeout(() => {
|
|
@@ -780,7 +774,7 @@ function URLEncodedParser(options) {
|
|
|
780
774
|
const readBuffer = ReadBuffer({
|
|
781
775
|
limit
|
|
782
776
|
});
|
|
783
|
-
return async function
|
|
777
|
+
return async function URLEncodedParser3(req, res) {
|
|
784
778
|
try {
|
|
785
779
|
const isType = req.body === void 0 && req.headers["content-type"] ? req.headers["content-type"].toLocaleLowerCase().indexOf(type.toLocaleLowerCase()) !== -1 : false;
|
|
786
780
|
if (isType && !req.buffer) {
|
|
@@ -828,7 +822,7 @@ function JSONParser(options) {
|
|
|
828
822
|
const readBuffer = ReadBuffer({
|
|
829
823
|
limit
|
|
830
824
|
});
|
|
831
|
-
return async function
|
|
825
|
+
return async function JSONParser3(req, res) {
|
|
832
826
|
try {
|
|
833
827
|
const isType = req.body === void 0 && req.headers["content-type"] ? req.headers["content-type"].toLocaleLowerCase().indexOf(type.toLocaleLowerCase()) !== -1 : false;
|
|
834
828
|
if (isType && !req.buffer) {
|
|
@@ -872,7 +866,7 @@ function TextParser(options) {
|
|
|
872
866
|
const readBuffer = ReadBuffer({
|
|
873
867
|
limit
|
|
874
868
|
});
|
|
875
|
-
return async function
|
|
869
|
+
return async function TextParser3(req, res) {
|
|
876
870
|
try {
|
|
877
871
|
const isType = req.body === void 0 && req.headers["content-type"] ? req.headers["content-type"].toLocaleLowerCase().indexOf(type.toLocaleLowerCase()) !== -1 : false;
|
|
878
872
|
if (isType && !req.buffer) {
|
|
@@ -1103,7 +1097,7 @@ var init_body_parser = __esm({
|
|
|
1103
1097
|
origins = origins[0];
|
|
1104
1098
|
}
|
|
1105
1099
|
const validate = options && options.validate ? options && options.validate : isOriginAllowed;
|
|
1106
|
-
return async function
|
|
1100
|
+
return async function CORS3(req, res) {
|
|
1107
1101
|
if (!origins || origins === "*") {
|
|
1108
1102
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
1109
1103
|
res.addVaryHeader("Origin");
|
|
@@ -1206,7 +1200,7 @@ function SessionHandler(config) {
|
|
|
1206
1200
|
const tokenLocation = config.options.tokenLocation;
|
|
1207
1201
|
const tokenLocationName = config.options.tokenLocationName;
|
|
1208
1202
|
const setCookieOptions = config.options.setCookieOptions;
|
|
1209
|
-
return async function
|
|
1203
|
+
return async function SessionHandler3(req, res) {
|
|
1210
1204
|
try {
|
|
1211
1205
|
const tlN = typeof tokenLocationName === "string" ? tokenLocationName : tokenLocationName ? await tokenLocationName(req) : "";
|
|
1212
1206
|
let token = null;
|
|
@@ -1352,6 +1346,9 @@ var init_session = __esm({
|
|
|
1352
1346
|
function isMinimalRouter(obj) {
|
|
1353
1347
|
return typeof obj === "object" && typeof obj.run === "function" && typeof obj.getJSONDoc === "function";
|
|
1354
1348
|
}
|
|
1349
|
+
function defineRoute(route) {
|
|
1350
|
+
return route;
|
|
1351
|
+
}
|
|
1355
1352
|
function pathPartTokenize(token) {
|
|
1356
1353
|
const isWild = token.value[0] === ":";
|
|
1357
1354
|
const optional = token.value[token.value.length - 1] === "?";
|
|
@@ -6797,7 +6794,7 @@ var init_read_api = __esm({
|
|
|
6797
6794
|
import_node_path21 = require("node:path");
|
|
6798
6795
|
init_scan_api();
|
|
6799
6796
|
init_constants_server();
|
|
6800
|
-
read_api_default = {
|
|
6797
|
+
read_api_default = defineRoute({
|
|
6801
6798
|
method: "POST",
|
|
6802
6799
|
path: "/read",
|
|
6803
6800
|
description: "admin editor file read endpoint",
|
|
@@ -6822,7 +6819,7 @@ var init_read_api = __esm({
|
|
|
6822
6819
|
path
|
|
6823
6820
|
});
|
|
6824
6821
|
}
|
|
6825
|
-
};
|
|
6822
|
+
});
|
|
6826
6823
|
}
|
|
6827
6824
|
});
|
|
6828
6825
|
|
|
@@ -6899,7 +6896,7 @@ var init_rename_api = __esm({
|
|
|
6899
6896
|
import_node_fs21 = require("node:fs");
|
|
6900
6897
|
init_read_api();
|
|
6901
6898
|
import_node_path23 = require("node:path");
|
|
6902
|
-
rename_api_default = {
|
|
6899
|
+
rename_api_default = defineRoute({
|
|
6903
6900
|
middleware: [JSONParser()],
|
|
6904
6901
|
method: "POST",
|
|
6905
6902
|
description: "admin editor file rename endpoint",
|
|
@@ -6923,7 +6920,7 @@ var init_rename_api = __esm({
|
|
|
6923
6920
|
message: "OK"
|
|
6924
6921
|
});
|
|
6925
6922
|
}
|
|
6926
|
-
};
|
|
6923
|
+
});
|
|
6927
6924
|
}
|
|
6928
6925
|
});
|
|
6929
6926
|
|
|
@@ -6941,7 +6938,7 @@ var init_delete_api = __esm({
|
|
|
6941
6938
|
init_lib3();
|
|
6942
6939
|
import_node_fs22 = require("node:fs");
|
|
6943
6940
|
init_read_api();
|
|
6944
|
-
delete_api_default = {
|
|
6941
|
+
delete_api_default = defineRoute({
|
|
6945
6942
|
description: "admin editor file deletion endpoint",
|
|
6946
6943
|
method: "POST",
|
|
6947
6944
|
path: "/delete",
|
|
@@ -6964,7 +6961,7 @@ var init_delete_api = __esm({
|
|
|
6964
6961
|
message: "OK"
|
|
6965
6962
|
});
|
|
6966
6963
|
}
|
|
6967
|
-
};
|
|
6964
|
+
});
|
|
6968
6965
|
}
|
|
6969
6966
|
});
|
|
6970
6967
|
|
|
@@ -7145,6 +7142,7 @@ __export(lib_exports3, {
|
|
|
7145
7142
|
appendAPIModule: () => appendAPIModule,
|
|
7146
7143
|
createLogProviderOptions: () => createLogProviderOptions,
|
|
7147
7144
|
createServerInterface: () => createServerInterface,
|
|
7145
|
+
defineRoute: () => defineRoute2,
|
|
7148
7146
|
jsx: () => lib_exports,
|
|
7149
7147
|
jsx2HTML: () => jsx2HTML,
|
|
7150
7148
|
jwt: () => jwt,
|
|
@@ -8881,22 +8879,25 @@ function HTMLEncode(str) {
|
|
|
8881
8879
|
function AttributeEncode(str) {
|
|
8882
8880
|
return str.replaceAll('"', """);
|
|
8883
8881
|
}
|
|
8882
|
+
var containerMap = /* @__PURE__ */ new WeakMap();
|
|
8883
|
+
var originalChildNodesMap = /* @__PURE__ */ new WeakMap();
|
|
8884
8884
|
function runtimeDefine(runtime, tagName, component, options) {
|
|
8885
|
-
let container = null;
|
|
8886
|
-
let originalChildNodes = [];
|
|
8887
8885
|
runtime.customElementMap[tagName] = class extends SSRHTMLElement {
|
|
8888
8886
|
constructor() {
|
|
8889
8887
|
super(tagName, runtime);
|
|
8890
|
-
container = runtime.createContainer(this, {
|
|
8888
|
+
const container = runtime.createContainer(this, {
|
|
8891
8889
|
shadowInit: options?.shadowInit,
|
|
8892
8890
|
runtimeOptions: options?.runtimeOptions
|
|
8893
8891
|
});
|
|
8892
|
+
containerMap.set(this, container);
|
|
8894
8893
|
}
|
|
8895
8894
|
connectedCallback() {
|
|
8895
|
+
const container = containerMap.get(this);
|
|
8896
8896
|
if (!container) {
|
|
8897
8897
|
throw new Error("cannot find container!");
|
|
8898
8898
|
}
|
|
8899
8899
|
this.reCalculateOriginalChildren();
|
|
8900
|
+
const originalChildNodes = originalChildNodesMap.get(this);
|
|
8900
8901
|
const props = {};
|
|
8901
8902
|
const self = this;
|
|
8902
8903
|
for (const name of self.getAttributeNames()) {
|
|
@@ -8906,12 +8907,18 @@ function runtimeDefine(runtime, tagName, component, options) {
|
|
|
8906
8907
|
container.render(createElement(component, props, originalChildNodes));
|
|
8907
8908
|
}
|
|
8908
8909
|
disconnectedCallback() {
|
|
8910
|
+
const container = containerMap.get(this);
|
|
8909
8911
|
if (!container) {
|
|
8910
8912
|
throw new Error("cannot find container!");
|
|
8911
8913
|
}
|
|
8912
8914
|
container.disconnect();
|
|
8913
8915
|
}
|
|
8914
8916
|
attributeChangedCallback() {
|
|
8917
|
+
const container = containerMap.get(this);
|
|
8918
|
+
const originalChildNodes = originalChildNodesMap.get(this);
|
|
8919
|
+
if (!container || !originalChildNodesMap.has(this)) {
|
|
8920
|
+
return;
|
|
8921
|
+
}
|
|
8915
8922
|
if (!container) {
|
|
8916
8923
|
throw new Error("cannot find container!");
|
|
8917
8924
|
}
|
|
@@ -8924,13 +8931,22 @@ function runtimeDefine(runtime, tagName, component, options) {
|
|
|
8924
8931
|
container.render(createElement(component, props, originalChildNodes));
|
|
8925
8932
|
}
|
|
8926
8933
|
reCalculateOriginalChildren() {
|
|
8927
|
-
|
|
8934
|
+
if (originalChildNodesMap.has(this)) {
|
|
8935
|
+
return;
|
|
8936
|
+
}
|
|
8937
|
+
const originalChildNodes = [];
|
|
8938
|
+
if (!originalChildNodes) {
|
|
8939
|
+
return;
|
|
8940
|
+
}
|
|
8928
8941
|
const self = this;
|
|
8929
8942
|
for (let i = 0; i < self.childNodes.length; i++) {
|
|
8930
8943
|
const node = self.childNodes[i];
|
|
8931
|
-
node.remove();
|
|
8932
8944
|
originalChildNodes.push(node);
|
|
8933
8945
|
}
|
|
8946
|
+
for (const o of originalChildNodes) {
|
|
8947
|
+
o.remove();
|
|
8948
|
+
}
|
|
8949
|
+
originalChildNodesMap.set(this, originalChildNodes);
|
|
8934
8950
|
}
|
|
8935
8951
|
getProps() {
|
|
8936
8952
|
const props = {};
|
|
@@ -11589,6 +11605,11 @@ var down = {
|
|
|
11589
11605
|
folder: downMigrationFolder
|
|
11590
11606
|
};
|
|
11591
11607
|
|
|
11608
|
+
// src/types.ts
|
|
11609
|
+
function defineRoute2(route) {
|
|
11610
|
+
return defineRoute(route);
|
|
11611
|
+
}
|
|
11612
|
+
|
|
11592
11613
|
// src/services/utils/cluster-ws.ts
|
|
11593
11614
|
init_lib3();
|
|
11594
11615
|
var ClusterWebSocketServer2MessageType = "$$$$ClusterWebSocketServer2Message$$$$$";
|
|
@@ -17852,6 +17873,7 @@ var JSX2 = {
|
|
|
17852
17873
|
appendAPIModule,
|
|
17853
17874
|
createLogProviderOptions,
|
|
17854
17875
|
createServerInterface,
|
|
17876
|
+
defineRoute,
|
|
17855
17877
|
jsx,
|
|
17856
17878
|
jsx2HTML,
|
|
17857
17879
|
jwt,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineRoute, JSONParser } from "@miqro/core";
|
|
2
2
|
import { unlinkSync } from "node:fs";
|
|
3
3
|
import { getPath } from "./read.api.js";
|
|
4
4
|
|
|
5
|
-
export default {
|
|
5
|
+
export default defineRoute({
|
|
6
6
|
description: "admin editor file deletion endpoint",
|
|
7
7
|
method: "POST",
|
|
8
8
|
path: "/delete",
|
|
@@ -25,7 +25,7 @@ export default {
|
|
|
25
25
|
message: "OK"
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
}
|
|
28
|
+
});
|
|
29
29
|
|
|
30
30
|
function deleteFile(path: string) {
|
|
31
31
|
unlinkSync(getPath(path));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { APIRoute, JSONParser } from "@miqro/core";
|
|
1
|
+
import { APIRoute, defineRoute, JSONParser } from "@miqro/core";
|
|
2
2
|
import { readFileSync, realpathSync } from "node:fs";
|
|
3
3
|
import { SUPPORTED_LANGUAGES } from "../../../../../common/constants.js";
|
|
4
4
|
import { relative, resolve } from "node:path";
|
|
5
5
|
import { getLanguage } from "./scan.api.js";
|
|
6
6
|
import { BASE_PATH } from "../../../../../common/constants.server.js";
|
|
7
7
|
|
|
8
|
-
export default {
|
|
8
|
+
export default defineRoute({
|
|
9
9
|
method: "POST",
|
|
10
10
|
path: "/read",
|
|
11
11
|
description: "admin editor file read endpoint",
|
|
@@ -30,7 +30,7 @@ export default {
|
|
|
30
30
|
path
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
});
|
|
34
34
|
|
|
35
35
|
export function readFile(path: string) {
|
|
36
36
|
const filePath = getPath(path);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { APIRoute, JSONParser } from "@miqro/core";
|
|
1
|
+
import { APIRoute, defineRoute, JSONParser } from "@miqro/core";
|
|
2
2
|
import { existsSync, mkdirSync, renameSync } from "node:fs";
|
|
3
3
|
import { getPath } from "./read.api.js";
|
|
4
4
|
import { dirname } from "node:path";
|
|
5
5
|
|
|
6
|
-
export default {
|
|
6
|
+
export default defineRoute({
|
|
7
7
|
middleware: [JSONParser()],
|
|
8
8
|
method: "POST",
|
|
9
9
|
description: "admin editor file rename endpoint",
|
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
message: "OK"
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
}
|
|
30
|
+
});
|
|
31
31
|
|
|
32
32
|
export async function rename(path: string, newName: string) {
|
|
33
33
|
if (existsSync(path) && !existsSync(newName)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "miqro",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/esm/src/lib.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"pretest": "npm run build",
|
|
12
12
|
"test": "BROWSER=none node --enable-source-maps --test test/cases/*.test.js",
|
|
13
13
|
"coverage": "BROWSER=none node --enable-source-maps --experimental-test-coverage --test test/cases/*.test.js",
|
|
14
|
-
"
|
|
14
|
+
"prepare": "npm run build",
|
|
15
15
|
"release:package": "sh sea/release-tar.sh",
|
|
16
16
|
"prerelease:package": "npm run compile",
|
|
17
17
|
"prebuild": "rm -Rf build/;",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"postject": "1.0.0-alpha.6",
|
|
44
|
-
"@miqro/core": "^5.0.
|
|
45
|
-
"@miqro/jsx": "^1.0.
|
|
46
|
-
"@miqro/jsx-dom": "^1.0.
|
|
47
|
-
"@miqro/jsx-node": "^1.0.
|
|
48
|
-
"@miqro/parser": "^2.0.
|
|
49
|
-
"@miqro/query": "^0.0.
|
|
50
|
-
"@miqro/runner": "^2.0.
|
|
51
|
-
"@miqro/test": "^0.2.
|
|
52
|
-
"@miqro/test-http": "^0.1.
|
|
44
|
+
"@miqro/core": "^5.0.18",
|
|
45
|
+
"@miqro/jsx": "^1.0.2",
|
|
46
|
+
"@miqro/jsx-dom": "^1.0.6",
|
|
47
|
+
"@miqro/jsx-node": "^1.0.7",
|
|
48
|
+
"@miqro/parser": "^2.0.6",
|
|
49
|
+
"@miqro/query": "^0.0.8",
|
|
50
|
+
"@miqro/runner": "^2.0.3",
|
|
51
|
+
"@miqro/test": "^0.2.10",
|
|
52
|
+
"@miqro/test-http": "^0.1.4",
|
|
53
53
|
"esbuild": "0.28.0",
|
|
54
54
|
"jose": "6.2.1",
|
|
55
55
|
"showdown": "2.1.0"
|
package/src/common/jsx.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { createNodeRuntime } from "@miqro/jsx-node";
|
|
|
3
3
|
import { basename, dirname, extname, relative, resolve } from "node:path";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { Request, Response, CORSOptions, Logger, APIRoute } from "@miqro/core";
|
|
6
|
-
import { Parser, Schema } from "@miqro/parser";
|
|
6
|
+
import { InferSchema, Parser, Schema } from "@miqro/parser";
|
|
7
7
|
import { APIRouteSchema, SessionHandlerOptionsSchema } from "@miqro/core";
|
|
8
8
|
import { cwd } from "node:process";
|
|
9
9
|
|
|
@@ -391,7 +391,7 @@ export async function importMiddlewareConfigModule(inFile: string, options: Impo
|
|
|
391
391
|
const isCJS = extname(inFile) === ".cjs";
|
|
392
392
|
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
393
393
|
|
|
394
|
-
const module = parser.parse(mod, MiddlewareConfigSchema, basename(inFile));
|
|
394
|
+
const module = parser.parse(mod, MiddlewareConfigSchema, basename(inFile)) as MiddlewareConfig;
|
|
395
395
|
if (module !== undefined) {
|
|
396
396
|
return module;
|
|
397
397
|
} else {
|
|
@@ -403,7 +403,7 @@ export async function importErrorConfigModule(inFile: string, options: ImportJSX
|
|
|
403
403
|
const isCJS = extname(inFile) === ".cjs";
|
|
404
404
|
const mod = isCJS ? (await importJSXFile(inFile, options, logger)).default.default : (await importJSXFile(inFile, options, logger)).default;
|
|
405
405
|
|
|
406
|
-
const module = parser.parse(mod, ErrorConfigSchema, basename(inFile));
|
|
406
|
+
const module = parser.parse(mod, ErrorConfigSchema, basename(inFile)) as ErrorConfig;
|
|
407
407
|
if (module !== undefined) {
|
|
408
408
|
return module;
|
|
409
409
|
} else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Router, newURL, Response, Request, RouterHandlerOptions, Logger, APIRoute, normalizePath
|
|
1
|
+
import { Router, newURL, Response, Request, RouterHandlerOptions, Logger, APIRoute, normalizePath } from "@miqro/core";
|
|
2
2
|
import { existsSync, mkdir, readFile, readFileSync, readdirSync, statSync } from "node:fs";
|
|
3
3
|
import { dirname, join, relative, resolve as pathResolve } from "node:path";
|
|
4
4
|
|
|
@@ -15,7 +15,7 @@ import { setupAUTH } from "./setup-auth.js";
|
|
|
15
15
|
import { getRoutes } from "../services/utils/get-route.js";
|
|
16
16
|
import { describeFilePath, mkdirASync, writeFileASync } from "../common/fs.js";
|
|
17
17
|
import { inflateMD2HTML } from "./md.js";
|
|
18
|
-
import { MiddlewareConfig, ServerInterface, ServerRequest } from "../types.js";
|
|
18
|
+
import { MiddlewareConfig, ServerInterface, ServerRequest, ServerResponse } from "../types.js";
|
|
19
19
|
import { setupMiddleware } from "./setup-middleware.js";
|
|
20
20
|
import { setupError } from "./setup-error.js";
|
|
21
21
|
|
|
@@ -319,7 +319,7 @@ async function createRouterFromDirectory(importOptions: ImportJSXFileOptions, in
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
// router.use(assertGlobalTampered);
|
|
322
|
-
router.use(async function (req:
|
|
322
|
+
router.use(async function (req: ServerRequest, res: ServerResponse) {
|
|
323
323
|
|
|
324
324
|
const JSON = await getJSON(req, res, newURL(req.path), module.apiOptions?.basePath, module.default);
|
|
325
325
|
|
|
@@ -393,7 +393,7 @@ async function createRouterFromDirectory(importOptions: ImportJSXFileOptions, in
|
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
// router.use(assertGlobalTampered);
|
|
396
|
-
router.use(async function (req:
|
|
396
|
+
router.use(async function (req: ServerRequest, res: ServerResponse) {
|
|
397
397
|
const toRender = typeof module.default === "function" ? module.default(req, res) : module.default;
|
|
398
398
|
const HTML = await getHTML(hotreload, req, res, newURL(req.path), module.apiOptions?.basePath, await toRender);
|
|
399
399
|
|
package/src/services/editor.tsx
CHANGED
|
@@ -89,7 +89,7 @@ function getHandlerOptions(router: APIRoute): RouterHandlerOptions {
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
function getHandler(/*auth: Handler, */router: APIRoute): HandlerWithOptions {
|
|
92
|
+
function getHandler(/*auth: Handler, */router: APIRoute<any, any, any>): HandlerWithOptions<any, any, any> {
|
|
93
93
|
/*const ret = new Router();
|
|
94
94
|
ret.use(auth);
|
|
95
95
|
ret.use(router.handler, undefined, undefined, getHandlerOptions(router));
|
package/src/types.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { Database } from "@miqro/query";
|
|
2
|
-
import { WebSocketServerOptions, SessionHandlerOptions, Logger, WebSocketServer, ReadBuffer, URLEncodedParser, JSONParser, TextParser, CORS, SessionHandler, RouteOptions, Handler, Request, Response, LogLevel, LoggerTransportWriteArgs, CORSOptions, HandlerWithOptions, ErrorHandler } from "@miqro/core";
|
|
2
|
+
import { WebSocketServerOptions, SessionHandlerOptions, Logger, WebSocketServer, ReadBuffer, URLEncodedParser, JSONParser, TextParser, CORS, SessionHandler, RouteOptions, Handler, Request, Response, LogLevel, LoggerTransportWriteArgs, CORSOptions, HandlerWithOptions, ErrorHandler, SchemaProperties, APIRoute as BaseAPIRoute, TypedRequest, defineRoute as baseDefineRoute } from "@miqro/core";
|
|
3
3
|
import { request } from "@miqro/request";
|
|
4
4
|
import { Parser, ParserInterface } from "@miqro/parser";
|
|
5
5
|
import { RuntimeHTMLElement, Runtime, RuntimeContainer, RuntimeURL, RuntimeOptions, RuntimeShadowRootInit } from "@miqro/jsx";
|
|
6
|
-
import {
|
|
7
|
-
RuntimeElementDefinitionOptions,
|
|
8
|
-
Component,
|
|
9
|
-
createElement,
|
|
10
|
-
Fragment,
|
|
11
|
-
enableDebugLog
|
|
12
|
-
} from "@miqro/jsx";
|
|
13
|
-
import * as jsxLib from "@miqro/jsx";
|
|
14
6
|
import { EncryptOptions, JWTDecryptOptions, JWTDecryptResult, JWTPayload, JWTVerifyOptions, JWTVerifyResult, ProtectedHeaderParameters, SignOptions } from "jose";
|
|
15
7
|
import { KeyObject } from "node:crypto";
|
|
16
8
|
|
|
@@ -33,36 +25,20 @@ export interface JWTSignOptions {
|
|
|
33
25
|
options?: SignOptions;
|
|
34
26
|
}
|
|
35
27
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
export type APIRoute<
|
|
29
|
+
TBody extends SchemaProperties | string | boolean | undefined = undefined,
|
|
30
|
+
TParams extends SchemaProperties | string | boolean | undefined = undefined,
|
|
31
|
+
TQuery extends SchemaProperties | string | boolean | undefined = undefined>
|
|
32
|
+
= BaseAPIRoute<ServerRequest, TBody, TParams, TQuery>;
|
|
33
|
+
|
|
34
|
+
export function defineRoute<
|
|
35
|
+
const TBody extends SchemaProperties | string | boolean | undefined = undefined,
|
|
36
|
+
const TParams extends SchemaProperties | string | boolean | undefined = undefined,
|
|
37
|
+
const TQuery extends SchemaProperties | string | boolean | undefined = undefined
|
|
38
|
+
>(route: APIRoute<TBody, TParams, TQuery>) {
|
|
39
|
+
return baseDefineRoute<ServerRequest, TBody, TParams, TQuery>(route) as APIRoute;
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
declare global {
|
|
47
|
-
// only available browser side
|
|
48
|
-
var jsx: {
|
|
49
|
-
define: (tagName: string, component: Component, options?: RuntimeElementDefinitionOptions) => void;
|
|
50
|
-
useRuntime: typeof jsxLib.useRuntime;
|
|
51
|
-
usePathname: typeof jsxLib.usePathname;
|
|
52
|
-
Link: typeof jsxLib.Link;
|
|
53
|
-
Router: typeof jsxLib.Router;
|
|
54
|
-
createContext: typeof jsxLib.createContext;
|
|
55
|
-
useContext: typeof jsxLib.useContext;
|
|
56
|
-
useState: typeof jsxLib.useState;
|
|
57
|
-
useEffect: typeof jsxLib.useEffect;
|
|
58
|
-
useQuery: typeof jsxLib.useQuery;
|
|
59
|
-
useRef: typeof jsxLib.useRef;
|
|
60
|
-
useElement: typeof jsxLib.useElement;
|
|
61
|
-
useRefresh: typeof jsxLib.useRefresh;
|
|
62
|
-
}
|
|
63
|
-
}*/
|
|
64
|
-
|
|
65
|
-
export { APIRoute } from "@miqro/core";
|
|
66
42
|
export { Migration } from "@miqro/query";
|
|
67
43
|
|
|
68
44
|
export interface JWTInterface {
|
|
@@ -129,7 +105,7 @@ export interface ServerGlobal {
|
|
|
129
105
|
newParser(): Parser;
|
|
130
106
|
newClusterCache: (name: string, logger?: Logger) => CacheInterface;
|
|
131
107
|
newLocalCache: (name: string, logger?: Logger) => CacheInterface;
|
|
132
|
-
|
|
108
|
+
|
|
133
109
|
getWorkerCount: () => number;
|
|
134
110
|
getWorkerNumber: () => number;
|
|
135
111
|
isPrimaryWorker: () => boolean;
|
|
@@ -199,7 +175,7 @@ export interface ServerInterface extends ServerGlobal {
|
|
|
199
175
|
}
|
|
200
176
|
|
|
201
177
|
export interface ServerRequest extends Request {
|
|
202
|
-
server
|
|
178
|
+
server: ServerInterface;
|
|
203
179
|
}
|
|
204
180
|
|
|
205
181
|
export interface ServerResponse extends Response {
|
|
@@ -297,11 +273,15 @@ export interface DBConfig {
|
|
|
297
273
|
name: string;
|
|
298
274
|
}
|
|
299
275
|
|
|
300
|
-
export interface APIOptions
|
|
276
|
+
export interface APIOptions<
|
|
277
|
+
TBody extends SchemaProperties | string | boolean | undefined = SchemaProperties | string | boolean | undefined,
|
|
278
|
+
TParams extends SchemaProperties | string | boolean | undefined = SchemaProperties | string | boolean | undefined,
|
|
279
|
+
TQuery extends SchemaProperties | string | boolean | undefined = SchemaProperties | string | boolean | undefined
|
|
280
|
+
> extends Partial<RouteOptions<TBody, TParams, TQuery>> {
|
|
301
281
|
basePath?: string;
|
|
302
282
|
path?: string | string[];
|
|
303
283
|
method?: string | string[];
|
|
304
284
|
parser?: ParserInterface;
|
|
305
285
|
middleware?: Handler | Handler[];
|
|
306
286
|
session?: SessionHandlerOptions | Handler;
|
|
307
|
-
}
|
|
287
|
+
}
|