phecda-server 7.0.0-alpha.1 → 7.0.0-alpha.10

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 (86) hide show
  1. package/assets/ps.json +1 -1
  2. package/assets/schema.json +55 -55
  3. package/bin/cli.mjs +31 -23
  4. package/dist/chunk-4LLLQOMF.js +152 -0
  5. package/dist/{chunk-7YQ57BQS.js → chunk-6OQ2SB5W.js} +137 -69
  6. package/dist/{chunk-GSPBHZBH.js → chunk-G7JFKM2M.js} +96 -80
  7. package/dist/{chunk-MBCHNDAY.js → chunk-KCPBITYZ.js} +24 -24
  8. package/dist/{chunk-HMVLXNV3.mjs → chunk-MUI6MTUO.mjs} +1 -1
  9. package/dist/chunk-NQ55PA2X.mjs +152 -0
  10. package/dist/{chunk-XYVMNY2X.mjs → chunk-YCES6ABN.mjs} +124 -56
  11. package/dist/{chunk-V7EI76QQ.mjs → chunk-Z7NAAE4M.mjs} +48 -32
  12. package/dist/{core-BIcUwV18.d.mts → core-CUTbX_IS.d.ts} +5 -3
  13. package/dist/{core-CYwEPfN4.d.ts → core-DIfgUKIU.d.mts} +5 -3
  14. package/dist/helper.d.mts +8 -6
  15. package/dist/helper.d.ts +8 -6
  16. package/dist/helper.js +8 -3
  17. package/dist/helper.mjs +10 -5
  18. package/dist/http/elysia/index.d.mts +4 -4
  19. package/dist/http/elysia/index.d.ts +4 -4
  20. package/dist/http/elysia/index.js +43 -44
  21. package/dist/http/elysia/index.mjs +9 -10
  22. package/dist/http/express/index.d.mts +4 -4
  23. package/dist/http/express/index.d.ts +4 -4
  24. package/dist/http/express/index.js +40 -41
  25. package/dist/http/express/index.mjs +9 -10
  26. package/dist/http/fastify/index.d.mts +4 -4
  27. package/dist/http/fastify/index.d.ts +4 -4
  28. package/dist/http/fastify/index.js +41 -42
  29. package/dist/http/fastify/index.mjs +9 -10
  30. package/dist/http/h3/index.d.mts +4 -4
  31. package/dist/http/h3/index.d.ts +4 -4
  32. package/dist/http/h3/index.js +41 -42
  33. package/dist/http/h3/index.mjs +9 -10
  34. package/dist/http/hono/index.d.mts +4 -4
  35. package/dist/http/hono/index.d.ts +4 -4
  36. package/dist/http/hono/index.js +37 -39
  37. package/dist/http/hono/index.mjs +5 -7
  38. package/dist/http/hyper-express/index.d.mts +4 -4
  39. package/dist/http/hyper-express/index.d.ts +4 -4
  40. package/dist/http/hyper-express/index.js +38 -39
  41. package/dist/http/hyper-express/index.mjs +8 -9
  42. package/dist/http/koa/index.d.mts +4 -4
  43. package/dist/http/koa/index.d.ts +4 -4
  44. package/dist/http/koa/index.js +40 -41
  45. package/dist/http/koa/index.mjs +9 -10
  46. package/dist/index.d.mts +44 -38
  47. package/dist/index.d.ts +44 -38
  48. package/dist/index.js +48 -42
  49. package/dist/index.mjs +21 -15
  50. package/dist/{meta-BXKLFTgG.d.mts → meta-CR-D39hQ.d.mts} +7 -5
  51. package/dist/{meta-BXKLFTgG.d.ts → meta-CR-D39hQ.d.ts} +7 -5
  52. package/dist/rpc/bullmq/index.d.mts +5 -5
  53. package/dist/rpc/bullmq/index.d.ts +5 -5
  54. package/dist/rpc/bullmq/index.js +15 -14
  55. package/dist/rpc/bullmq/index.mjs +4 -3
  56. package/dist/rpc/kafka/index.d.mts +4 -4
  57. package/dist/rpc/kafka/index.d.ts +4 -4
  58. package/dist/rpc/kafka/index.js +15 -14
  59. package/dist/rpc/kafka/index.mjs +3 -2
  60. package/dist/rpc/nats/index.d.mts +4 -4
  61. package/dist/rpc/nats/index.d.ts +4 -4
  62. package/dist/rpc/nats/index.js +14 -13
  63. package/dist/rpc/nats/index.mjs +4 -3
  64. package/dist/rpc/rabbitmq/index.d.mts +4 -4
  65. package/dist/rpc/rabbitmq/index.d.ts +4 -4
  66. package/dist/rpc/rabbitmq/index.js +16 -15
  67. package/dist/rpc/rabbitmq/index.mjs +4 -3
  68. package/dist/rpc/redis/index.d.mts +4 -4
  69. package/dist/rpc/redis/index.d.ts +4 -4
  70. package/dist/rpc/redis/index.js +14 -13
  71. package/dist/rpc/redis/index.mjs +4 -3
  72. package/dist/test.d.mts +3 -3
  73. package/dist/test.d.ts +3 -3
  74. package/dist/test.js +6 -6
  75. package/dist/test.mjs +2 -2
  76. package/dist/{types-h40T3cRG.d.mts → types-BF1TDbFV.d.ts} +4 -3
  77. package/dist/{types-BtbL49Zs.d.mts → types-DYRu0vic.d.ts} +4 -3
  78. package/dist/{types-VFzEM7LL.d.ts → types-DYviSl5B.d.mts} +4 -3
  79. package/dist/{types-m3IEDKjP.d.ts → types-DqH1qA-q.d.mts} +4 -3
  80. package/package.json +8 -5
  81. package/register/export.mjs +30 -0
  82. package/register/index.mjs +50 -40
  83. package/register/loader.mjs +84 -66
  84. package/register/utils.mjs +60 -56
  85. package/dist/chunk-J5CFUN4V.js +0 -73
  86. package/dist/chunk-WHJ5FALK.mjs +0 -73
