phecda-server 6.1.0 → 7.0.0-alpha.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 (80) hide show
  1. package/bin/cli.mjs +160 -157
  2. package/dist/{chunk-3H3T54IC.mjs → chunk-5622RBNB.mjs} +3 -4
  3. package/dist/{chunk-NL6QBQAR.js → chunk-BGXSMOLX.js} +20 -21
  4. package/dist/{chunk-J7B24YSE.mjs → chunk-HMVLXNV3.mjs} +5 -14
  5. package/dist/{chunk-TVT62GIX.js → chunk-J5CFUN4V.js} +8 -1
  6. package/dist/{chunk-JDV2XJYE.js → chunk-MBCHNDAY.js} +27 -36
  7. package/dist/{chunk-2CFYUXPM.mjs → chunk-P75VKZJY.mjs} +101 -137
  8. package/dist/chunk-SW5IKE5H.js +503 -0
  9. package/dist/{chunk-G7TD2VB7.mjs → chunk-WHJ5FALK.mjs} +7 -0
  10. package/dist/{core-P1CsH6jz.d.mts → core-BIcUwV18.d.mts} +1 -1
  11. package/dist/{core-BlN0Spy9.d.ts → core-CYwEPfN4.d.ts} +1 -1
  12. package/dist/helper.d.mts +4 -6
  13. package/dist/helper.d.ts +4 -6
  14. package/dist/helper.js +3 -3
  15. package/dist/helper.mjs +2 -2
  16. package/dist/{server → http}/elysia/index.d.mts +5 -5
  17. package/dist/{server → http}/elysia/index.d.ts +5 -5
  18. package/dist/{server → http}/elysia/index.js +80 -62
  19. package/dist/{server → http}/elysia/index.mjs +50 -32
  20. package/dist/{server → http}/express/index.d.mts +5 -5
  21. package/dist/{server → http}/express/index.d.ts +5 -5
  22. package/dist/{server → http}/express/index.js +71 -55
  23. package/dist/{server → http}/express/index.mjs +42 -26
  24. package/dist/{server → http}/fastify/index.d.mts +5 -5
  25. package/dist/{server → http}/fastify/index.d.ts +5 -5
  26. package/dist/{server → http}/fastify/index.js +72 -72
  27. package/dist/{server → http}/fastify/index.mjs +47 -47
  28. package/dist/{server → http}/h3/index.d.mts +5 -5
  29. package/dist/{server → http}/h3/index.d.ts +5 -5
  30. package/dist/http/h3/index.js +160 -0
  31. package/dist/{server → http}/h3/index.mjs +68 -62
  32. package/dist/{server → http}/hono/index.d.mts +5 -5
  33. package/dist/{server → http}/hono/index.d.ts +5 -5
  34. package/dist/{server → http}/hono/index.js +69 -54
  35. package/dist/{server → http}/hono/index.mjs +41 -26
  36. package/dist/{server → http}/hyper-express/index.d.mts +5 -5
  37. package/dist/{server → http}/hyper-express/index.d.ts +5 -5
  38. package/dist/{server → http}/hyper-express/index.js +69 -56
  39. package/dist/{server → http}/hyper-express/index.mjs +41 -28
  40. package/dist/{server → http}/koa/index.d.mts +5 -5
  41. package/dist/{server → http}/koa/index.d.ts +5 -5
  42. package/dist/{server → http}/koa/index.js +71 -55
  43. package/dist/{server → http}/koa/index.mjs +42 -26
  44. package/dist/index.d.mts +51 -40
  45. package/dist/index.d.ts +51 -40
  46. package/dist/index.js +59 -81
  47. package/dist/index.mjs +39 -61
  48. package/dist/{meta-KtfiBIde.d.ts → meta-BXKLFTgG.d.mts} +2 -3
  49. package/dist/{meta-KtfiBIde.d.mts → meta-BXKLFTgG.d.ts} +2 -3
  50. package/dist/rpc/bullmq/index.d.mts +6 -6
  51. package/dist/rpc/bullmq/index.d.ts +6 -6
  52. package/dist/rpc/bullmq/index.js +24 -24
  53. package/dist/rpc/bullmq/index.mjs +14 -14
  54. package/dist/rpc/kafka/index.d.mts +3 -3
  55. package/dist/rpc/kafka/index.d.ts +3 -3
  56. package/dist/rpc/kafka/index.js +25 -21
  57. package/dist/rpc/kafka/index.mjs +15 -11
  58. package/dist/rpc/nats/index.d.mts +3 -3
  59. package/dist/rpc/nats/index.d.ts +3 -3
  60. package/dist/rpc/nats/index.js +22 -21
  61. package/dist/rpc/nats/index.mjs +13 -12
  62. package/dist/rpc/rabbitmq/index.d.mts +3 -3
  63. package/dist/rpc/rabbitmq/index.d.ts +3 -3
  64. package/dist/rpc/rabbitmq/index.js +23 -22
  65. package/dist/rpc/rabbitmq/index.mjs +12 -11
  66. package/dist/rpc/redis/index.d.mts +3 -3
  67. package/dist/rpc/redis/index.d.ts +3 -3
  68. package/dist/rpc/redis/index.js +24 -20
  69. package/dist/rpc/redis/index.mjs +15 -11
  70. package/dist/test.d.mts +3 -3
  71. package/dist/test.d.ts +3 -3
  72. package/dist/test.js +6 -6
  73. package/dist/test.mjs +2 -2
  74. package/dist/{types-JVT0mgLD.d.ts → types-BtbL49Zs.d.mts} +2 -1
  75. package/dist/{types-DIw7B6Up.d.ts → types-VFzEM7LL.d.ts} +5 -5
  76. package/dist/{types-BvD3B5Ny.d.mts → types-h40T3cRG.d.mts} +5 -5
  77. package/dist/{types-t9D1fU6G.d.mts → types-m3IEDKjP.d.ts} +2 -1
  78. package/package.json +23 -23
  79. package/dist/chunk-DVTBLV6I.js +0 -539
  80. package/dist/server/h3/index.js +0 -154
