phecda-server 5.1.0 → 5.2.0

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.
Files changed (176) hide show
  1. package/README.md +10 -10
  2. package/assets/ps.json +25 -0
  3. package/{bin → assets}/schema.json +55 -55
  4. package/assets/tsconfig.json +21 -0
  5. package/bin/cli.mjs +150 -189
  6. package/dist/{chunk-6UQYEBAN.js → chunk-5BVUCNMA.js} +19 -20
  7. package/dist/{chunk-QG4X6H5Y.js → chunk-BSE2DSDK.js} +121 -124
  8. package/dist/{chunk-OTHER3YM.mjs → chunk-CKQW3FDK.mjs} +4 -5
  9. package/dist/{chunk-6W7CGOZC.mjs → chunk-JE6BBDXW.mjs} +64 -67
  10. package/dist/{chunk-5DOVDDO7.mjs → chunk-V3WIKOP3.mjs} +11 -6
  11. package/dist/{chunk-H4N6SHNG.mjs → chunk-VLV3AO3H.mjs} +0 -1
  12. package/dist/{chunk-GHOKWS5V.js → chunk-VMLHTEW3.js} +48 -43
  13. package/dist/{chunk-Z4YJHEXT.js → chunk-ZP7HNASU.js} +0 -1
  14. package/dist/core-7f6d2be6.d.ts +27 -0
  15. package/dist/{helper-fcbf6aa8.d.ts → helper-49c7213c.d.ts} +1 -1
  16. package/dist/{helper-867a598d.d.ts → helper-5d755442.d.ts} +1 -1
  17. package/dist/helper.d.ts +25 -0
  18. package/dist/helper.js +21 -0
  19. package/dist/helper.mjs +21 -0
  20. package/dist/index.d.ts +5 -25
  21. package/dist/index.js +39 -58
  22. package/dist/index.mjs +6 -25
  23. package/dist/rpc/bullmq/index.d.ts +3 -2
  24. package/dist/rpc/bullmq/index.js +12 -13
  25. package/dist/rpc/bullmq/index.mjs +2 -3
  26. package/dist/rpc/kafka/index.d.ts +3 -2
  27. package/dist/rpc/kafka/index.js +10 -11
  28. package/dist/rpc/kafka/index.mjs +2 -3
  29. package/dist/rpc/nats/index.d.ts +3 -2
  30. package/dist/rpc/nats/index.js +11 -12
  31. package/dist/rpc/nats/index.mjs +2 -3
  32. package/dist/rpc/rabbitmq/index.d.ts +3 -2
  33. package/dist/rpc/rabbitmq/index.js +13 -14
  34. package/dist/rpc/rabbitmq/index.mjs +2 -3
  35. package/dist/rpc/redis/index.d.ts +3 -2
  36. package/dist/rpc/redis/index.js +11 -12
  37. package/dist/rpc/redis/index.mjs +2 -3
  38. package/dist/server/elysia/index.d.ts +3 -2
  39. package/dist/server/elysia/index.js +20 -21
  40. package/dist/server/elysia/index.mjs +3 -4
  41. package/dist/server/express/index.d.ts +3 -2
  42. package/dist/server/express/index.js +18 -19
  43. package/dist/server/express/index.mjs +2 -3
  44. package/dist/server/fastify/index.d.ts +3 -2
  45. package/dist/server/fastify/index.js +19 -20
  46. package/dist/server/fastify/index.mjs +3 -4
  47. package/dist/server/h3/index.d.ts +3 -2
  48. package/dist/server/h3/index.js +16 -17
  49. package/dist/server/h3/index.mjs +2 -3
  50. package/dist/server/hono/index.d.ts +3 -2
  51. package/dist/server/hono/index.js +17 -18
  52. package/dist/server/hono/index.mjs +2 -3
  53. package/dist/server/hyper-express/index.d.ts +3 -2
  54. package/dist/server/hyper-express/index.js +17 -18
  55. package/dist/server/hyper-express/index.mjs +2 -3
  56. package/dist/server/koa/index.d.ts +3 -2
  57. package/dist/server/koa/index.js +18 -19
  58. package/dist/server/koa/index.mjs +2 -3
  59. package/dist/test.d.ts +2 -1
  60. package/dist/test.js +6 -7
  61. package/dist/test.mjs +2 -3
  62. package/dist/{core-fd134ffa.d.ts → types-81be0ba3.d.ts} +2 -24
  63. package/package.json +62 -54
  64. package/register/index.mjs +40 -40
  65. package/register/loader.mjs +367 -341
  66. package/register/utils.mjs +56 -81
  67. package/dist/chunk-423JPSEB.js +0 -253
  68. package/dist/chunk-423JPSEB.js.map +0 -1
  69. package/dist/chunk-4R55T3HG.js +0 -253
  70. package/dist/chunk-4R55T3HG.js.map +0 -1
  71. package/dist/chunk-4YVAW3L4.mjs +0 -76
  72. package/dist/chunk-4YVAW3L4.mjs.map +0 -1
  73. package/dist/chunk-5DOVDDO7.mjs.map +0 -1
  74. package/dist/chunk-5WQ2SMIK.js +0 -295
  75. package/dist/chunk-5WQ2SMIK.js.map +0 -1
  76. package/dist/chunk-6MQP6OHU.mjs +0 -295
  77. package/dist/chunk-6MQP6OHU.mjs.map +0 -1
  78. package/dist/chunk-6Q2PCC3A.mjs +0 -295
  79. package/dist/chunk-6Q2PCC3A.mjs.map +0 -1
  80. package/dist/chunk-6UQYEBAN.js.map +0 -1
  81. package/dist/chunk-6W7CGOZC.mjs.map +0 -1
  82. package/dist/chunk-7Y37NSBM.js +0 -88
  83. package/dist/chunk-7Y37NSBM.js.map +0 -1
  84. package/dist/chunk-BQBSVGMG.mjs +0 -253
  85. package/dist/chunk-BQBSVGMG.mjs.map +0 -1
  86. package/dist/chunk-BZP6GKM6.mjs +0 -565
  87. package/dist/chunk-BZP6GKM6.mjs.map +0 -1
  88. package/dist/chunk-C5JAHCS2.mjs +0 -88
  89. package/dist/chunk-C5JAHCS2.mjs.map +0 -1
  90. package/dist/chunk-DTBKDALR.mjs +0 -295
  91. package/dist/chunk-DTBKDALR.mjs.map +0 -1
  92. package/dist/chunk-GHOKWS5V.js.map +0 -1
  93. package/dist/chunk-H4N6SHNG.mjs.map +0 -1
  94. package/dist/chunk-ICYHM4UM.js +0 -565
  95. package/dist/chunk-ICYHM4UM.js.map +0 -1
  96. package/dist/chunk-LOLXPM4J.mjs +0 -529
  97. package/dist/chunk-LOLXPM4J.mjs.map +0 -1
  98. package/dist/chunk-MSS6A2TU.js +0 -585
  99. package/dist/chunk-MSS6A2TU.js.map +0 -1
  100. package/dist/chunk-NEM3FY7C.mjs +0 -537
  101. package/dist/chunk-NEM3FY7C.mjs.map +0 -1
  102. package/dist/chunk-OTHER3YM.mjs.map +0 -1
  103. package/dist/chunk-Q2FYFIEY.js +0 -295
  104. package/dist/chunk-Q2FYFIEY.js.map +0 -1
  105. package/dist/chunk-QG4X6H5Y.js.map +0 -1
  106. package/dist/chunk-QIEZ6YTG.mjs +0 -295
  107. package/dist/chunk-QIEZ6YTG.mjs.map +0 -1
  108. package/dist/chunk-QOAKHCM7.js +0 -295
  109. package/dist/chunk-QOAKHCM7.js.map +0 -1
  110. package/dist/chunk-QVUD6L5X.js +0 -565
  111. package/dist/chunk-QVUD6L5X.js.map +0 -1
  112. package/dist/chunk-RGLTGKAU.js +0 -537
  113. package/dist/chunk-RGLTGKAU.js.map +0 -1
  114. package/dist/chunk-SHRK3TVB.js +0 -295
  115. package/dist/chunk-SHRK3TVB.js.map +0 -1
  116. package/dist/chunk-TCH6S42Z.js +0 -529
  117. package/dist/chunk-TCH6S42Z.js.map +0 -1
  118. package/dist/chunk-UCGRFVHC.mjs +0 -253
  119. package/dist/chunk-UCGRFVHC.mjs.map +0 -1
  120. package/dist/chunk-VOISXWVF.mjs +0 -295
  121. package/dist/chunk-VOISXWVF.mjs.map +0 -1
  122. package/dist/chunk-W6BC5INO.mjs +0 -295
  123. package/dist/chunk-W6BC5INO.mjs.map +0 -1
  124. package/dist/chunk-X5WQRO4R.js +0 -295
  125. package/dist/chunk-X5WQRO4R.js.map +0 -1
  126. package/dist/chunk-XDMCVVD3.mjs +0 -585
  127. package/dist/chunk-XDMCVVD3.mjs.map +0 -1
  128. package/dist/chunk-XNTMYLK6.js +0 -76
  129. package/dist/chunk-XNTMYLK6.js.map +0 -1
  130. package/dist/chunk-Y6LI4FDO.js +0 -537
  131. package/dist/chunk-Y6LI4FDO.js.map +0 -1
  132. package/dist/chunk-YZ2AQ6IL.mjs +0 -537
  133. package/dist/chunk-YZ2AQ6IL.mjs.map +0 -1
  134. package/dist/chunk-Z4YJHEXT.js.map +0 -1
  135. package/dist/chunk-ZE336SKZ.js +0 -295
  136. package/dist/chunk-ZE336SKZ.js.map +0 -1
  137. package/dist/chunk-ZJD235TO.mjs +0 -565
  138. package/dist/chunk-ZJD235TO.mjs.map +0 -1
  139. package/dist/core-39f27fe8.d.ts +0 -131
  140. package/dist/core-930ea883.d.ts +0 -131
  141. package/dist/core-eb646fe5.d.ts +0 -139
  142. package/dist/helper-06d25b37.d.ts +0 -19
  143. package/dist/helper-48454c0b.d.ts +0 -20
  144. package/dist/helper-6133f78f.d.ts +0 -18
  145. package/dist/helper-73e8d2f0.d.ts +0 -18
  146. package/dist/helper-88b19c66.d.ts +0 -12
  147. package/dist/helper-9e206c66.d.ts +0 -12
  148. package/dist/helper-f29f082f.d.ts +0 -19
  149. package/dist/index.js.map +0 -1
  150. package/dist/index.mjs.map +0 -1
  151. package/dist/rpc/bullmq/index.js.map +0 -1
  152. package/dist/rpc/bullmq/index.mjs.map +0 -1
  153. package/dist/rpc/kafka/index.js.map +0 -1
  154. package/dist/rpc/kafka/index.mjs.map +0 -1
  155. package/dist/rpc/nats/index.js.map +0 -1
  156. package/dist/rpc/nats/index.mjs.map +0 -1
  157. package/dist/rpc/rabbitmq/index.js.map +0 -1
  158. package/dist/rpc/rabbitmq/index.mjs.map +0 -1
  159. package/dist/rpc/redis/index.js.map +0 -1
  160. package/dist/rpc/redis/index.mjs.map +0 -1
  161. package/dist/server/elysia/index.js.map +0 -1
  162. package/dist/server/elysia/index.mjs.map +0 -1
  163. package/dist/server/express/index.js.map +0 -1
  164. package/dist/server/express/index.mjs.map +0 -1
  165. package/dist/server/fastify/index.js.map +0 -1
  166. package/dist/server/fastify/index.mjs.map +0 -1
  167. package/dist/server/h3/index.js.map +0 -1
  168. package/dist/server/h3/index.mjs.map +0 -1
  169. package/dist/server/hono/index.js.map +0 -1
  170. package/dist/server/hono/index.mjs.map +0 -1
  171. package/dist/server/hyper-express/index.js.map +0 -1
  172. package/dist/server/hyper-express/index.mjs.map +0 -1
  173. package/dist/server/koa/index.js.map +0 -1
  174. package/dist/server/koa/index.mjs.map +0 -1
  175. package/dist/test.js.map +0 -1
  176. package/dist/test.mjs.map +0 -1