@@ -5,7 +5,9 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkJ5CFUN4Vjs = require('./chunk-J5CFUN4V.js');
8
+
9
+
10
+ var _chunk4LLLQOMFjs = require('./chunk-4LLLQOMF.js');
9
11
 
10
12
  // src/helper.ts
11
13
  var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
@@ -15,14 +17,14 @@ var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
15
17
 
16
18
 
17
19
  // src/pipe.ts
18
- var defaultPipe = /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, ({ arg }) => {
20
+ var defaultPipe = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, ({ arg }) => {
19
21
  return arg;
20
22
  }, "defaultPipe");
21
23
 
22
24
  // src/exception/base.ts
23
25
  var Exception = class extends Error {
24
26
  static {
25
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "Exception");
27
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "Exception");
26
28
  }
27
29
 
28
30
 
@@ -35,7 +37,7 @@ var Exception = class extends Error {
35
37
  message: this.message,
36
38
  description: this.description,
37
39
  status: this.status,
38
- [_chunkJ5CFUN4Vjs.ERROR_SYMBOL]: true
40
+ [_chunk4LLLQOMFjs.ERROR_SYMBOL]: true
39
41
  };
40
42
  }
41
43
  };
@@ -43,7 +45,7 @@ var Exception = class extends Error {
43
45
  // src/exception/undefine.ts
44
46
  var UndefinedException = class extends Exception {
45
47
  static {
46
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "UndefinedException");
48
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "UndefinedException");
47
49
  }