@@ -0,0 +1,503 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
+
3
+
4
+
5
+
6
+
7
+ var _chunkJ5CFUN4Vjs = require('./chunk-J5CFUN4V.js');
8
+
9
+ // src/helper.ts
10
+ var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
11
+
12
+ // src/context.ts
13
+ var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
14
+
15
+ // src/pipe.ts
16
+ var defaultPipe = /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, ({ arg }) => {
17
+ return arg;
18
+ }, "defaultPipe");
19
+
20
+ // src/exception/base.ts
21
+ var Exception = class extends Error {
22
+ static {
23
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "Exception");
24
+ }
25
+
26
+
27
+
28
+ constructor(message, status = 0, description = "Exception") {
29
+ super(message), this.message = message, this.status = status, this.description = description;
30
+ }
31
+ get data() {
32
+ return {
33
+ message: this.message,
34
+ description: this.description,
35
+ status: this.status,
36
+ [_chunkJ5CFUN4Vjs.ERROR_SYMBOL]: true
37
+ };
38
+ }
39
+ };
40
+
41
+ // src/exception/undefine.ts
42
+ var UndefinedException = class extends Exception {
43
+ static {
44
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "UndefinedException");
45
+ }
46
+ constructor(message) {
47
+ super(message, 500, "Undefined error");
48
+ }
49
+ };
50
+
51
+ // src/exception/validate.ts
52
+ var ValidateException = class extends Exception {
53
+ static {
54
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "ValidateException");
55
+ }
56
+ constructor(message) {
57
+ super(message, 400, "Validate exception");
58
+ }
59
+ };
60
+
61
+ // src/exception/forbidden.ts
62
+ var ForbiddenException = class extends Exception {
63
+ static {
64
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "ForbiddenException");
65
+ }
66
+ constructor(message) {
67
+ super(message, 403, "Forbidden resource");
68
+ }
69
+ };
70
+
71
+ // src/exception/bad-request.ts
72
+ var BadRequestException = class extends Exception {
73
+ static {
74
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "BadRequestException");
75
+ }
76
+ constructor(message) {
77
+ super(message, 400, "Bad Request");
78
+ }
79
+ };
80
+
81
+ // src/exception/not-found.ts
82
+ var NotFoundException = class extends Exception {
83
+ static {
84
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "NotFoundException");
85
+ }
86
+ constructor(message) {
87
+ super(message, 404, "Not Found");
88
+ }
89
+ };
90
+
91
+ // src/exception/conflict.ts
92
+ var ConflictException = class extends Exception {
93
+ static {
94
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "ConflictException");
95
+ }
96
+ constructor(message) {
97
+ super(message, 409, "Conflict");
98
+ }
99
+ };
100
+
101
+ // src/exception/bad-gateway.ts
102
+ var BadGatewayException = class extends Exception {
103
+ static {
104
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "BadGatewayException");
105
+ }
106
+ constructor(message) {
107
+ super(message, 502, "Bad Gatrway");
108
+ }
109
+ };
110
+
111
+ // src/exception/invalid-input.ts
112
+ var InvalidInputException = class extends Exception {
113
+ static {
114
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "InvalidInputException");
115
+ }
116
+ constructor(message) {
117
+ super(message, 502, "Invalid Input");
118
+ }
119
+ };
120
+
121
+ // src/exception/media-type.ts
122
+ var UnsupportedMediaTypeException = class extends Exception {
123
+ static {
124
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "UnsupportedMediaTypeException");
125
+ }
126
+ constructor(message) {
127
+ super(message, 415, "Unsupported Media Type");
128
+ }
129
+ };
130
+
131
+ // src/exception/payload-large.ts
132
+ var PayloadLargeException = class extends Exception {
133
+ static {
134
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "PayloadLargeException");
135
+ }
136
+ constructor(message) {
137
+ super(message, 413, "Payload Too Large");
138
+ }
139
+ };
140
+
141
+ // src/exception/timeout.ts
142
+ var TimeoutException = class extends Exception {
143
+ static {
144
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "TimeoutException");
145
+ }
146
+ constructor(message) {
147
+ super(message, 408, "Request Timeout");
148
+ }
149
+ };
150
+
151
+ // src/exception/unauthorized.ts
152
+ var UnauthorizedException = class extends Exception {
153
+ static {
154
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "UnauthorizedException");
155
+ }
156
+ constructor(message) {
157
+ super(message, 401, "Unauthorized");
158
+ }
159
+ };
160
+
161
+ // src/exception/unavailable-service.ts
162
+ var ServiceUnavailableException = class extends Exception {
163
+ static {
164
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "ServiceUnavailableException");
165
+ }
166
+ constructor(message) {
167
+ super(message, 503, "Service Unavailable");
168
+ }
169
+ };
170
+
171
+ // src/exception/framework.ts
172
+ var FrameworkException = class extends Exception {
173
+ static {
174
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "FrameworkException");
175
+ }
176
+ constructor(message) {
177
+ super(`[phecda-server] ${message}`, 500, "Framework Error");
178
+ }
179
+ };
180
+
181
+ // src/exception/timer.ts
182
+ var TimerException = class extends Exception {
183
+ static {
184
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "TimerException");
185
+ }
186
+ constructor(message) {
187
+ super(message, 0, "Timer Error");
188
+ }
189
+ };
190
+
191
+ // src/exception/worker.ts
192
+ var WorkerException = class extends Exception {
193
+ static {
194
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "WorkerException");
195
+ }
196
+ constructor(message) {
197
+ super(message, 0, "Worker Error");
198
+ }
199
+ };
200
+
201
+ // src/filter.ts
202
+ var defaultFilter = /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (e) => {
203
+ if (!(e instanceof Exception)) {
204
+ _chunkJ5CFUN4Vjs.log.call(void 0, e.message, "error");
205
+ if (_chunkJ5CFUN4Vjs.LOG_LEVEL <= 0) console.error(e.stack);
206
+ e = new UndefinedException(e.message || e);
207
+ } else {
208
+ _chunkJ5CFUN4Vjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
209
+ if (_chunkJ5CFUN4Vjs.LOG_LEVEL <= 0) console.error(e.stack);
210
+ }
211
+ return e.data;
212
+ }, "defaultFilter");
213
+
214
+ // src/context.ts
215
+ var debug = _debug2.default.call(void 0, "phecda-server(Context)");
216
+ var Context = (_class = class _Context {
217
+ static {
218
+ _chunkJ5CFUN4Vjs.__name.call(void 0, this, "Context");
219
+ }
220
+
221
+
222
+
223
+ static __initStatic() {this.filterRecord = {
224
+ default: defaultFilter
225
+ }}
226
+ static __initStatic2() {this.pipeRecord = {
227
+ default: defaultPipe
228
+ }}
229
+ static __initStatic3() {this.guardRecord = {}}
230
+ static __initStatic4() {this.addonRecord = {}}
231
+ constructor(data) {
232
+ this.data = data;
233
+ if (_chunkJ5CFUN4Vjs.IS_HMR)
234
+ data._context = this;
235
+ }
236
+ static getAop(meta, opts) {
237
+ const { globalGuards = [], globalFilter = "default", globalPipe = "default" } = opts;
238
+ const { data: { guards, filter, params } } = meta;
239
+ return {
240
+ guards: this.getGuards([
241
+ ...globalGuards,
242
+ ...guards
243
+ ]),
244
+ pipe: this.getPipe(params.map((item) => item.pipe || globalPipe)),
245
+ filter: this.getFilter(filter || globalFilter)
246
+ };
247
+ }
248
+ async run({ guards, filter, pipe }, successCb, failCb) {
249
+ const { meta, moduleMap } = this.data;
250
+ const { paramsType, data: { ctxs, tag, params, func } } = meta;
251
+ try {
252
+ let res;
253
+ const nextHandler = /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (index) => {
254
+ return async () => {
255
+ if (index === guards.length) {
256
+ const instance = moduleMap.get(tag);
257
+ if (ctxs) {
258
+ ctxs.forEach((ctx) => instance[ctx] = this.data);
259
+ }
260
+ const args = await Promise.all(params.map((item, i) => pipe[i]({
261
+ arg: resolveDep(this.data[item.type], item.key),
262
+ reflect: paramsType[item.index],
263
+ ...item
264
+ }, this.data)));
265
+ res = await instance[func](...args);
266
+ } else {
267
+ let nextPromise;
268
+ async function next() {
269
+ return nextPromise = nextHandler(index + 1)().then((ret2) => {
270
+ if (ret2 !== void 0) {
271
+ debug(`The ${index + 1}th guard rewrite the response value.`);
272
+ res = ret2;
273
+ }
274
+ return res;
275
+ });
276
+ }
277
+ _chunkJ5CFUN4Vjs.__name.call(void 0, next, "next");
278
+ const ret = await guards[index](this.data, next);
279
+ if (ret !== void 0) {
280
+ res = ret;
281
+ } else {
282
+ if (!nextPromise) await next();
283
+ else await nextPromise;
284
+ }
285
+ }
286
+ };
287
+ }, "nextHandler");
288
+ await nextHandler(0)();
289
+ return successCb(res);
290
+ } catch (e) {
291
+ const err = await filter(e, this.data);
292
+ return failCb(err);
293
+ }
294
+ }
295
+ static getPipe(pipe) {
296
+ return pipe.map((pipe2) => {
297
+ return _Context.pipeRecord[pipe2] || _Context.pipeRecord.default;
298
+ });
299
+ }
300
+ static getFilter(filter = "default") {
301
+ return _Context.filterRecord[filter] || _Context.filterRecord.default;
302
+ }
303
+ static getGuards(guards) {
304
+ const ret = [];
305
+ for (const guard of new Set(guards)) {
306
+ if (guard in _Context.guardRecord) ret.push(_Context.guardRecord[guard]);
307
+ }
308
+ return ret.sort((a, b) => b.priority - a.priority).map((item) => item.value);
309
+ }
310
+ static applyAddons(addons, router, framework) {
311
+ const ret = [];
312
+ for (const a of new Set(addons)) {
313
+ if (a in _Context.addonRecord) ret.push(_Context.addonRecord[a]);
314
+ }
315
+ ret.sort((a, b) => b.priority - a.priority).forEach((item) => item.value(router, framework));
316
+ }
317
+ }, _class.__initStatic(), _class.__initStatic2(), _class.__initStatic3(), _class.__initStatic4(), _class);
318
+ function addPipe(key, pipe) {
319
+ if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) _chunkJ5CFUN4Vjs.log.call(void 0, `overwrite Pipe "${String(key)}"`, "warn");
320
+ Context.pipeRecord[key] = pipe;
321
+ }
322
+ _chunkJ5CFUN4Vjs.__name.call(void 0, addPipe, "addPipe");
323
+ function addFilter(key, filter) {
324
+ if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) _chunkJ5CFUN4Vjs.log.call(void 0, `overwrite Filter "${String(key)}"`, "warn");
325
+ Context.filterRecord[key] = filter;
326
+ }
327
+ _chunkJ5CFUN4Vjs.__name.call(void 0, addFilter, "addFilter");
328
+ function addGuard(key, guard, priority = 0) {
329
+ if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) _chunkJ5CFUN4Vjs.log.call(void 0, `overwrite Guard "${String(key)}"`, "warn");
330
+ Context.guardRecord[key] = {
331
+ value: guard,
332
+ priority
333
+ };
334
+ }
335
+ _chunkJ5CFUN4Vjs.__name.call(void 0, addGuard, "addGuard");
336
+ function addAddon(key, addon, priority = 0) {
337
+ if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) _chunkJ5CFUN4Vjs.log.call(void 0, `overwrite Addon "${String(key)}"`, "warn");
338
+ Context.addonRecord[key] = {
339
+ value: addon,
340
+ priority
341
+ };
342
+ }
343
+ _chunkJ5CFUN4Vjs.__name.call(void 0, addAddon, "addAddon");
344
+
345
+ // src/hmr.ts
346
+ function HMR(cb) {
347
+ if (_chunkJ5CFUN4Vjs.IS_HMR) _optionalChain([globalThis, 'access', _ => _.__PS_HMR__, 'optionalAccess', _2 => _2.push, 'call', _3 => _3(cb)]);
348
+ }
349
+ _chunkJ5CFUN4Vjs.__name.call(void 0, HMR, "HMR");
350
+
351
+ // src/http/helper.ts
352
+ function resolveDep(ret, key) {
353
+ if (key) return _optionalChain([ret, 'optionalAccess', _4 => _4[key]]);
354
+ return ret;
355
+ }
356
+ _chunkJ5CFUN4Vjs.__name.call(void 0, resolveDep, "resolveDep");
357
+ function argToReq(params, args, headers) {
358
+ const req = {
359
+ body: {},
360
+ query: {},
361
+ params: {},
362
+ headers
363
+ };
364
+ params.forEach((param) => {
365
+ if (param.key) req[param.type][param.key] = args[param.index];
366
+ else req[param.type] = args[param.index];
367
+ });
368
+ return req;
369
+ }
370
+ _chunkJ5CFUN4Vjs.__name.call(void 0, argToReq, "argToReq");
371
+
372
+ // src/rpc/helper.ts
373
+ var _os = require('os');
374
+ function genClientQueue(key) {
375
+ return `PS-${key ? `${key}-` : ""}${_os.hostname.call(void 0, )}-${process.pid}`;
376
+ }
377
+ _chunkJ5CFUN4Vjs.__name.call(void 0, genClientQueue, "genClientQueue");
378
+
379
+ // src/decorators/helper.ts
380
+ function shallowClone(obj) {
381
+ return {
382
+ ...obj
383
+ };
384
+ }
385
+ _chunkJ5CFUN4Vjs.__name.call(void 0, shallowClone, "shallowClone");
386
+ function mergeObject(...args) {
387
+ return Object.assign({}, ...args);
388
+ }
389
+ _chunkJ5CFUN4Vjs.__name.call(void 0, mergeObject, "mergeObject");
390
+
391
+ // src/helper.ts
392
+ function createControllerMetaMap(meta, filter) {
393
+ const metaMap = /* @__PURE__ */ new Map();
394
+ function handleMeta() {
395
+ metaMap.clear();
396
+ for (const item of meta) {
397
+ const { tag, func } = item.data;
398
+ if (!filter(item)) continue;
399
+ if (metaMap.has(tag)) metaMap.get(tag)[func] = item;
400
+ else metaMap.set(tag, {
401
+ [func]: item
402
+ });
403
+ }
404
+ }
405
+ _chunkJ5CFUN4Vjs.__name.call(void 0, handleMeta, "handleMeta");
406
+ handleMeta();
407
+ HMR(handleMeta);
408
+ return metaMap;
409
+ }
410
+ _chunkJ5CFUN4Vjs.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
411
+ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
412
+ const addonSet = /* @__PURE__ */ new Set();
413
+ const guardSet = /* @__PURE__ */ new Set();
414
+ const pipeSet = /* @__PURE__ */ new Set();
415
+ const filterSet = /* @__PURE__ */ new Set();
416
+ const warningSet = /* @__PURE__ */ new Set();
417
+ function handleMeta() {
418
+ addonSet.clear();
419
+ guardSet.clear();
420
+ pipeSet.clear();
421
+ filterSet.clear();
422
+ warningSet.clear();
423
+ _optionalChain([addons, 'optionalAccess', _5 => _5.forEach, 'call', _6 => _6((item) => {
424
+ addonSet.add(item);
425
+ })]);
426
+ _optionalChain([guards, 'optionalAccess', _7 => _7.forEach, 'call', _8 => _8((item) => {
427
+ guardSet.add(item);
428
+ })]);
429
+ meta.forEach(({ data }) => {
430
+ if (data.controller !== controller) {
431
+ if (data[controller]) warningSet.add(`Module "${data.tag === data.name ? data.name : `${data.name}(${data.tag})`}" should use ${controller} controller to decorate class or remove ${controller} decorator on method "${data.func}"`);
432
+ return;
433
+ }
434
+ if (data.filter) filterSet.add(data.filter);
435
+ data.guards.forEach((i) => guardSet.add(i));
436
+ data.addons.forEach((i) => addonSet.add(i));
437
+ data.params.forEach((i) => {
438
+ if (i.pipe) pipeSet.add(i.pipe);
439
+ });
440
+ });
441
+ const missAddons = [
442
+ ...addonSet
443
+ ].filter((i) => !Context.addonRecord[i]);
444
+ const missGuards = [
445
+ ...guardSet
446
+ ].filter((i) => !Context.guardRecord[i]);
447
+ const missPipes = [
448
+ ...pipeSet
449
+ ].filter((i) => !Context.pipeRecord[i]);
450
+ const missFilters = [
451
+ ...filterSet
452
+ ].filter((i) => !Context.filterRecord[i]);
453
+ if (missAddons.length) _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
454
+ if (missGuards.length) _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
455
+ if (missPipes.length) _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
456
+ if (missFilters.length) _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
457
+ warningSet.forEach((warn) => _chunkJ5CFUN4Vjs.log.call(void 0, warn, "warn"));
458
+ }
459
+ _chunkJ5CFUN4Vjs.__name.call(void 0, handleMeta, "handleMeta");
460
+ handleMeta();
461
+ HMR(handleMeta);
462
+ return {
463
+ addonSet,
464
+ guardSet,
465
+ pipeSet,
466
+ filterSet
467
+ };
468
+ }
469
+ _chunkJ5CFUN4Vjs.__name.call(void 0, detectAopDep, "detectAopDep");
470
+
471
+
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+ 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;
@@ -50,6 +50,12 @@ function log(msg, level = "log") {
50
50
  console[level](`${pc.magenta("[phecda-server]")} ${pc.gray(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`)} ${pc[color](msg)} ${pc.gray(interval)}`);
51
51
  }
52
52
  __name(log, "log");
53
+ function runMiddleware(ctx, middleware) {
54
+ return new Promise((resolve) => {
55
+ middleware(ctx.getRequest(), ctx.getResponse(), resolve);
56
+ });
57
+ }
58
+ __name(runMiddleware, "runMiddleware");
53
59
 
54
60
  export {
55
61
  __name,
@@ -62,5 +68,6 @@ export {
62
68
  setLogger,
63
69
  getLogger,
64
70
  log,
71
+ runMiddleware,
65
72
  Mixin
66
73
  };
@@ -1,5 +1,5 @@
1
1
  import { Construct } from 'phecda-core';
2
- import { b as MetaData, M as Meta, E as Emitter } from './meta-KtfiBIde.mjs';
2
+ import { b as MetaData, M as Meta, E as Emitter } from './meta-BXKLFTgG.mjs';
3
3
 
4
4
  declare abstract class Generator {
5
5
  private _path;
@@ -1,5 +1,5 @@
1
1
  import { Construct } from 'phecda-core';
2
- import { b as MetaData, M as Meta, E as Emitter } from './meta-KtfiBIde.js';
2
+ import { b as MetaData, M as Meta, E as Emitter } from './meta-BXKLFTgG.js';
3
3
 
4
4
  declare abstract class Generator {
5
5
  private _path;
package/dist/helper.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-KtfiBIde.mjs';
1
+ import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-BXKLFTgG.mjs';
2
2
  import 'phecda-core';
3
3
 
4
4
  declare function HMR(cb: (...args: any) => any): void;
@@ -12,14 +12,12 @@ declare function shallowClone(obj: any): any;
12
12
  declare function mergeObject(...args: any[]): any;
13
13
 
14
14
  declare function createControllerMetaMap(meta: Meta[], filter: (meta: Meta) => boolean | void): Map<string, Record<string, ControllerMeta>>;
15
- declare function detectAopDep(meta: Meta[], { guards, interceptors, plugins }?: {
15
+ declare function detectAopDep(meta: Meta[], { guards, addons }?: {
16
16
  guards?: string[];
17
- interceptors?: string[];
18
- plugins?: string[];
17
+ addons?: string[];
19
18
  }, controller?: string): {
20
- pluginSet: Set<string>;
19
+ addonSet: Set<string>;
21
20
  guardSet: Set<string>;
22
- interceptorSet: Set<string>;
23
21
  pipeSet: Set<string>;
24
22
  filterSet: Set<string>;
25
23
  };
package/dist/helper.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-KtfiBIde.js';
1
+ import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-BXKLFTgG.js';
2
2
  import 'phecda-core';
3
3
 
4
4
  declare function HMR(cb: (...args: any) => any): void;
@@ -12,14 +12,12 @@ declare function shallowClone(obj: any): any;
12
12
  declare function mergeObject(...args: any[]): any;
13
13
 
14
14
  declare function createControllerMetaMap(meta: Meta[], filter: (meta: Meta) => boolean | void): Map<string, Record<string, ControllerMeta>>;
15
- declare function detectAopDep(meta: Meta[], { guards, interceptors, plugins }?: {
15
+ declare function detectAopDep(meta: Meta[], { guards, addons }?: {
16
16
  guards?: string[];
17
- interceptors?: string[];
18
- plugins?: string[];
17
+ addons?: string[];
19
18
  }, controller?: string): {
20
- pluginSet: Set<string>;
19
+ addonSet: Set<string>;
21
20
  guardSet: Set<string>;
22
- interceptorSet: Set<string>;
23
21
  pipeSet: Set<string>;
24
22
  filterSet: Set<string>;
25
23
  };
package/dist/helper.js CHANGED
@@ -7,8 +7,8 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkDVTBLV6Ijs = require('./chunk-DVTBLV6I.js');
11
- require('./chunk-TVT62GIX.js');
10
+ var _chunkSW5IKE5Hjs = require('./chunk-SW5IKE5H.js');
11
+ require('./chunk-J5CFUN4V.js');
12
12
 
13
13
 
14
14
 
@@ -18,4 +18,4 @@ require('./chunk-TVT62GIX.js');
18
18
 
19
19
 
20
20
 
21
- exports.HMR = _chunkDVTBLV6Ijs.HMR; exports.argToReq = _chunkDVTBLV6Ijs.argToReq; exports.createControllerMetaMap = _chunkDVTBLV6Ijs.createControllerMetaMap; exports.detectAopDep = _chunkDVTBLV6Ijs.detectAopDep; exports.genClientQueue = _chunkDVTBLV6Ijs.genClientQueue; exports.mergeObject = _chunkDVTBLV6Ijs.mergeObject; exports.resolveDep = _chunkDVTBLV6Ijs.resolveDep; exports.shallowClone = _chunkDVTBLV6Ijs.shallowClone;
21
+ exports.HMR = _chunkSW5IKE5Hjs.HMR; exports.argToReq = _chunkSW5IKE5Hjs.argToReq; exports.createControllerMetaMap = _chunkSW5IKE5Hjs.createControllerMetaMap; exports.detectAopDep = _chunkSW5IKE5Hjs.detectAopDep; exports.genClientQueue = _chunkSW5IKE5Hjs.genClientQueue; exports.mergeObject = _chunkSW5IKE5Hjs.mergeObject; exports.resolveDep = _chunkSW5IKE5Hjs.resolveDep; exports.shallowClone = _chunkSW5IKE5Hjs.shallowClone;
package/dist/helper.mjs CHANGED
@@ -7,8 +7,8 @@ import {
7
7
  mergeObject,
8
8
  resolveDep,
9
9
  shallowClone
10
- } from "./chunk-2CFYUXPM.mjs";
11
- import "./chunk-G7TD2VB7.mjs";
10
+ } from "./chunk-P75VKZJY.mjs";
11
+ import "./chunk-WHJ5FALK.mjs";
12
12
  export {
13
13
  HMR,
14
14
  argToReq,
@@ -1,9 +1,9 @@
1
1
  import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
2
2
  import { BaseMacro } from 'elysia/dist/types';
3
- import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
4
- import { F as Factory } from '../../core-P1CsH6jz.mjs';
3
+ import { H as HttpContext, a as HttpOptions } from '../../types-h40T3cRG.mjs';
4
+ import { F as Factory } from '../../core-BIcUwV18.mjs';
5
5
  import 'node:http';
6
- import '../../meta-KtfiBIde.mjs';
6
+ import '../../meta-BXKLFTgG.mjs';
7
7
  import 'phecda-core';
8
8
 
9
9
  interface ElysiaCtx extends HttpContext {
@@ -11,8 +11,8 @@ interface ElysiaCtx extends HttpContext {
11
11
  app: Elysia$1;
12
12
  context: Context;
13
13
  }
14
- type Plugin = (app: Elysia$1<any>) => void;
14
+ type Addon = (app: Elysia$1<any>) => void;
15
15
  declare function bind(app: Elysia$1<any>, data: Awaited<ReturnType<typeof Factory>>, opts?: HttpOptions): void;
16
16
  declare function Elysia(opts: LocalHook<InputSchema, RouteSchema, SingletonBase, Record<string, Error>, BaseMacro>): any;
17
17
 
18
- export { Elysia, type ElysiaCtx, type Plugin, bind };
18
+ export { type Addon, Elysia, type ElysiaCtx, bind };
@@ -1,9 +1,9 @@
1
1
  import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
2
2
  import { BaseMacro } from 'elysia/dist/types';
3
- import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
4
- import { F as Factory } from '../../core-BlN0Spy9.js';
3
+ import { H as HttpContext, a as HttpOptions } from '../../types-VFzEM7LL.js';
4
+ import { F as Factory } from '../../core-CYwEPfN4.js';
5
5
  import 'node:http';
6
- import '../../meta-KtfiBIde.js';
6
+ import '../../meta-BXKLFTgG.js';
7
7
  import 'phecda-core';
8
8
 
9
9
  interface ElysiaCtx extends HttpContext {
@@ -11,8 +11,8 @@ interface ElysiaCtx extends HttpContext {
11
11
  app: Elysia$1;
12
12
  context: Context;
13
13
  }
14
- type Plugin = (app: Elysia$1<any>) => void;
14
+ type Addon = (app: Elysia$1<any>) => void;
15
15
  declare function bind(app: Elysia$1<any>, data: Awaited<ReturnType<typeof Factory>>, opts?: HttpOptions): void;
16
16
  declare function Elysia(opts: LocalHook<InputSchema, RouteSchema, SingletonBase, Record<string, Error>, BaseMacro>): any;
17
17
 
18
- export { Elysia, type ElysiaCtx, type Plugin, bind };
18
+ export { type Addon, Elysia, type ElysiaCtx, bind };