@@ -5,10 +5,10 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkQG4X6H5Yjs = require('../../chunk-QG4X6H5Y.js');
8
+ var _chunkBSE2DSDKjs = require('../../chunk-BSE2DSDK.js');
9
9
 
10
10
 
11
- var _chunkXNTMYLK6js = require('../../chunk-XNTMYLK6.js');
11
+ var _chunkZP7HNASUjs = require('../../chunk-ZP7HNASU.js');
12
12
 
13
13
  // src/server/koa/bind.ts
14
14
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
@@ -17,14 +17,14 @@ function bind(router, data, opts = {}) {
17
17
  const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
18
18
  const { moduleMap, meta } = data;
19
19
  const originStack = router.stack.slice(0, router.stack.length);
20
- const metaMap = _chunkQG4X6H5Yjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
20
+ const metaMap = _chunkBSE2DSDKjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
21
  const { controller, http, func, tag } = meta2.data;
22
22
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
23
23
  debug(`register method "${func}" in module "${tag}"`);
24
24
  return true;
25
25
  }
26
26
  });
27
- _chunkQG4X6H5Yjs.detectAopDep.call(void 0, meta, {
27
+ _chunkBSE2DSDKjs.detectAopDep.call(void 0, meta, {
28
28
  plugins: [
29
29
  ...globalPlugins,
30
30
  ...parallelPlugins
@@ -34,28 +34,28 @@ function bind(router, data, opts = {}) {
34
34
  });
35
35
  registerRoute();
36
36
  async function registerRoute() {
37
- _chunkQG4X6H5Yjs.Context.usePlugin(globalPlugins, "koa").forEach((p) => router.use(p));
37
+ _chunkBSE2DSDKjs.Context.usePlugin(globalPlugins, "koa").forEach((p) => router.use(p));
38
38
  if (parallelRoute) {
39
- router.post(parallelRoute, ..._chunkQG4X6H5Yjs.Context.usePlugin(parallelPlugins, "koa"), async (ctx, next) => {
39
+ router.post(parallelRoute, ..._chunkBSE2DSDKjs.Context.usePlugin(parallelPlugins, "koa"), async (ctx, next) => {
40
40
  const { body } = ctx.request;
41
41
  async function errorHandler(e) {
42
- const error = await _chunkQG4X6H5Yjs.Context.filterRecord.default(e);
42
+ const error = await _chunkBSE2DSDKjs.Context.filterRecord.default(e);
43
43
  ctx.status = error.status;
44
44
  ctx.body = error;
45
45
  }
46
- _chunkXNTMYLK6js.__name.call(void 0, errorHandler, "errorHandler");
46
+ _chunkZP7HNASUjs.__name.call(void 0, errorHandler, "errorHandler");
47
47
  if (!Array.isArray(body))
48
- return errorHandler(new (0, _chunkQG4X6H5Yjs.BadRequestException)("data format should be an array"));
48
+ return errorHandler(new (0, _chunkBSE2DSDKjs.BadRequestException)("data format should be an array"));
49
49
  try {
50
50
  return Promise.all(body.map((item, i) => {
51
51
  return new Promise(async (resolve) => {
52
52
  const { tag, func } = item;
53
53
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
54
54
  if (!metaMap.has(tag))
55
- return resolve(await _chunkQG4X6H5Yjs.Context.filterRecord.default(new (0, _chunkQG4X6H5Yjs.BadRequestException)(`module "${tag}" doesn't exist`)));
55
+ return resolve(await _chunkBSE2DSDKjs.Context.filterRecord.default(new (0, _chunkBSE2DSDKjs.BadRequestException)(`module "${tag}" doesn't exist`)));
56
56
  const meta2 = metaMap.get(tag)[func];
57
57
  if (!meta2)
58
- return resolve(await _chunkQG4X6H5Yjs.Context.filterRecord.default(new (0, _chunkQG4X6H5Yjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
58
+ return resolve(await _chunkBSE2DSDKjs.Context.filterRecord.default(new (0, _chunkBSE2DSDKjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
59
59
  const { data: { params } } = meta2;
60
60
  const contextData = {
61
61
  type: "koa",
@@ -66,11 +66,11 @@ function bind(router, data, opts = {}) {
66
66
  parallel: true,
67
67
  next,
68
68
  app: router,
69
- ..._chunkQG4X6H5Yjs.argToReq.call(void 0, params, item.args, ctx.headers),
69
+ ..._chunkBSE2DSDKjs.argToReq.call(void 0, params, item.args, ctx.headers),
70
70
  tag,
71
71
  func
72
72
  };
73
- const context = new (0, _chunkQG4X6H5Yjs.Context)(contextData);
73
+ const context = new (0, _chunkBSE2DSDKjs.Context)(contextData);
74
74
  context.run({
75
75
  globalGuards,
76
76
  globalInterceptors,
@@ -92,7 +92,7 @@ function bind(router, data, opts = {}) {
92
92
  const { data: { plugins, http } } = meta2;
93
93
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
94
94
  continue;
95
- router[http.type](http.prefix + http.route, ..._chunkQG4X6H5Yjs.Context.usePlugin(plugins, "koa"), async (ctx, next) => {
95
+ router[http.type](http.prefix + http.route, ..._chunkBSE2DSDKjs.Context.usePlugin(plugins, "koa"), async (ctx, next) => {
96
96
  debug(`invoke method "${func}" in module "${tag}"`);
97
97
  const contextData = {
98
98
  type: "koa",
@@ -108,7 +108,7 @@ function bind(router, data, opts = {}) {
108
108
  headers: ctx.headers,
109
109
  next
110
110
  };
111
- const context = new (0, _chunkQG4X6H5Yjs.Context)(contextData);
111
+ const context = new (0, _chunkBSE2DSDKjs.Context)(contextData);
112
112
  if (http.headers) {
113
113
  for (const name in http.headers)
114
114
  ctx.set(name, http.headers[name]);
@@ -132,14 +132,13 @@ function bind(router, data, opts = {}) {
132
132
  }
133
133
  }
134
134
  }
135
- _chunkXNTMYLK6js.__name.call(void 0, registerRoute, "registerRoute");
136
- _chunkQG4X6H5Yjs.HMR.call(void 0, async () => {
135
+ _chunkZP7HNASUjs.__name.call(void 0, registerRoute, "registerRoute");
136
+ _chunkBSE2DSDKjs.HMR.call(void 0, async () => {
137
137
  router.stack = originStack;
138
138
  registerRoute();
139
139
  });
140
140
  }
141
- _chunkXNTMYLK6js.__name.call(void 0, bind, "bind");
141
+ _chunkZP7HNASUjs.__name.call(void 0, bind, "bind");
142
142
 
143
143
 
144
144
  exports.bind = bind;
145
- //# sourceMappingURL=index.js.map
@@ -5,10 +5,10 @@ import {
5
5
  argToReq,
6
6
  createControllerMetaMap,
7
7
  detectAopDep
8
- } from "../../chunk-ZJD235TO.mjs";
8
+ } from "../../chunk-JE6BBDXW.mjs";
9
9
  import {
10
10
  __name
11
- } from "../../chunk-H4N6SHNG.mjs";
11
+ } from "../../chunk-VLV3AO3H.mjs";
12
12
 
13
13
  // src/server/koa/bind.ts
14
14
  import Debug from "debug";
@@ -142,4 +142,3 @@ __name(bind, "bind");
142
142
  export {
143
143
  bind
144
144
  };
145
- //# sourceMappingURL=index.mjs.map
package/dist/test.d.ts CHANGED
@@ -2,7 +2,8 @@ import * as supertest from 'supertest';
2
2
  import { Test } from 'supertest';
3
3
  import { Server } from 'node:http';
4
4
  import { Construct } from 'phecda-core';
5
- import { F as Factory, P as PickFunc } from './core-39f27fe8.js';
5
+ import { F as Factory } from './core-7f6d2be6.js';
6
+ import { P as PickFunc } from './types-81be0ba3.js';
6
7
 
7
8
  declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
8
9
  get<C extends T[number]>(Module: C): InstanceType<C>;
package/dist/test.js CHANGED
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk423JPSEBjs = require('./chunk-423JPSEB.js');
3
+ var _chunk5BVUCNMAjs = require('./chunk-5BVUCNMA.js');
4
4
 
5
5
 
6
- var _chunkXNTMYLK6js = require('./chunk-XNTMYLK6.js');
6
+ var _chunkZP7HNASUjs = require('./chunk-ZP7HNASU.js');
7
7
 
8
8
  // src/test.ts
9
9
  var _phecdacore = require('phecda-core');
10
10
  async function TestFactory(...Modules) {
11
- const { moduleMap, constructorMap } = await _chunk423JPSEBjs.Factory.call(void 0, Modules);
11
+ const { moduleMap, constructorMap } = await _chunk5BVUCNMAjs.Factory.call(void 0, Modules);
12
12
  return {
13
13
  get(Module) {
14
14
  const tag = _phecdacore.getTag.call(void 0, Module);
@@ -21,7 +21,7 @@ async function TestFactory(...Modules) {
21
21
  }
22
22
  };
23
23
  }
24
- _chunkXNTMYLK6js.__name.call(void 0, TestFactory, "TestFactory");
24
+ _chunkZP7HNASUjs.__name.call(void 0, TestFactory, "TestFactory");
25
25
  async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
26
26
  const { default: request, agent } = await Promise.resolve().then(() => require("supertest"));
27
27
  const Agent = agent(app);
@@ -67,13 +67,12 @@ async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
67
67
  }
68
68
  });
69
69
  }
70
- _chunkXNTMYLK6js.__name.call(void 0, module, "module");
70
+ _chunkZP7HNASUjs.__name.call(void 0, module, "module");
71
71
  Agent.module = module;
72
72
  return Agent;
73
73
  }
74
- _chunkXNTMYLK6js.__name.call(void 0, TestHttp, "TestHttp");
74
+ _chunkZP7HNASUjs.__name.call(void 0, TestHttp, "TestHttp");
75
75
 
76
76
 
77
77
 
78
78
  exports.TestFactory = TestFactory; exports.TestHttp = TestHttp;
79
- //# sourceMappingURL=test.js.map
package/dist/test.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Factory
3
- } from "./chunk-UCGRFVHC.mjs";
3
+ } from "./chunk-CKQW3FDK.mjs";
4
4
  import {
5
5
  __name
6
- } from "./chunk-H4N6SHNG.mjs";
6
+ } from "./chunk-VLV3AO3H.mjs";
7
7
 
8
8
  // src/test.ts
9
9
  import { getTag } from "phecda-core";
@@ -76,4 +76,3 @@ export {
76
76
  TestFactory,
77
77
  TestHttp
78
78
  };
79
- //# sourceMappingURL=test.mjs.map
@@ -19,7 +19,7 @@ interface ControllerMetaData extends ServiceMetaData {
19
19
  queue?: string;
20
20
  isEvent?: boolean;
21
21
  };
22
- ctx?: string;
22
+ ctxs?: string[];
23
23
  params: {
24
24
  type: string;
25
25
  index: number;
@@ -105,26 +105,4 @@ declare class CustomResponse<Value> {
105
105
  }
106
106
  type ExtractResponse<Class extends CustomResponse<any>> = Class extends CustomResponse<infer Value> ? Value : never;
107
107
 
108
- declare abstract class Generator {
109
- path: string;
110
- constructor(path: string);
111
- abstract name: string;
112
- abstract generateCode(meta: MetaData[]): string;
113
- output(meta: Meta[]): Promise<void>;
114
- }
115
-
116
- declare const emitter: Emitter;
117
- declare function Factory(models: (new (...args: any) => any)[], opts?: {
118
- parseModule?: (module: any) => any;
119
- parseMeta?: (meta: Meta) => Meta | null | undefined;
120
- generators?: Generator[];
121
- }): Promise<{
122
- moduleMap: Map<PropertyKey, any>;
123
- constructorMap: Map<any, any>;
124
- meta: Meta[];
125
- add: (Model: Construct) => Promise<void>;
126
- del: (tag: PropertyKey) => Promise<any>;
127
- destroy: () => Promise<void>;
128
- }>;
129
-
130
- export { BaseContext as B, ControllerMetaData as C, DefaultOptions as D, Emitter as E, Factory as F, Generator as G, IS_HMR as I, LOG_LEVEL as L, Meta as M, OmitFunction as O, PickFunc as P, ServiceMetaData as S, ToClientMap as T, UNMOUNT_SYMBOL as U, MetaData as a, BaseError as b, ToClientInstance as c, ToClientFn as d, BaseReturn as e, BaseRequestType as f, CustomResponse as g, ExtractResponse as h, emitter as i, ControllerMeta as j, ERROR_SYMBOL as k, IS_ONLY_GENERATE as l, IS_STRICT as m, PS_EXIT_CODE as n };
108
+ export { BaseContext as B, ControllerMetaData as C, DefaultOptions as D, Emitter as E, IS_HMR as I, LOG_LEVEL as L, MetaData as M, OmitFunction as O, PickFunc as P, ServiceMetaData as S, ToClientMap as T, UNMOUNT_SYMBOL as U, BaseError as a, ToClientInstance as b, ToClientFn as c, BaseReturn as d, BaseRequestType as e, CustomResponse as f, ExtractResponse as g, Meta as h, ControllerMeta as i, ERROR_SYMBOL as j, IS_ONLY_GENERATE as k, IS_STRICT as l, PS_EXIT_CODE as m };
package/package.json CHANGED
@@ -1,74 +1,84 @@
1
1
  {
2
2
  "name": "phecda-server",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "bin": {
9
- "phecda": "bin/cli.mjs"
10
- },
5
+ "author": "fgsreally",
6
+ "license": "MIT",
7
+ "repository": "https://github.com/fgsreally/phecda/tree/main/packages/server",
8
+ "keywords": [
9
+ "server",
10
+ "IOC",
11
+ "rpc",
12
+ "types-share"
13
+ ],
11
14
  "exports": {
12
15
  ".": {
13
- "import": "./dist/index.mjs",
14
16
  "require": "./dist/index.js",
17
+ "import": "./dist/index.mjs",
15
18
  "node": "./dist/index.js"
16
19
  },
20
+ "./helper": {
21
+ "require": "./dist/helper.js",
22
+ "import": "./dist/helper.mjs"
23
+ },
17
24
  "./test": {
18
- "import": "./dist/test.mjs",
19
- "require": "./dist/test.js"
25
+ "require": "./dist/test.js",
26
+ "import": "./dist/test.mjs"
20
27
  },
21
28
  "./h3": {
22
- "import": "./dist/server/h3/index.mjs",
23
- "require": "./dist/server/h3/index.js"
29
+ "require": "./dist/server/h3/index.js",
30
+ "import": "./dist/server/h3/index.mjs"
24
31
  },
25
32
  "./express": {
26
- "import": "./dist/server/express/index.mjs",
27
- "require": "./dist/server/express/index.js"
33
+ "require": "./dist/server/express/index.js",
34
+ "import": "./dist/server/express/index.mjs"
28
35
  },
29
36
  "./koa": {
30
- "import": "./dist/server/koa/index.mjs",
31
- "require": "./dist/server/koa/index.js"
37
+ "require": "./dist/server/koa/index.js",
38
+ "import": "./dist/server/koa/index.mjs"
32
39
  },
33
40
  "./fastify": {
34
- "import": "./dist/server/fastify/index.mjs",
35
- "require": "./dist/server/fastify/index.js"
41
+ "require": "./dist/server/fastify/index.js",
42
+ "import": "./dist/server/fastify/index.mjs"
36
43
  },
37
44
  "./hyper-express": {
38
- "import": "./dist/server/hyper-express/index.mjs",
39
- "require": "./dist/server/hyper-express/index.js"
45
+ "require": "./dist/server/hyper-express/index.js",
46
+ "import": "./dist/server/hyper-express/index.mjs"
40
47
  },
41
48
  "./hono": {
42
- "import": "./dist/server/hono/index.mjs",
43
- "require": "./dist/server/hono/index.js"
49
+ "require": "./dist/server/hono/index.js",
50
+ "import": "./dist/server/hono/index.mjs"
44
51
  },
45
52
  "./elysia": {
46
- "import": "./dist/server/elysia/index.mjs",
47
- "require": "./dist/server/elysia/index.js"
53
+ "require": "./dist/server/elysia/index.js",
54
+ "import": "./dist/server/elysia/index.mjs"
48
55
  },
49
56
  "./redis": {
50
- "import": "./dist/rpc/redis/index.mjs",
51
- "require": "./dist/rpc/redis/index.js"
57
+ "require": "./dist/rpc/redis/index.js",
58
+ "import": "./dist/rpc/redis/index.mjs"
52
59
  },
53
60
  "./kafka": {
54
- "import": "./dist/rpc/kafka/index.mjs",
55
- "require": "./dist/rpc/kafka/index.js"
61
+ "require": "./dist/rpc/kafka/index.js",
62
+ "import": "./dist/rpc/kafka/index.mjs"
56
63
  },
57
64
  "./rabbitmq": {
58
- "import": "./dist/rpc/rabbitmq/index.mjs",
59
- "require": "./dist/rpc/rabbitmq/index.js"
65
+ "require": "./dist/rpc/rabbitmq/index.js",
66
+ "import": "./dist/rpc/rabbitmq/index.mjs"
60
67
  },
61
68
  "./bullmq": {
62
- "import": "./dist/rpc/bullmq/index.mjs",
63
- "require": "./dist/rpc/bullmq/index.js"
69
+ "require": "./dist/rpc/bullmq/index.js",
70
+ "import": "./dist/rpc/bullmq/index.mjs"
64
71
  },
65
72
  "./nats": {
66
- "import": "./dist/rpc/nats/index.mjs",
67
- "require": "./dist/rpc/nats/index.js"
73
+ "require": "./dist/rpc/nats/index.js",
74
+ "import": "./dist/rpc/nats/index.mjs"
68
75
  },
69
76
  "./register": "./register/index.mjs",
70
77
  "./*": "./*"
71
78
  },
79
+ "main": "dist/index.js",
80
+ "module": "dist/index.mjs",
81
+ "types": "dist/index.d.ts",
72
82
  "typesVersions": {
73
83
  "*": {
74
84
  ".": [
@@ -77,6 +87,9 @@
77
87
  "test": [
78
88
  "dist/test.d.ts"
79
89
  ],
90
+ "helper": [
91
+ "dist/helper.d.ts"
92
+ ],
80
93
  "h3": [
81
94
  "dist/server/h3/index.d.ts"
82
95
  ],
@@ -115,20 +128,25 @@
115
128
  ]
116
129
  }
117
130
  },
118
- "keywords": [
119
- "server",
120
- "IOC",
121
- "rpc",
122
- "types-share"
123
- ],
124
- "author": "fgsreally",
125
- "repository": "https://github.com/fgsreally/phecda/tree/main/packages/server",
131
+ "bin": {
132
+ "phecda": "bin/cli.mjs"
133
+ },
126
134
  "files": [
127
135
  "dist",
136
+ "assets",
128
137
  "register",
129
138
  "bin"
130
139
  ],
131
- "license": "MIT",
140
+ "dependencies": {
141
+ "@swc-node/core": "^1.10.6",
142
+ "cac": "^6.7.14",
143
+ "chokidar": "^3.5.3",
144
+ "debug": "^4.3.4",
145
+ "fs-extra": "^11.2.0",
146
+ "picocolors": "^1.0.0",
147
+ "reflect-metadata": "^0.1.13",
148
+ "phecda-core": "3.0.0"
149
+ },
132
150
  "devDependencies": {
133
151
  "@koa/router": "^12.0.1",
134
152
  "@nucleoidjs/kafkajs-mock": "^0.0.1",
@@ -156,19 +174,9 @@
156
174
  "nats": "^2.22.0",
157
175
  "supertest": "^6.3.3",
158
176
  "tsup": "^6.5.0",
159
- "typescript": "^5.2.2",
177
+ "typescript": "^5.4.5",
160
178
  "unimport": "^3.7.1"
161
179
  },
162
- "dependencies": {
163
- "@swc-node/core": "^1.10.6",
164
- "cac": "^6.7.14",
165
- "chokidar": "^3.5.3",
166
- "debug": "^4.3.4",
167
- "fs-extra": "^11.2.0",
168
- "picocolors": "^1.0.0",
169
- "reflect-metadata": "^0.1.13",
170
- "phecda-core": "3.0.0"
171
- },
172
180
  "scripts": {
173
181
  "dev": "tsup --watch",
174
182
  "build": "tsup"
@@ -1,40 +1,40 @@
1
- import { register } from 'node:module'
2
- import { MessageChannel } from 'node:worker_threads'
3
- import { log } from '../dist/index.mjs'
4
- const { port1, port2 } = new MessageChannel()
5
-
6
- register('./loader.mjs', {
7
- parentURL: import.meta.url,
8
- data: { port: port2 },
9
- transferList: [port2],
10
- })
11
-
12
- let isRunning = true
13
-
14
- port1.on('message', async (data) => {
15
- const { type, files } = JSON.parse(data)
16
-
17
- if (!isRunning || !globalThis.__PS_HMR__ || type === 'relaunch')
18
- return process.exit(2)// file change -> relaunch
19
-
20
- if (type === 'change') {
21
- log('reload module...')
22
-
23
- for (const cb of globalThis.__PS_HMR__) await cb(files)
24
-
25
- log('reload done')
26
- }
27
- })
28
-
29
- process.on('uncaughtException', (err) => {
30
- log('Uncaught Exception:', 'error')
31
- isRunning = false
32
- console.error(err)
33
- })
34
-
35
- process.on('unhandledRejection', (err) => {
36
- log('Unhandled Promise Rejection:', 'error')
37
- isRunning = false
38
-
39
- console.error(err)
40
- })
1
+ import { register } from 'node:module'
2
+ import { MessageChannel } from 'node:worker_threads'
3
+ import { log } from '../dist/index.mjs'
4
+ const { port1, port2 } = new MessageChannel()
5
+
6
+ register('./loader.mjs', {
7
+ parentURL: import.meta.url,
8
+ data: { port: port2 },
9
+ transferList: [port2],
10
+ })
11
+
12
+ let isRunning = true
13
+
14
+ port1.on('message', async (data) => {
15
+ const { type, files } = JSON.parse(data)
16
+
17
+ if (!isRunning || !globalThis.__PS_HMR__ || type === 'relaunch')
18
+ return process.exit(2)// file change -> relaunch
19
+
20
+ if (type === 'change') {
21
+ log('reload module...')
22
+
23
+ for (const cb of globalThis.__PS_HMR__) await cb(files)
24
+
25
+ log('reload done')
26
+ }
27
+ })
28
+
29
+ process.on('uncaughtException', (err) => {
30
+ log('Uncaught Exception:', 'error')
31
+ isRunning = false
32
+ console.error(err)
33
+ })
34
+
35
+ process.on('unhandledRejection', (err) => {
36
+ log('Unhandled Promise Rejection:', 'error')
37
+ isRunning = false
38
+
39
+ console.error(err)
40
+ })