imean-service-engine 1.7.1 → 1.7.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/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
  }
@@ -930,10 +939,14 @@ var Microservice = class {
930
939
  moduleName
931
940
  );
932
941
  this.pageHandlers.set(`${moduleName}.${page.name}`, handler);
933
- this.app[page.method](`${this.options.prefix}${page.path}`, (ctx) => handler.handle(ctx));
934
- logger_default.info(
935
- `[ \u6CE8\u518C\u9875\u9762 ] ${moduleName}.${page.name} ${page.method.toUpperCase()} ${page.path} ${page.description}`
936
- );
942
+ const paths = Array.isArray(page.path) ? page.path : [page.path];
943
+ for (let path of paths) {
944
+ path = page.absolutePath ? path : `${this.options.prefix}${path}`;
945
+ this.app[page.method](path, (ctx) => handler.handle(ctx));
946
+ logger_default.info(
947
+ `[ \u6CE8\u518C\u9875\u9762 ] ${moduleName}.${page.name} ${page.method.toUpperCase()} ${page.path} ${page.description}`
948
+ );
949
+ }
937
950
  }
938
951
  const schedules = getScheduleMetadata(ModuleClass.prototype);
939
952
  if (schedules && Object.keys(schedules).length > 0) {
@@ -1672,7 +1685,9 @@ var ServiceStatusPage_default = ServiceStatusPage;
1672
1685
 
1673
1686
  // core/plugins/page/mod.ts
1674
1687
  var PageRenderPlugin = class extends Plugin {
1675
- constructor(options = {}) {
1688
+ constructor(options = {
1689
+ useDefaultStatusPage: true
1690
+ }) {
1676
1691
  super();
1677
1692
  this.options = options;
1678
1693
  }
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
  }
@@ -921,10 +930,14 @@ var Microservice = class {
921
930
  moduleName
922
931
  );
923
932
  this.pageHandlers.set(`${moduleName}.${page.name}`, handler);
924
- this.app[page.method](`${this.options.prefix}${page.path}`, (ctx) => handler.handle(ctx));
925
- logger_default.info(
926
- `[ \u6CE8\u518C\u9875\u9762 ] ${moduleName}.${page.name} ${page.method.toUpperCase()} ${page.path} ${page.description}`
927
- );
933
+ const paths = Array.isArray(page.path) ? page.path : [page.path];
934
+ for (let path of paths) {
935
+ path = page.absolutePath ? path : `${this.options.prefix}${path}`;
936
+ this.app[page.method](path, (ctx) => handler.handle(ctx));
937
+ logger_default.info(
938
+ `[ \u6CE8\u518C\u9875\u9762 ] ${moduleName}.${page.name} ${page.method.toUpperCase()} ${page.path} ${page.description}`
939
+ );
940
+ }
928
941
  }
929
942
  const schedules = getScheduleMetadata(ModuleClass.prototype);
930
943
  if (schedules && Object.keys(schedules).length > 0) {
@@ -1663,7 +1676,9 @@ var ServiceStatusPage_default = ServiceStatusPage;
1663
1676
 
1664
1677
  // core/plugins/page/mod.ts
1665
1678
  var PageRenderPlugin = class extends Plugin {
1666
- constructor(options = {}) {
1679
+ constructor(options = {
1680
+ useDefaultStatusPage: true
1681
+ }) {
1667
1682
  super();
1668
1683
  this.options = options;
1669
1684
  }
package/package.json CHANGED
@@ -1,86 +1,87 @@
1
- {
2
- "name": "imean-service-engine",
3
- "version": "1.7.1",
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
- "dependencies": {
34
- "@hono/node-server": "^1.13.7",
35
- "@hono/node-ws": "^1.0.6",
36
- "@modelcontextprotocol/sdk": "^1.8.0",
37
- "dayjs": "^1.11.13",
38
- "ejson": "^2.2.3",
39
- "etcd3": "^1.1.2",
40
- "fs-extra": "^11.3.0",
41
- "hono": "^4.6.17",
42
- "lru-cache": "^11.0.2",
43
- "prettier": "^3.4.2",
44
- "ulid": "^3.0.0",
45
- "winston": "^3.17.0",
46
- "zod": "^3.24.1"
47
- },
48
- "peerDependencies": {
49
- "@opentelemetry/api": "^1.x",
50
- "ioredis": "^5.6.0"
51
- },
52
- "devDependencies": {
53
- "@opentelemetry/auto-instrumentations-node": "^0.55.3",
54
- "@opentelemetry/exporter-logs-otlp-proto": "^0.57.1",
55
- "@opentelemetry/exporter-metrics-otlp-proto": "^0.57.1",
56
- "@opentelemetry/exporter-trace-otlp-proto": "^0.57.1",
57
- "@opentelemetry/instrumentation-winston": "^0.44.0",
58
- "@opentelemetry/sdk-logs": "^0.57.1",
59
- "@opentelemetry/sdk-metrics": "^1.30.1",
60
- "@opentelemetry/sdk-node": "^0.57.1",
61
- "@opentelemetry/sdk-trace-node": "^1.30.1",
62
- "@opentelemetry/winston-transport": "^0.10.0",
63
- "@types/ejson": "^2.2.2",
64
- "@types/fs-extra": "^11.0.4",
65
- "@types/ioredis-mock": "^8.2.5",
66
- "@types/node": "^20.0.0",
67
- "@vitest/coverage-v8": "^3.0.4",
68
- "imean-service-client": "^1.5.0",
69
- "ioredis-mock": "^8.9.0",
70
- "opentelemetry-instrumentation-fetch-node": "^1.2.3",
71
- "tslib": "^2.8.1",
72
- "tsup": "^8.0.1",
73
- "tsx": "^4.19.2",
74
- "typescript": "^5.3.3",
75
- "vite-tsconfig-paths": "^5.1.4",
76
- "vitest": "^3.0.3"
77
- },
78
- "engines": {
79
- "node": ">=20"
80
- },
81
- "scripts": {
82
- "dev": "tsx watch dev/index.ts",
83
- "build": "tsup",
84
- "test": "vitest run"
85
- }
86
- }
1
+ {
2
+ "name": "imean-service-engine",
3
+ "version": "1.7.2",
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
+ }