imean-service-engine 1.7.1 → 1.7.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/dist/mod.cjs +24 -6
- package/dist/mod.d.cts +2 -1
- package/dist/mod.d.ts +2 -1
- package/dist/mod.js +24 -6
- package/package.json +87 -86
package/dist/mod.cjs
CHANGED
@@ -611,12 +611,21 @@ function Page(options) {
|
|
611
611
|
name: methodName,
|
612
612
|
description: options.description || "",
|
613
613
|
method: options.method,
|
614
|
-
path: options.path
|
614
|
+
path: normalizePath(options.path),
|
615
|
+
absolutePath: options.absolutePath ?? false
|
615
616
|
};
|
616
617
|
prototype[PAGE_METADATA] = existingMetadata;
|
617
618
|
});
|
618
619
|
};
|
619
620
|
}
|
621
|
+
function normalizePath(path) {
|
622
|
+
if (Array.isArray(path)) {
|
623
|
+
return path.map((p) => normalizePath(p));
|
624
|
+
}
|
625
|
+
if (!path.startsWith("/")) path = "/" + path;
|
626
|
+
if (path === "/") return "";
|
627
|
+
return path;
|
628
|
+
}
|
620
629
|
function getPageMetadata(target) {
|
621
630
|
return target.constructor.prototype[PAGE_METADATA] ?? {};
|
622
631
|
}
|
@@ -639,6 +648,9 @@ var PageHandler = class {
|
|
639
648
|
this.moduleInstance,
|
640
649
|
[ctx]
|
641
650
|
);
|
651
|
+
if (result instanceof Response) {
|
652
|
+
return result;
|
653
|
+
}
|
642
654
|
return ctx.html(result);
|
643
655
|
} catch (error) {
|
644
656
|
span.recordException(error);
|
@@ -930,10 +942,14 @@ var Microservice = class {
|
|
930
942
|
moduleName
|
931
943
|
);
|
932
944
|
this.pageHandlers.set(`${moduleName}.${page.name}`, handler);
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
945
|
+
const paths = Array.isArray(page.path) ? page.path : [page.path];
|
946
|
+
for (let path of paths) {
|
947
|
+
path = page.absolutePath ? path : `${this.options.prefix}${path}`;
|
948
|
+
this.app[page.method](path, (ctx) => handler.handle(ctx));
|
949
|
+
logger_default.info(
|
950
|
+
`[ \u6CE8\u518C\u9875\u9762 ] ${moduleName}.${page.name} ${page.method.toUpperCase()} ${page.path} ${page.description}`
|
951
|
+
);
|
952
|
+
}
|
937
953
|
}
|
938
954
|
const schedules = getScheduleMetadata(ModuleClass.prototype);
|
939
955
|
if (schedules && Object.keys(schedules).length > 0) {
|
@@ -1672,7 +1688,9 @@ var ServiceStatusPage_default = ServiceStatusPage;
|
|
1672
1688
|
|
1673
1689
|
// core/plugins/page/mod.ts
|
1674
1690
|
var PageRenderPlugin = class extends Plugin {
|
1675
|
-
constructor(options = {
|
1691
|
+
constructor(options = {
|
1692
|
+
useDefaultStatusPage: true
|
1693
|
+
}) {
|
1676
1694
|
super();
|
1677
1695
|
this.options = options;
|
1678
1696
|
}
|
package/dist/mod.d.cts
CHANGED
@@ -43,7 +43,8 @@ interface ActionOptions {
|
|
43
43
|
}
|
44
44
|
interface PageOptions {
|
45
45
|
method: "get" | "post" | "put" | "delete" | "patch" | "options";
|
46
|
-
path: string;
|
46
|
+
path: string | string[];
|
47
|
+
absolutePath?: boolean;
|
47
48
|
description?: string;
|
48
49
|
}
|
49
50
|
interface PageMetadata extends PageOptions {
|
package/dist/mod.d.ts
CHANGED
@@ -43,7 +43,8 @@ interface ActionOptions {
|
|
43
43
|
}
|
44
44
|
interface PageOptions {
|
45
45
|
method: "get" | "post" | "put" | "delete" | "patch" | "options";
|
46
|
-
path: string;
|
46
|
+
path: string | string[];
|
47
|
+
absolutePath?: boolean;
|
47
48
|
description?: string;
|
48
49
|
}
|
49
50
|
interface PageMetadata extends PageOptions {
|
package/dist/mod.js
CHANGED
@@ -602,12 +602,21 @@ function Page(options) {
|
|
602
602
|
name: methodName,
|
603
603
|
description: options.description || "",
|
604
604
|
method: options.method,
|
605
|
-
path: options.path
|
605
|
+
path: normalizePath(options.path),
|
606
|
+
absolutePath: options.absolutePath ?? false
|
606
607
|
};
|
607
608
|
prototype[PAGE_METADATA] = existingMetadata;
|
608
609
|
});
|
609
610
|
};
|
610
611
|
}
|
612
|
+
function normalizePath(path) {
|
613
|
+
if (Array.isArray(path)) {
|
614
|
+
return path.map((p) => normalizePath(p));
|
615
|
+
}
|
616
|
+
if (!path.startsWith("/")) path = "/" + path;
|
617
|
+
if (path === "/") return "";
|
618
|
+
return path;
|
619
|
+
}
|
611
620
|
function getPageMetadata(target) {
|
612
621
|
return target.constructor.prototype[PAGE_METADATA] ?? {};
|
613
622
|
}
|
@@ -630,6 +639,9 @@ var PageHandler = class {
|
|
630
639
|
this.moduleInstance,
|
631
640
|
[ctx]
|
632
641
|
);
|
642
|
+
if (result instanceof Response) {
|
643
|
+
return result;
|
644
|
+
}
|
633
645
|
return ctx.html(result);
|
634
646
|
} catch (error) {
|
635
647
|
span.recordException(error);
|
@@ -921,10 +933,14 @@ var Microservice = class {
|
|
921
933
|
moduleName
|
922
934
|
);
|
923
935
|
this.pageHandlers.set(`${moduleName}.${page.name}`, handler);
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
936
|
+
const paths = Array.isArray(page.path) ? page.path : [page.path];
|
937
|
+
for (let path of paths) {
|
938
|
+
path = page.absolutePath ? path : `${this.options.prefix}${path}`;
|
939
|
+
this.app[page.method](path, (ctx) => handler.handle(ctx));
|
940
|
+
logger_default.info(
|
941
|
+
`[ \u6CE8\u518C\u9875\u9762 ] ${moduleName}.${page.name} ${page.method.toUpperCase()} ${page.path} ${page.description}`
|
942
|
+
);
|
943
|
+
}
|
928
944
|
}
|
929
945
|
const schedules = getScheduleMetadata(ModuleClass.prototype);
|
930
946
|
if (schedules && Object.keys(schedules).length > 0) {
|
@@ -1663,7 +1679,9 @@ var ServiceStatusPage_default = ServiceStatusPage;
|
|
1663
1679
|
|
1664
1680
|
// core/plugins/page/mod.ts
|
1665
1681
|
var PageRenderPlugin = class extends Plugin {
|
1666
|
-
constructor(options = {
|
1682
|
+
constructor(options = {
|
1683
|
+
useDefaultStatusPage: true
|
1684
|
+
}) {
|
1667
1685
|
super();
|
1668
1686
|
this.options = options;
|
1669
1687
|
}
|
package/package.json
CHANGED
@@ -1,86 +1,87 @@
|
|
1
|
-
{
|
2
|
-
"name": "imean-service-engine",
|
3
|
-
"version": "1.7.
|
4
|
-
"description": "microservice engine",
|
5
|
-
"keywords": [
|
6
|
-
"microservice",
|
7
|
-
"websocket",
|
8
|
-
"http",
|
9
|
-
"node"
|
10
|
-
],
|
11
|
-
"author": "imean",
|
12
|
-
"type": "module",
|
13
|
-
"license": "MIT",
|
14
|
-
"repository": {
|
15
|
-
"type": "git",
|
16
|
-
"url": "git+https://git.imean.tech/imean/imean-microservice-framework.git"
|
17
|
-
},
|
18
|
-
"main": "dist/mod.js",
|
19
|
-
"module": "dist/mod.js",
|
20
|
-
"types": "dist/mod.d.ts",
|
21
|
-
"exports": {
|
22
|
-
".": {
|
23
|
-
"types": "./dist/mod.d.ts",
|
24
|
-
"import": "./dist/mod.js",
|
25
|
-
"require": "./dist/mod.cjs"
|
26
|
-
}
|
27
|
-
},
|
28
|
-
"files": [
|
29
|
-
"dist",
|
30
|
-
"README.md",
|
31
|
-
"LICENSE"
|
32
|
-
],
|
33
|
-
"
|
34
|
-
"
|
35
|
-
"
|
36
|
-
"
|
37
|
-
"
|
38
|
-
|
39
|
-
|
40
|
-
"
|
41
|
-
"hono": "^
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"
|
47
|
-
|
48
|
-
|
49
|
-
"
|
50
|
-
"
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
"@opentelemetry/
|
56
|
-
"
|
57
|
-
|
58
|
-
|
59
|
-
"@opentelemetry/
|
60
|
-
"@opentelemetry/
|
61
|
-
"@opentelemetry/
|
62
|
-
"@opentelemetry/
|
63
|
-
"@
|
64
|
-
"@
|
65
|
-
"@
|
66
|
-
"@
|
67
|
-
"@
|
68
|
-
"
|
69
|
-
"
|
70
|
-
"
|
71
|
-
"
|
72
|
-
"
|
73
|
-
"
|
74
|
-
"
|
75
|
-
"
|
76
|
-
"
|
77
|
-
|
78
|
-
|
79
|
-
"
|
80
|
-
|
81
|
-
|
82
|
-
"
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
}
|
1
|
+
{
|
2
|
+
"name": "imean-service-engine",
|
3
|
+
"version": "1.7.3",
|
4
|
+
"description": "microservice engine",
|
5
|
+
"keywords": [
|
6
|
+
"microservice",
|
7
|
+
"websocket",
|
8
|
+
"http",
|
9
|
+
"node"
|
10
|
+
],
|
11
|
+
"author": "imean",
|
12
|
+
"type": "module",
|
13
|
+
"license": "MIT",
|
14
|
+
"repository": {
|
15
|
+
"type": "git",
|
16
|
+
"url": "git+https://git.imean.tech/imean/imean-microservice-framework.git"
|
17
|
+
},
|
18
|
+
"main": "dist/mod.js",
|
19
|
+
"module": "dist/mod.js",
|
20
|
+
"types": "dist/mod.d.ts",
|
21
|
+
"exports": {
|
22
|
+
".": {
|
23
|
+
"types": "./dist/mod.d.ts",
|
24
|
+
"import": "./dist/mod.js",
|
25
|
+
"require": "./dist/mod.cjs"
|
26
|
+
}
|
27
|
+
},
|
28
|
+
"files": [
|
29
|
+
"dist",
|
30
|
+
"README.md",
|
31
|
+
"LICENSE"
|
32
|
+
],
|
33
|
+
"scripts": {
|
34
|
+
"dev": "tsx watch dev/index.ts",
|
35
|
+
"build": "tsup",
|
36
|
+
"test": "vitest run",
|
37
|
+
"prepublishOnly": "npm run build && npm run test"
|
38
|
+
},
|
39
|
+
"dependencies": {
|
40
|
+
"@hono/node-server": "^1.13.7",
|
41
|
+
"@hono/node-ws": "^1.0.6",
|
42
|
+
"@modelcontextprotocol/sdk": "^1.8.0",
|
43
|
+
"dayjs": "^1.11.13",
|
44
|
+
"ejson": "^2.2.3",
|
45
|
+
"etcd3": "^1.1.2",
|
46
|
+
"fs-extra": "^11.3.0",
|
47
|
+
"hono": "^4.6.17",
|
48
|
+
"lru-cache": "^11.0.2",
|
49
|
+
"prettier": "^3.4.2",
|
50
|
+
"ulid": "^3.0.0",
|
51
|
+
"winston": "^3.17.0",
|
52
|
+
"zod": "^3.24.1"
|
53
|
+
},
|
54
|
+
"peerDependencies": {
|
55
|
+
"@opentelemetry/api": "^1.x",
|
56
|
+
"ioredis": "^5.6.0"
|
57
|
+
},
|
58
|
+
"devDependencies": {
|
59
|
+
"@opentelemetry/auto-instrumentations-node": "^0.55.3",
|
60
|
+
"@opentelemetry/exporter-logs-otlp-proto": "^0.57.1",
|
61
|
+
"@opentelemetry/exporter-metrics-otlp-proto": "^0.57.1",
|
62
|
+
"@opentelemetry/exporter-trace-otlp-proto": "^0.57.1",
|
63
|
+
"@opentelemetry/instrumentation-winston": "^0.44.0",
|
64
|
+
"@opentelemetry/sdk-logs": "^0.57.1",
|
65
|
+
"@opentelemetry/sdk-metrics": "^1.30.1",
|
66
|
+
"@opentelemetry/sdk-node": "^0.57.1",
|
67
|
+
"@opentelemetry/sdk-trace-node": "^1.30.1",
|
68
|
+
"@opentelemetry/winston-transport": "^0.10.0",
|
69
|
+
"@types/ejson": "^2.2.2",
|
70
|
+
"@types/fs-extra": "^11.0.4",
|
71
|
+
"@types/ioredis-mock": "^8.2.5",
|
72
|
+
"@types/node": "^20.0.0",
|
73
|
+
"@vitest/coverage-v8": "^3.0.4",
|
74
|
+
"imean-service-client": "^1.5.0",
|
75
|
+
"ioredis-mock": "^8.9.0",
|
76
|
+
"opentelemetry-instrumentation-fetch-node": "^1.2.3",
|
77
|
+
"tslib": "^2.8.1",
|
78
|
+
"tsup": "^8.0.1",
|
79
|
+
"tsx": "^4.19.2",
|
80
|
+
"typescript": "^5.3.3",
|
81
|
+
"vite-tsconfig-paths": "^5.1.4",
|
82
|
+
"vitest": "^3.0.3"
|
83
|
+
},
|
84
|
+
"engines": {
|
85
|
+
"node": ">=20"
|
86
|
+
}
|
87
|
+
}
|