48
50
  constructor(message) {
49
51
  super(message, 500, "Undefined error");
@@ -53,7 +55,7 @@ var UndefinedException = class extends Exception {
53
55
  // src/exception/validate.ts
54
56
  var ValidateException = class extends Exception {
55
57
  static {
56
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "ValidateException");
58
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "ValidateException");
57
59
  }
58
60
  constructor(message) {
59
61
  super(message, 400, "Validate exception");
@@ -63,7 +65,7 @@ var ValidateException = class extends Exception {
63
65
  // src/exception/forbidden.ts
64
66
  var ForbiddenException = class extends Exception {
65
67
  static {
66
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "ForbiddenException");
68
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "ForbiddenException");
67
69
  }
68
70
  constructor(message) {
69
71
  super(message, 403, "Forbidden resource");
@@ -73,7 +75,7 @@ var ForbiddenException = class extends Exception {
73
75
  // src/exception/bad-request.ts
74
76
  var BadRequestException = class extends Exception {
75
77
  static {
76
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "BadRequestException");
78
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "BadRequestException");
77
79
  }
78
80
  constructor(message) {
79
81
  super(message, 400, "Bad Request");
@@ -83,7 +85,7 @@ var BadRequestException = class extends Exception {
83
85
  // src/exception/not-found.ts
84
86
  var NotFoundException = class extends Exception {
85
87
  static {
86
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "NotFoundException");
88
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "NotFoundException");
87
89
  }
88
90
  constructor(message) {
89
91
  super(message, 404, "Not Found");
@@ -93,7 +95,7 @@ var NotFoundException = class extends Exception {
93
95
  // src/exception/conflict.ts
94
96
  var ConflictException = class extends Exception {
95
97
  static {
96
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "ConflictException");
98
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "ConflictException");
97
99
  }
98
100
  constructor(message) {
99
101
  super(message, 409, "Conflict");
@@ -103,7 +105,7 @@ var ConflictException = class extends Exception {
103
105
  // src/exception/bad-gateway.ts
104
106
  var BadGatewayException = class extends Exception {
105
107
  static {
106
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "BadGatewayException");
108
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "BadGatewayException");
107
109
  }
108
110
  constructor(message) {
109
111
  super(message, 502, "Bad Gatrway");
@@ -113,7 +115,7 @@ var BadGatewayException = class extends Exception {
113
115
  // src/exception/invalid-input.ts
114
116
  var InvalidInputException = class extends Exception {
115
117
  static {
116
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "InvalidInputException");
118
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "InvalidInputException");
117
119
  }
118
120
  constructor(message) {
119
121
  super(message, 502, "Invalid Input");
@@ -123,7 +125,7 @@ var InvalidInputException = class extends Exception {
123
125
  // src/exception/media-type.ts
124
126
  var UnsupportedMediaTypeException = class extends Exception {
125
127
  static {
126
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "UnsupportedMediaTypeException");
128
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "UnsupportedMediaTypeException");
127
129
  }
128
130
  constructor(message) {
129
131
  super(message, 415, "Unsupported Media Type");
@@ -133,7 +135,7 @@ var UnsupportedMediaTypeException = class extends Exception {
133
135
  // src/exception/payload-large.ts
134
136
  var PayloadLargeException = class extends Exception {
135
137
  static {
136
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "PayloadLargeException");
138
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "PayloadLargeException");
137
139
  }
138
140
  constructor(message) {
139
141
  super(message, 413, "Payload Too Large");
@@ -143,7 +145,7 @@ var PayloadLargeException = class extends Exception {
143
145
  // src/exception/timeout.ts
144
146
  var TimeoutException = class extends Exception {
145
147
  static {
146
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "TimeoutException");
148
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "TimeoutException");
147
149
  }
148
150
  constructor(message) {
149
151
  super(message, 408, "Request Timeout");
@@ -153,7 +155,7 @@ var TimeoutException = class extends Exception {
153
155
  // src/exception/unauthorized.ts
154
156
  var UnauthorizedException = class extends Exception {
155
157
  static {
156
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "UnauthorizedException");
158
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "UnauthorizedException");
157
159
  }
158
160
  constructor(message) {
159
161
  super(message, 401, "Unauthorized");
@@ -163,7 +165,7 @@ var UnauthorizedException = class extends Exception {
163
165
  // src/exception/unavailable-service.ts
164
166
  var ServiceUnavailableException = class extends Exception {
165
167
  static {
166
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "ServiceUnavailableException");
168
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "ServiceUnavailableException");
167
169
  }
168
170
  constructor(message) {
169
171
  super(message, 503, "Service Unavailable");
@@ -173,7 +175,7 @@ var ServiceUnavailableException = class extends Exception {
173
175
  // src/exception/framework.ts
174
176
  var FrameworkException = class extends Exception {
175
177
  static {
176
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "FrameworkException");
178
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "FrameworkException");
177
179
  }
178
180
  constructor(message) {
179
181
  super(`[phecda-server] ${message}`, 500, "Framework Error");
@@ -183,7 +185,7 @@ var FrameworkException = class extends Exception {
183
185
  // src/exception/timer.ts
184
186
  var TimerException = class extends Exception {
185
187
  static {
186
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "TimerException");
188
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "TimerException");
187
189
  }
188
190
  constructor(message) {
189
191
  super(message, 0, "Timer Error");
@@ -193,7 +195,7 @@ var TimerException = class extends Exception {
193
195
  // src/exception/worker.ts
194
196
  var WorkerException = class extends Exception {
195
197
  static {
196
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "WorkerException");
198
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "WorkerException");
197
199
  }
198
200
  constructor(message) {
199
201
  super(message, 0, "Worker Error");
@@ -201,14 +203,14 @@ var WorkerException = class extends Exception {
201
203
  };
202
204
 
203
205
  // src/filter.ts
204
- var defaultFilter = /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (e) => {
206
+ var defaultFilter = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (e) => {
205
207
  if (!(e instanceof Exception)) {
206
- _chunkJ5CFUN4Vjs.log.call(void 0, e.message, "error");
207
- if (_chunkJ5CFUN4Vjs.LOG_LEVEL <= 0) console.error(e.stack);
208
+ _chunk4LLLQOMFjs.log.call(void 0, e.message, "error");
209
+ if (_chunk4LLLQOMFjs.LOG_LEVEL <= 0) console.error(e.stack);
208
210
  e = new UndefinedException(e.message || e);
209
211
  } else {
210
- _chunkJ5CFUN4Vjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
211
- if (_chunkJ5CFUN4Vjs.LOG_LEVEL <= 0) console.error(e.stack);
212
+ _chunk4LLLQOMFjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
213
+ if (_chunk4LLLQOMFjs.LOG_LEVEL <= 0) console.error(e.stack);
212
214
  }
213
215
  return e.data;
214
216
  }, "defaultFilter");
@@ -217,7 +219,7 @@ var defaultFilter = /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (e) =>
217
219
  var debug = _debug2.default.call(void 0, "phecda-server(Context)");
218
220
  var Context = (_class = class _Context {
219
221
  static {
220
- _chunkJ5CFUN4Vjs.__name.call(void 0, this, "Context");
222
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "Context");
221
223
  }
222
224
 
223
225
 
@@ -230,10 +232,25 @@ var Context = (_class = class _Context {
230
232
  }}
231
233
  static __initStatic3() {this.guardRecord = {}}
232
234
  static __initStatic4() {this.addonRecord = {}}
235
+
236
+
233
237
  constructor(data) {
234
238
  this.data = data;
235
- if (_chunkJ5CFUN4Vjs.IS_HMR)
239
+ this.canGetCtx = true;
240
+ if (_chunk4LLLQOMFjs.IS_DEV)
236
241
  data._context = this;
242
+ const that = this;
243
+ this.ctx = new Proxy(data, {
244
+ get(target, p) {
245
+ if (_chunk4LLLQOMFjs.IS_DEV && !that.canGetCtx) throw new FrameworkException("ctx must be obtained within the same request cycle in controller");
246
+ if (!(p in target)) _chunk4LLLQOMFjs.log.call(void 0, `attribute "${p}" does not exist on ctx, which might be due to a missing AOP role (such as a guard).`, "warn", data.tag);
247
+ return target[p];
248
+ },
249
+ set(target, p, newValue) {
250
+ target[p] = newValue;
251
+ return true;
252
+ }
253
+ });
237
254
  }
238
255
  static getAop(meta, opts) {
239
256
  const { globalGuards = [], globalFilter = "default", globalPipe = "default" } = opts;
@@ -264,19 +281,25 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
264
281
  const { paramsType, data: { ctxs, tag, params, func } } = meta;
265
282
  try {
266
283
  let res;
267
- const nextHandler = /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (index) => {
284
+ const nextHandler = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (index) => {
268
285
  return async () => {
269
286
  if (index === guards.length) {
270
287
  const instance = moduleMap.get(tag);
271
288
  if (ctxs) {
272
- ctxs.forEach((ctx) => instance[ctx] = this.data);
289
+ ctxs.forEach((ctx) => instance[ctx] = this.ctx);
273
290
  }
274
291
  const args = await Promise.all(params.map((item, i) => pipe[i]({
275
292
  arg: resolveDep(this.data[item.type], item.key),
276
293
  reflect: paramsType[item.index],
277
294
  ...item
278
- }, this.data)));
295
+ }, this.ctx)));
296
+ if (_chunk4LLLQOMFjs.IS_DEV) {
297
+ Promise.resolve().then(() => {
298
+ this.canGetCtx = false;
299
+ });
300
+ }
279
301
  res = await instance[func](...args);
302
+ this.canGetCtx = true;
280
303
  } else {
281
304
  let nextPromise;
282
305
  async function next() {
@@ -288,8 +311,8 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
288
311
  return res;
289
312
  });
290
313
  }
291
- _chunkJ5CFUN4Vjs.__name.call(void 0, next, "next");
292
- const ret = await guards[index](this.data, next);
314
+ _chunk4LLLQOMFjs.__name.call(void 0, next, "next");
315
+ const ret = await guards[index](this.ctx, next);
293
316
  if (ret !== void 0) {
294
317
  res = ret;
295
318
  } else {
@@ -302,7 +325,7 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
302
325
  await nextHandler(0)();
303
326
  return successCb(res);
304
327
  } catch (e) {
305
- const err = await filter(e, this.data);
328
+ const err = await filter(e, this.ctx);
306
329
  return failCb(err);
307
330
  }
308
331
  }
@@ -333,12 +356,12 @@ function addPipe(key, pipe) {
333
356
  if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) debug(`overwrite Pipe "${String(key)}"`, "warn");
334
357
  Context.pipeRecord[key] = pipe;
335
358
  }
336
- _chunkJ5CFUN4Vjs.__name.call(void 0, addPipe, "addPipe");
359
+ _chunk4LLLQOMFjs.__name.call(void 0, addPipe, "addPipe");
337
360
  function addFilter(key, filter) {
338
361
  if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) debug(`overwrite Filter "${String(key)}"`, "warn");
339
362
  Context.filterRecord[key] = filter;
340
363
  }
341
- _chunkJ5CFUN4Vjs.__name.call(void 0, addFilter, "addFilter");
364
+ _chunk4LLLQOMFjs.__name.call(void 0, addFilter, "addFilter");
342
365
  function addGuard(key, guard, priority = 0) {
343
366
  if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) debug(`overwrite Guard "${String(key)}"`, "warn");
344
367
  Context.guardRecord[key] = {
@@ -346,7 +369,7 @@ function addGuard(key, guard, priority = 0) {
346
369
  priority
347
370
  };
348
371
  }
349
- _chunkJ5CFUN4Vjs.__name.call(void 0, addGuard, "addGuard");
372
+ _chunk4LLLQOMFjs.__name.call(void 0, addGuard, "addGuard");
350
373
  function addAddon(key, addon, priority = 0) {
351
374
  if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) debug(`overwrite Addon "${String(key)}"`, "warn");
352
375
  Context.addonRecord[key] = {
@@ -354,41 +377,21 @@ function addAddon(key, addon, priority = 0) {
354
377
  priority
355
378
  };
356
379
  }
357
- _chunkJ5CFUN4Vjs.__name.call(void 0, addAddon, "addAddon");
358
-
359
- // src/hmr.ts
360
- function HMR(cb) {
361
- if (_chunkJ5CFUN4Vjs.IS_HMR) _optionalChain([globalThis, 'access', _ => _.__PS_HMR__, 'optionalAccess', _2 => _2.push, 'call', _3 => _3(cb)]);
362
- }
363
- _chunkJ5CFUN4Vjs.__name.call(void 0, HMR, "HMR");
380
+ _chunk4LLLQOMFjs.__name.call(void 0, addAddon, "addAddon");
364
381
 
365
382
  // src/http/helper.ts
366
383
  function resolveDep(ret, key) {
367
- if (key) return _optionalChain([ret, 'optionalAccess', _4 => _4[key]]);
384
+ if (key) return _optionalChain([ret, 'optionalAccess', _ => _[key]]);
368
385
  return ret;
369
386
  }
370
- _chunkJ5CFUN4Vjs.__name.call(void 0, resolveDep, "resolveDep");
371
- function argToReq(params, args, headers) {
372
- const req = {
373
- body: {},
374
- query: {},
375
- params: {},
376
- headers
377
- };
378
- params.forEach((param) => {
379
- if (param.key) req[param.type][param.key] = args[param.index];
380
- else req[param.type] = args[param.index];
381
- });
382
- return req;
383
- }
384
- _chunkJ5CFUN4Vjs.__name.call(void 0, argToReq, "argToReq");
387
+ _chunk4LLLQOMFjs.__name.call(void 0, resolveDep, "resolveDep");
385
388
 
386
389
  // src/rpc/helper.ts
387
390
  var _os = require('os');
388
391
  function genClientQueue(key) {
389
392
  return `PS-${key ? `${key}-` : ""}${_os.hostname.call(void 0, )}-${process.pid}`;
390
393
  }
391
- _chunkJ5CFUN4Vjs.__name.call(void 0, genClientQueue, "genClientQueue");
394
+ _chunk4LLLQOMFjs.__name.call(void 0, genClientQueue, "genClientQueue");
392
395
 
393
396
  // src/decorators/helper.ts
394
397
  function shallowClone(obj) {
@@ -396,11 +399,11 @@ function shallowClone(obj) {
396
399
  ...obj
397
400
  };
398
401
  }
399
- _chunkJ5CFUN4Vjs.__name.call(void 0, shallowClone, "shallowClone");
402
+ _chunk4LLLQOMFjs.__name.call(void 0, shallowClone, "shallowClone");
400
403
  function mergeObject(...args) {
401
404
  return Object.assign({}, ...args);
402
405
  }
403
- _chunkJ5CFUN4Vjs.__name.call(void 0, mergeObject, "mergeObject");
406
+ _chunk4LLLQOMFjs.__name.call(void 0, mergeObject, "mergeObject");
404
407
 
405
408
  // src/helper.ts
406
409
  function createControllerMetaMap(meta, filter) {
@@ -416,13 +419,14 @@ function createControllerMetaMap(meta, filter) {
416
419
  });
417
420
  }
418
421
  }
419
- _chunkJ5CFUN4Vjs.__name.call(void 0, handleMeta, "handleMeta");
422
+ _chunk4LLLQOMFjs.__name.call(void 0, handleMeta, "handleMeta");
420
423
  handleMeta();
421
- HMR(handleMeta);
424
+ _chunk4LLLQOMFjs.HMR.call(void 0, handleMeta);
422
425
  return metaMap;
423
426
  }
424
- _chunkJ5CFUN4Vjs.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
427
+ _chunk4LLLQOMFjs.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
425
428
  function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
429
+ if (_chunk4LLLQOMFjs.IS_PURE) return;
426
430
  const addonSet = /* @__PURE__ */ new Set();
427
431
  const guardSet = /* @__PURE__ */ new Set();
428
432
  const pipeSet = /* @__PURE__ */ new Set();
@@ -434,15 +438,17 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
434
438
  pipeSet.clear();
435
439
  filterSet.clear();
436
440
  warningSet.clear();
437
- _optionalChain([addons, 'optionalAccess', _5 => _5.forEach, 'call', _6 => _6((item) => {
441
+ _optionalChain([addons, 'optionalAccess', _2 => _2.forEach, 'call', _3 => _3((item) => {
438
442
  addonSet.add(item);
439
443
  })]);
440
- _optionalChain([guards, 'optionalAccess', _7 => _7.forEach, 'call', _8 => _8((item) => {
444
+ _optionalChain([guards, 'optionalAccess', _4 => _4.forEach, 'call', _5 => _5((item) => {
441
445
  guardSet.add(item);
442
446
  })]);
443
447
  meta.forEach(({ data }) => {
448
+ if (!data.controller) return;
449
+ if (typeof data.tag !== "string") warningSet.add(`Tag of controller "${data.name}" should be a string`);
444
450
  if (data.controller !== controller) {
445
- if (data[controller]) warningSet.add(`Should use ${controller} controller to decorate class "${data.name}" or method "${data.func}"`);
451
+ if (data[controller]) warningSet.add(`Should use ${controller} controller to decorate class "${data.name}"`);
446
452
  return;
447
453
  }
448
454
  if (data.filter) filterSet.add(data.filter);
@@ -465,31 +471,34 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
465
471
  ...filterSet
466
472
  ].filter((i) => !Context.filterRecord[i]);
467
473
  function exit() {
468
- if (_chunkJ5CFUN4Vjs.IS_STRICT) process.exit(5);
474
+ if (_chunk4LLLQOMFjs.IS_STRICT) {
475
+ _chunk4LLLQOMFjs.log.call(void 0, "Does not meet strict mode requirements", "error");
476
+ process.exit(1);
477
+ }
469
478
  }
470
- _chunkJ5CFUN4Vjs.__name.call(void 0, exit, "exit");
479
+ _chunk4LLLQOMFjs.__name.call(void 0, exit, "exit");
471
480
  if (missAddons.length) {
472
- _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
481
+ _chunk4LLLQOMFjs.log.call(void 0, `${_picocolors2.default.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
473
482
  exit();
474
483
  }
475
484
  if (missGuards.length) {
476
- _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
485
+ _chunk4LLLQOMFjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
477
486
  exit();
478
487
  }
479
488
  if (missPipes.length) {
480
- _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
489
+ _chunk4LLLQOMFjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
481
490
  exit();
482
491
  }
483
492
  if (missFilters.length) {
484
- _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
493
+ _chunk4LLLQOMFjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
485
494
  exit();
486
495
  }
487
- warningSet.forEach((warn) => _chunkJ5CFUN4Vjs.log.call(void 0, warn, "warn"));
496
+ warningSet.forEach((warn) => _chunk4LLLQOMFjs.log.call(void 0, warn, "warn"));
488
497
  if (warningSet.size) exit();
489
498
  }
490
- _chunkJ5CFUN4Vjs.__name.call(void 0, handleMeta, "handleMeta");
499
+ _chunk4LLLQOMFjs.__name.call(void 0, handleMeta, "handleMeta");
491
500
  handleMeta();
492
- HMR(handleMeta);
501
+ _chunk4LLLQOMFjs.HMR.call(void 0, handleMeta);
493
502
  return {
494
503
  addonSet,
495
504
  guardSet,
@@ -497,8 +506,15 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
497
506
  filterSet
498
507
  };
499
508
  }
500
- _chunkJ5CFUN4Vjs.__name.call(void 0, detectAopDep, "detectAopDep");
501
-
509
+ _chunk4LLLQOMFjs.__name.call(void 0, detectAopDep, "detectAopDep");
510
+ function joinUrl(base, ...paths) {
511
+ const joinedPath = [
512
+ base,
513
+ ...paths
514
+ ].filter((p) => p).map((path) => path.replace(/(^\/)/g, "")).join("/");
515
+ return `/${joinedPath}`;
516
+ }
517
+ _chunk4LLLQOMFjs.__name.call(void 0, joinUrl, "joinUrl");
502
518
 
503
519
 
504
520
 
@@ -531,4 +547,4 @@ _chunkJ5CFUN4Vjs.__name.call(void 0, detectAopDep, "detectAopDep");
531
547
 
532
548
 
533
549
 
534
- exports.defaultPipe = defaultPipe; exports.Exception = Exception; exports.UndefinedException = UndefinedException; exports.ValidateException = ValidateException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.TimerException = TimerException; exports.WorkerException = WorkerException; exports.Context = Context; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addAddon = addAddon; exports.HMR = HMR; exports.resolveDep = resolveDep; exports.argToReq = argToReq; exports.genClientQueue = genClientQueue; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep;
550
+ exports.defaultPipe = defaultPipe; exports.Exception = Exception; exports.UndefinedException = UndefinedException; exports.ValidateException = ValidateException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.TimerException = TimerException; exports.WorkerException = WorkerException; exports.Context = Context; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addAddon = addAddon; exports.resolveDep = resolveDep; exports.genClientQueue = genClientQueue; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep; exports.joinUrl = joinUrl;
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkJ5CFUN4Vjs = require('./chunk-J5CFUN4V.js');
3
+ var _chunk4LLLQOMFjs = require('./chunk-4LLLQOMF.js');
4
4
 
5
5
  // src/decorators/param.ts
6
6
  var _phecdacore = require('phecda-core');
@@ -10,42 +10,42 @@ function BaseParam(data) {
10
10
  _phecdacore.setMeta.call(void 0, target, property, index, data);
11
11
  };
12
12
  }
13
- _chunkJ5CFUN4Vjs.__name.call(void 0, BaseParam, "BaseParam");
13
+ _chunk4LLLQOMFjs.__name.call(void 0, BaseParam, "BaseParam");
14
14
  function Body(key = "") {
15
15
  return BaseParam({
16
16
  type: "body",
17
17
  key
18
18
  });
19
19
  }
20
- _chunkJ5CFUN4Vjs.__name.call(void 0, Body, "Body");
20
+ _chunk4LLLQOMFjs.__name.call(void 0, Body, "Body");
21
21
  function Head(key) {
22
22
  return BaseParam({
23
23
  type: "headers",
24
24
  key: key.toLowerCase()
25
25
  });
26
26
  }
27
- _chunkJ5CFUN4Vjs.__name.call(void 0, Head, "Head");
27
+ _chunk4LLLQOMFjs.__name.call(void 0, Head, "Head");
28
28
  function Query(key = "") {
29
29
  return BaseParam({
30
30
  type: "query",
31
31
  key
32
32
  });
33
33
  }
34
- _chunkJ5CFUN4Vjs.__name.call(void 0, Query, "Query");
34
+ _chunk4LLLQOMFjs.__name.call(void 0, Query, "Query");
35
35
  function Param(key) {
36
36
  return BaseParam({
37
37
  type: "params",
38
38
  key
39
39
  });
40
40
  }
41
- _chunkJ5CFUN4Vjs.__name.call(void 0, Param, "Param");
41
+ _chunk4LLLQOMFjs.__name.call(void 0, Param, "Param");
42
42
  function Arg(target, k, index) {
43
43
  BaseParam({
44
44
  type: "args",
45
45
  key: `${index}`
46
46
  })(target, k, index);
47
47
  }
48
- _chunkJ5CFUN4Vjs.__name.call(void 0, Arg, "Arg");
48
+ _chunk4LLLQOMFjs.__name.call(void 0, Arg, "Arg");
49
49
 
50
50
  // src/decorators/aop.ts
51
51
 
@@ -56,7 +56,7 @@ function Guard(...guards) {
56
56
  });
57
57
  };
58
58
  }
59
- _chunkJ5CFUN4Vjs.__name.call(void 0, Guard, "Guard");
59
+ _chunk4LLLQOMFjs.__name.call(void 0, Guard, "Guard");
60
60
  function Addon(...addons) {
61
61
  return (target, property) => {
62
62
  _phecdacore.setMeta.call(void 0, target, property, void 0, {
@@ -64,7 +64,7 @@ function Addon(...addons) {
64
64
  });
65
65
  };
66
66
  }
67
- _chunkJ5CFUN4Vjs.__name.call(void 0, Addon, "Addon");
67
+ _chunk4LLLQOMFjs.__name.call(void 0, Addon, "Addon");
68
68
  function Filter(filter) {
69
69
  return (target, property) => {
70
70
  _phecdacore.setMeta.call(void 0, target, property, void 0, {
@@ -72,7 +72,7 @@ function Filter(filter) {
72
72
  });
73
73
  };
74
74
  }
75
- _chunkJ5CFUN4Vjs.__name.call(void 0, Filter, "Filter");
75
+ _chunk4LLLQOMFjs.__name.call(void 0, Filter, "Filter");
76
76
  function Pipe(pipe) {
77
77
  return (target, property, index) => {
78
78
  if (typeof index === "number") {
@@ -86,7 +86,7 @@ function Pipe(pipe) {
86
86
  });
87
87
  };
88
88
  }
89
- _chunkJ5CFUN4Vjs.__name.call(void 0, Pipe, "Pipe");
89
+ _chunk4LLLQOMFjs.__name.call(void 0, Pipe, "Pipe");
90
90
 
91
91
  // src/decorators/http.ts
92
92
 
@@ -100,7 +100,7 @@ function Route(route, type) {
100
100
  });
101
101
  };
102
102
  }
103
- _chunkJ5CFUN4Vjs.__name.call(void 0, Route, "Route");
103
+ _chunk4LLLQOMFjs.__name.call(void 0, Route, "Route");
104
104
  function Header(headers) {
105
105
  return (target, property) => {
106
106
  _phecdacore.setMeta.call(void 0, target, property, void 0, {
@@ -110,31 +110,31 @@ function Header(headers) {
110
110
  });
111
111
  };
112
112
  }
113
- _chunkJ5CFUN4Vjs.__name.call(void 0, Header, "Header");
113
+ _chunk4LLLQOMFjs.__name.call(void 0, Header, "Header");
114
114
  function Get(route = "") {
115
115
  return Route(route, "get");
116
116
  }
117
- _chunkJ5CFUN4Vjs.__name.call(void 0, Get, "Get");
117
+ _chunk4LLLQOMFjs.__name.call(void 0, Get, "Get");
118
118
  function Post(route = "") {
119
119
  return Route(route, "post");
120
120
  }
121
- _chunkJ5CFUN4Vjs.__name.call(void 0, Post, "Post");
121
+ _chunk4LLLQOMFjs.__name.call(void 0, Post, "Post");
122
122
  function Put(route = "") {
123
123
  return Route(route, "put");
124
124
  }
125
- _chunkJ5CFUN4Vjs.__name.call(void 0, Put, "Put");
125
+ _chunk4LLLQOMFjs.__name.call(void 0, Put, "Put");
126
126
  function Search(route = "") {
127
127
  return Route(route, "search");
128
128
  }
129
- _chunkJ5CFUN4Vjs.__name.call(void 0, Search, "Search");
129
+ _chunk4LLLQOMFjs.__name.call(void 0, Search, "Search");
130
130
  function Patch(route = "") {
131
131
  return Route(route, "patch");
132
132
  }
133
- _chunkJ5CFUN4Vjs.__name.call(void 0, Patch, "Patch");
133
+ _chunk4LLLQOMFjs.__name.call(void 0, Patch, "Patch");
134
134
  function Delete(route = "") {
135
135
  return Route(route, "delete");
136
136
  }
137
- _chunkJ5CFUN4Vjs.__name.call(void 0, Delete, "Delete");
137
+ _chunk4LLLQOMFjs.__name.call(void 0, Delete, "Delete");
138
138
  function Controller(prefix = "") {
139
139
  return (target) => {
140
140
  _phecdacore.setMeta.call(void 0, target, void 0, void 0, {
@@ -145,7 +145,7 @@ function Controller(prefix = "") {
145
145
  });
146
146
  };
147
147
  }
148
- _chunkJ5CFUN4Vjs.__name.call(void 0, Controller, "Controller");
148
+ _chunk4LLLQOMFjs.__name.call(void 0, Controller, "Controller");
149
149
 
150
150
  // src/decorators/rpc.ts
151
151
 
@@ -159,7 +159,7 @@ function Queue(queue = "", isEvent) {
159
159
  });
160
160
  };
161
161
  }
162
- _chunkJ5CFUN4Vjs.__name.call(void 0, Queue, "Queue");
162
+ _chunk4LLLQOMFjs.__name.call(void 0, Queue, "Queue");
163
163
  function Rpc() {
164
164
  return (target) => {
165
165
  _phecdacore.setMeta.call(void 0, target, void 0, void 0, {
@@ -167,11 +167,11 @@ function Rpc() {
167
167
  });
168
168
  };
169
169
  }
170
- _chunkJ5CFUN4Vjs.__name.call(void 0, Rpc, "Rpc");
170
+ _chunk4LLLQOMFjs.__name.call(void 0, Rpc, "Rpc");
171
171
 
172
172
  // src/decorators/ctx.ts
173
173
 
174
- var Ctx = /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (target, property) => {
174
+ var Ctx = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (target, property) => {
175
175
  _phecdacore.setMeta.call(void 0, target, _phecdacore.SHARE_KEY, void 0, {
176
176
  ctxs: [
177
177
  property
@@ -200,7 +200,7 @@ function Define(key, value) {
200
200
  }
201
201
  };
202
202
  }
203
- _chunkJ5CFUN4Vjs.__name.call(void 0, Define, "Define");
203
+ _chunk4LLLQOMFjs.__name.call(void 0, Define, "Define");
204
204
 
205
205
 
206
206
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-WHJ5FALK.mjs";
3
+ } from "./chunk-NQ55PA2X.mjs";
4
4
 
5
5
  // src/decorators/param.ts
6
6
  import { setMeta } from "phecda-core";