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
package/dist/index.mjs CHANGED
@@ -1,4 +1,14 @@
1
1
  import {
2
+ Factory,
3
+ Meta,
4
+ ServerPhecda,
5
+ defaultServerInject,
6
+ emitter,
7
+ phecdaNamespace,
8
+ useS
9
+ } from "./chunk-5622RBNB.mjs";
10
+ import {
11
+ Addon,
2
12
  Arg,
3
13
  BaseParam,
4
14
  Body,
@@ -11,11 +21,9 @@ import {
11
21
  Guard,
12
22
  Head,
13
23
  Header,
14
- Interceptor,
15
24
  Param,
16
25
  Patch,
17
26
  Pipe,
18
- Plugin,
19
27
  Post,
20
28
  Put,
21
29
  Query,
@@ -23,16 +31,7 @@ import {
23
31
  Route,
24
32
  Rpc,
25
33
  Search
26
- } from "./chunk-J7B24YSE.mjs";
27
- import {
28
- Factory,
29
- Meta,
30
- ServerPhecda,
31
- defaultServerInject,
32
- emitter,
33
- phecdaNamespace,
34
- useS
35
- } from "./chunk-3H3T54IC.mjs";
34
+ } from "./chunk-HMVLXNV3.mjs";
36
35
  import {
37
36
  BadGatewayException,
38
37
  BadRequestException,
@@ -52,13 +51,12 @@ import {
52
51
  UnsupportedMediaTypeException,
53
52
  ValidateException,
54
53
  WorkerException,
54
+ addAddon,
55
55
  addFilter,
56
56
  addGuard,
57
- addInterceptor,
58
57
  addPipe,
59
- addPlugin,
60
58
  defaultPipe
61
- } from "./chunk-2CFYUXPM.mjs";
59
+ } from "./chunk-P75VKZJY.mjs";
62
60
  import {
63
61
  ERROR_SYMBOL,
64
62
  IS_HMR,
@@ -70,8 +68,9 @@ import {
70
68
  __name,
71
69
  getLogger,
72
70
  log,
71
+ runMiddleware,
73
72
  setLogger
74
- } from "./chunk-G7TD2VB7.mjs";
73
+ } from "./chunk-WHJ5FALK.mjs";
75
74
 
76
75
  // src/types.ts
77
76
  var ResponseSymbol = Symbol("response");
@@ -146,35 +145,19 @@ var PGuard = class extends ServerBase {
146
145
  __name(this, "PGuard");
147
146
  }
148
147
  key;
148
+ priority = 0;
149
149
  constructor(tag) {
150
150
  super();
151
151
  this.key = tag || getTag2(this);
152
- addGuard(this.key, this.use.bind(this));
152
+ addGuard(this.key, this.use.bind(this), this.priority);
153
153
  this.onUnmount(() => {
154
154
  delete Context.guardRecord[this.key];
155
155
  });
156
156
  }
157
157
  };
158
158
 
159
- // src/modules/interceptor.ts
160
- import { getTag as getTag3 } from "phecda-core";
161
- var PInterceptor = class extends ServerBase {
162
- static {
163
- __name(this, "PInterceptor");
164
- }
165
- key;
166
- constructor(tag) {
167
- super();
168
- this.key = tag || getTag3(this);
169
- this.onUnmount(() => {
170
- delete Context.interceptorRecord[this.key];
171
- });
172
- addInterceptor(this.key, this.use.bind(this));
173
- }
174
- };
175
-
176
159
  // src/modules/pipe.ts
177
- import { getTag as getTag4 } from "phecda-core";
160
+ import { getTag as getTag3 } from "phecda-core";
178
161
  var PPipe = class extends ServerBase {
179
162
  static {
180
163
  __name(this, "PPipe");
@@ -182,7 +165,7 @@ var PPipe = class extends ServerBase {
182
165
  key;
183
166
  constructor(tag) {
184
167
  super();
185
- this.key = tag || getTag4(this);
168
+ this.key = tag || getTag3(this);
186
169
  addPipe(this.key, this.use.bind(this));
187
170
  this.onUnmount(() => {
188
171
  delete Context.pipeRecord[this.key];
@@ -190,53 +173,50 @@ var PPipe = class extends ServerBase {
190
173
  }
191
174
  };
192
175
 
193
- // src/modules/plugin.ts
194
- import { getTag as getTag5 } from "phecda-core";
195
- var PPlugin = class extends ServerBase {
176
+ // src/modules/addon.ts
177
+ import { getTag as getTag4 } from "phecda-core";
178
+ var PAddon = class extends ServerBase {
196
179
  static {
197
- __name(this, "PPlugin");
180
+ __name(this, "PAddon");
198
181
  }
199
182
  key;
183
+ priority = 0;
200
184
  constructor(tag) {
201
185
  super();
202
- this.key = tag || getTag5(this);
203
- addPlugin(this.key, this.use.bind(this));
186
+ this.key = tag || getTag4(this);
187
+ addAddon(this.key, this.use.bind(this), this.priority);
204
188
  this.onUnmount(() => {
205
- delete Context.pluginRecord[this.key];
189
+ delete Context.addonRecord[this.key];
206
190
  });
207
191
  }
208
192
  };
209
193
 
210
194
  // src/modules/extension.ts
211
- import { getTag as getTag6 } from "phecda-core";
195
+ import { getTag as getTag5 } from "phecda-core";
212
196
  var PExtension = class extends ServerBase {
213
197
  static {
214
198
  __name(this, "PExtension");
215
199
  }
216
200
  key;
201
+ guardPriority;
202
+ addonPriority;
217
203
  constructor(tag) {
218
204
  super();
219
- const key = this.key = tag || getTag6(this);
205
+ const key = this.key = tag || getTag5(this);
220
206
  if (this.pipe) {
221
207
  addPipe(key, this.pipe.bind(this));
222
208
  this.onUnmount(() => {
223
209
  delete Context.pipeRecord[key];
224
210
  });
225
211
  }
226
- if (this.plugin) {
227
- addPlugin(key, this.plugin.bind(this));
228
- this.onUnmount(() => {
229
- delete Context.pluginRecord[key];
230
- });
231
- }
232
- if (this.intercept) {
233
- addInterceptor(key, this.intercept.bind(this));
212
+ if (this.addon) {
213
+ addAddon(key, this.addon.bind(this), this.addonPriority);
234
214
  this.onUnmount(() => {
235
- delete Context.interceptorRecord[key];
215
+ delete Context.addonRecord[key];
236
216
  });
237
217
  }
238
218
  if (this.guard) {
239
- addGuard(key, this.guard.bind(this));
219
+ addGuard(key, this.guard.bind(this), this.guardPriority);
240
220
  this.onUnmount(() => {
241
221
  delete Context.guardRecord[key];
242
222
  });
@@ -348,6 +328,7 @@ return ret
348
328
  // src/index.ts
349
329
  export * from "phecda-core";
350
330
  export {
331
+ Addon,
351
332
  Arg,
352
333
  BadGatewayException,
353
334
  BadRequestException,
@@ -376,24 +357,21 @@ export {
376
357
  IS_HMR,
377
358
  IS_ONLY_GENERATE,
378
359
  IS_STRICT,
379
- Interceptor,
380
360
  InvalidInputException,
381
361
  LOG_LEVEL,
382
362
  Meta,
383
363
  Mixin,
384
364
  NotFoundException,
365
+ PAddon,
385
366
  PExtension,
386
367
  PFilter,
387
368
  PGuard,
388
- PInterceptor,
389
369
  PPipe,
390
- PPlugin,
391
370
  PS_EXIT_CODE,
392
371
  Param,
393
372
  Patch,
394
373
  PayloadLargeException,
395
374
  Pipe,
396
- Plugin,
397
375
  Post,
398
376
  Put,
399
377
  Query,
@@ -413,17 +391,17 @@ export {
413
391
  UnsupportedMediaTypeException,
414
392
  ValidateException,
415
393
  WorkerException,
394
+ addAddon,
416
395
  addFilter,
417
396
  addGuard,
418
- addInterceptor,
419
397
  addPipe,
420
- addPlugin,
421
398
  defaultPipe,
422
399
  defaultServerInject,
423
400
  emitter,
424
401
  getLogger,
425
402
  log,
426
403
  phecdaNamespace,
404
+ runMiddleware,
427
405
  setLogger,
428
406
  useS
429
407
  };
@@ -41,9 +41,9 @@ interface BaseContext {
41
41
  }
42
42
  interface DefaultOptions {
43
43
  globalGuards?: string[];
44
- globalInterceptors?: string[];
45
44
  globalFilter?: string;
46
45
  globalPipe?: string;
46
+ globalAddons?: string[];
47
47
  }
48
48
  interface BaseError {
49
49
  [ERROR_SYMBOL]: true;
@@ -91,8 +91,7 @@ interface ControllerMetaData extends ServiceMetaData {
91
91
  guards: string[];
92
92
  pipe?: string;
93
93
  filter?: string;
94
- interceptors: string[];
95
- plugins: string[];
94
+ addons: string[];
96
95
  }
97
96
  type MetaData = ControllerMetaData | ServiceMetaData;
98
97
  declare class Meta {
@@ -41,9 +41,9 @@ interface BaseContext {
41
41
  }
42
42
  interface DefaultOptions {
43
43
  globalGuards?: string[];
44
- globalInterceptors?: string[];
45
44
  globalFilter?: string;
46
45
  globalPipe?: string;
46
+ globalAddons?: string[];
47
47
  }
48
48
  interface BaseError {
49
49
  [ERROR_SYMBOL]: true;
@@ -91,8 +91,7 @@ interface ControllerMetaData extends ServiceMetaData {
91
91
  guards: string[];
92
92
  pipe?: string;
93
93
  filter?: string;
94
- interceptors: string[];
95
- plugins: string[];
94
+ addons: string[];
96
95
  }
97
96
  type MetaData = ControllerMetaData | ServiceMetaData;
98
97
  declare class Meta {
@@ -1,17 +1,17 @@
1
1
  import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
2
- import { F as Factory } from '../../core-P1CsH6jz.mjs';
3
- import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-t9D1fU6G.mjs';
4
- import { T as ToClientMap } from '../../meta-KtfiBIde.mjs';
2
+ import { F as Factory } from '../../core-BIcUwV18.mjs';
3
+ import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-BtbL49Zs.mjs';
4
+ import { T as ToClientMap } from '../../meta-BXKLFTgG.mjs';
5
5
  import 'phecda-core';
6
6
 
7
7
  interface BullmqCtx extends RpcContext {
8
8
  type: 'bullmq';
9
9
  }
10
- interface BullmqOptions {
10
+ type BullmqOptions = Omit<RpcServerOptions, 'globalAddons'> & {
11
11
  workerOpts?: WorkerOptions;
12
12
  queueOpts?: QueueOptions;
13
- }
14
- declare function create({ moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: BullmqOptions & RpcServerOptions): Promise<{
13
+ };
14
+ declare function create({ moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: BullmqOptions): Promise<{
15
15
  workerMap: Record<string, Worker<any, any, string>>;
16
16
  queueMap: Record<string, Queue<any, any, string>>;
17
17
  }>;
@@ -1,17 +1,17 @@
1
1
  import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
2
- import { F as Factory } from '../../core-BlN0Spy9.js';
3
- import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-JVT0mgLD.js';
4
- import { T as ToClientMap } from '../../meta-KtfiBIde.js';
2
+ import { F as Factory } from '../../core-CYwEPfN4.js';
3
+ import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-m3IEDKjP.js';
4
+ import { T as ToClientMap } from '../../meta-BXKLFTgG.js';
5
5
  import 'phecda-core';
6
6
 
7
7
  interface BullmqCtx extends RpcContext {
8
8
  type: 'bullmq';
9
9
  }
10
- interface BullmqOptions {
10
+ type BullmqOptions = Omit<RpcServerOptions, 'globalAddons'> & {
11
11
  workerOpts?: WorkerOptions;
12
12
  queueOpts?: QueueOptions;
13
- }
14
- declare function create({ moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: BullmqOptions & RpcServerOptions): Promise<{
13
+ };
14
+ declare function create({ moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: BullmqOptions): Promise<{
15
15
  workerMap: Record<string, Worker<any, any, string>>;
16
16
  queueMap: Record<string, Queue<any, any, string>>;
17
17
  }>;
@@ -4,47 +4,47 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkDVTBLV6Ijs = require('../../chunk-DVTBLV6I.js');
7
+ var _chunkSW5IKE5Hjs = require('../../chunk-SW5IKE5H.js');
8
8
 
9
9
 
10
- var _chunkTVT62GIXjs = require('../../chunk-TVT62GIX.js');
10
+ var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
11
11
 
12
- // src/rpc/bullmq/bind.ts
12
+ // src/rpc/bullmq/create.ts
13
13
  var _bullmq = require('bullmq');
14
14
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
15
15
  var debug = _debug2.default.call(void 0, "phecda-server/bullmq");
16
16
  async function create({ moduleMap, meta }, opts = {}) {
17
- const { globalGuards, globalInterceptors, globalFilter, globalPipe, workerOpts, queueOpts } = opts;
17
+ const { globalGuards, globalFilter, globalPipe, workerOpts, queueOpts, defaultQueue } = opts;
18
18
  const workerMap = {};
19
19
  const queueMap = {};
20
20
  const existQueue = /* @__PURE__ */ new Set();
21
- const metaMap = _chunkDVTBLV6Ijs.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
+ const metaMap = _chunkSW5IKE5Hjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
22
  const { controller, rpc, func, tag } = meta2.data;
23
23
  if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
24
24
  debug(`register method "${func}" in module "${tag}"`);
25
25
  return true;
26
26
  }
27
27
  });
28
- _chunkDVTBLV6Ijs.detectAopDep.call(void 0, meta, {
29
- guards: globalGuards,
30
- interceptors: globalInterceptors
28
+ _chunkSW5IKE5Hjs.detectAopDep.call(void 0, meta, {
29
+ guards: globalGuards
31
30
  }, "rpc");
32
31
  async function subscribeQueues() {
33
32
  existQueue.clear();
34
33
  for (const [tag, record] of metaMap) {
35
34
  for (const func in record) {
36
35
  const meta2 = metaMap.get(tag)[func];
37
- const { data: { rpc } } = meta2;
36
+ const { data: { rpc, addons } } = meta2;
38
37
  if (rpc) {
39
- const queue = rpc.queue || tag;
38
+ const queue = rpc.queue || defaultQueue || tag;
40
39
  if (existQueue.has(queue)) continue;
41
40
  existQueue.add(queue);
42
41
  workerMap[queue] = new (0, _bullmq.Worker)(queue, handleRequest, workerOpts);
42
+ _chunkSW5IKE5Hjs.Context.applyAddons(addons, workerMap[queue], "bullmq");
43
43
  }
44
44
  }
45
45
  }
46
46
  }
47
- _chunkTVT62GIXjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
47
+ _chunkJ5CFUN4Vjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
48
48
  async function handleRequest(job) {
49
49
  const { data } = job;
50
50
  const { tag, func, args, id, queue: clientQueue, _ps } = data;
@@ -53,7 +53,12 @@ async function create({ moduleMap, meta }, opts = {}) {
53
53
  const meta2 = metaMap.get(tag)[func];
54
54
  const { data: { rpc: { isEvent } = {} } } = meta2;
55
55
  if (!isEvent && !(clientQueue in queueMap)) queueMap[clientQueue] = new (0, _bullmq.Queue)(clientQueue, queueOpts);
56
- const context = new (0, _chunkDVTBLV6Ijs.Context)({
56
+ const aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
57
+ globalFilter,
58
+ globalGuards,
59
+ globalPipe
60
+ });
61
+ const context = new (0, _chunkSW5IKE5Hjs.Context)({
57
62
  type: "bullmq",
58
63
  moduleMap,
59
64
  meta: meta2,
@@ -65,12 +70,7 @@ async function create({ moduleMap, meta }, opts = {}) {
65
70
  queue: job.queueName,
66
71
  isEvent
67
72
  });
68
- await context.run({
69
- globalGuards,
70
- globalInterceptors,
71
- globalFilter,
72
- globalPipe
73
- }, (returnData) => {
73
+ await context.run(aop, (returnData) => {
74
74
  if (!isEvent) queueMap[clientQueue].add(`${tag}-${func}`, {
75
75
  data: returnData,
76
76
  id
@@ -85,9 +85,9 @@ async function create({ moduleMap, meta }, opts = {}) {
85
85
  }
86
86
  });
87
87
  }
88
- _chunkTVT62GIXjs.__name.call(void 0, handleRequest, "handleRequest");
88
+ _chunkJ5CFUN4Vjs.__name.call(void 0, handleRequest, "handleRequest");
89
89
  subscribeQueues();
90
- _chunkDVTBLV6Ijs.HMR.call(void 0, async () => {
90
+ _chunkSW5IKE5Hjs.HMR.call(void 0, async () => {
91
91
  for (const i in workerMap) await workerMap[i].close(true);
92
92
  for (const i in queueMap) await queueMap[i].close();
93
93
  await subscribeQueues();
@@ -97,7 +97,7 @@ async function create({ moduleMap, meta }, opts = {}) {
97
97
  queueMap
98
98
  };
99
99
  }
100
- _chunkTVT62GIXjs.__name.call(void 0, create, "create");
100
+ _chunkJ5CFUN4Vjs.__name.call(void 0, create, "create");
101
101
 
102
102
  // src/rpc/bullmq/client.ts
103
103
  var _events = require('events');
@@ -108,7 +108,7 @@ async function createClient(controllers, opts = {}) {
108
108
  const { max, workerOpts, queueOpts, timeout, key } = opts;
109
109
  const ret = {};
110
110
  const emitter = new (0, _events.EventEmitter)();
111
- const clientQueue = _chunkDVTBLV6Ijs.genClientQueue.call(void 0, key);
111
+ const clientQueue = _chunkSW5IKE5Hjs.genClientQueue.call(void 0, key);
112
112
  const queueMap = {};
113
113
  new (0, _bullmq.Worker)(clientQueue, async (job) => {
114
114
  const { data, id, error } = job.data;
@@ -153,7 +153,7 @@ async function createClient(controllers, opts = {}) {
153
153
  if (error) reject(data);
154
154
  else resolve(data);
155
155
  }
156
- _chunkTVT62GIXjs.__name.call(void 0, listener, "listener");
156
+ _chunkJ5CFUN4Vjs.__name.call(void 0, listener, "listener");
157
157
  eventCount++;
158
158
  emitter.once(id, listener);
159
159
  });
@@ -163,7 +163,7 @@ async function createClient(controllers, opts = {}) {
163
163
  }
164
164
  return ret;
165
165
  }
166
- _chunkTVT62GIXjs.__name.call(void 0, createClient, "createClient");
166
+ _chunkJ5CFUN4Vjs.__name.call(void 0, createClient, "createClient");
167
167
 
168
168
 
169
169
 
@@ -4,17 +4,17 @@ import {
4
4
  createControllerMetaMap,
5
5
  detectAopDep,
6
6
  genClientQueue
7
- } from "../../chunk-2CFYUXPM.mjs";
7
+ } from "../../chunk-P75VKZJY.mjs";
8
8
  import {
9
9
  __name
10
- } from "../../chunk-G7TD2VB7.mjs";
10
+ } from "../../chunk-WHJ5FALK.mjs";
11
11
 
12
- // src/rpc/bullmq/bind.ts
12
+ // src/rpc/bullmq/create.ts
13
13
  import { Queue, Worker } from "bullmq";
14
14
  import Debug from "debug";
15
15
  var debug = Debug("phecda-server/bullmq");
16
16
  async function create({ moduleMap, meta }, opts = {}) {
17
- const { globalGuards, globalInterceptors, globalFilter, globalPipe, workerOpts, queueOpts } = opts;
17
+ const { globalGuards, globalFilter, globalPipe, workerOpts, queueOpts, defaultQueue } = opts;
18
18
  const workerMap = {};
19
19
  const queueMap = {};
20
20
  const existQueue = /* @__PURE__ */ new Set();
@@ -26,20 +26,20 @@ async function create({ moduleMap, meta }, opts = {}) {
26
26
  }
27
27
  });
28
28
  detectAopDep(meta, {
29
- guards: globalGuards,
30
- interceptors: globalInterceptors
29
+ guards: globalGuards
31
30
  }, "rpc");
32
31
  async function subscribeQueues() {
33
32
  existQueue.clear();
34
33
  for (const [tag, record] of metaMap) {
35
34
  for (const func in record) {
36
35
  const meta2 = metaMap.get(tag)[func];
37
- const { data: { rpc } } = meta2;
36
+ const { data: { rpc, addons } } = meta2;
38
37
  if (rpc) {
39
- const queue = rpc.queue || tag;
38
+ const queue = rpc.queue || defaultQueue || tag;
40
39
  if (existQueue.has(queue)) continue;
41
40
  existQueue.add(queue);
42
41
  workerMap[queue] = new Worker(queue, handleRequest, workerOpts);
42
+ Context.applyAddons(addons, workerMap[queue], "bullmq");
43
43
  }
44
44
  }
45
45
  }
@@ -53,6 +53,11 @@ async function create({ moduleMap, meta }, opts = {}) {
53
53
  const meta2 = metaMap.get(tag)[func];
54
54
  const { data: { rpc: { isEvent } = {} } } = meta2;
55
55
  if (!isEvent && !(clientQueue in queueMap)) queueMap[clientQueue] = new Queue(clientQueue, queueOpts);
56
+ const aop = Context.getAop(meta2, {
57
+ globalFilter,
58
+ globalGuards,
59
+ globalPipe
60
+ });
56
61
  const context = new Context({
57
62
  type: "bullmq",
58
63
  moduleMap,
@@ -65,12 +70,7 @@ async function create({ moduleMap, meta }, opts = {}) {
65
70
  queue: job.queueName,
66
71
  isEvent
67
72
  });
68
- await context.run({
69
- globalGuards,
70
- globalInterceptors,
71
- globalFilter,
72
- globalPipe
73
- }, (returnData) => {
73
+ await context.run(aop, (returnData) => {
74
74
  if (!isEvent) queueMap[clientQueue].add(`${tag}-${func}`, {
75
75
  data: returnData,
76
76
  id
@@ -1,7 +1,7 @@
1
1
  import { Consumer, Producer } from 'kafkajs';
2
- import { F as Factory } from '../../core-P1CsH6jz.mjs';
3
- import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-t9D1fU6G.mjs';
4
- import { T as ToClientMap } from '../../meta-KtfiBIde.mjs';
2
+ import { F as Factory } from '../../core-BIcUwV18.mjs';
3
+ import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-BtbL49Zs.mjs';
4
+ import { T as ToClientMap } from '../../meta-BXKLFTgG.mjs';
5
5
  import 'phecda-core';
6
6
 
7
7
  interface KafkaCtx extends RpcContext {
@@ -1,7 +1,7 @@
1
1
  import { Consumer, Producer } from 'kafkajs';
2
- import { F as Factory } from '../../core-BlN0Spy9.js';
3
- import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-JVT0mgLD.js';
4
- import { T as ToClientMap } from '../../meta-KtfiBIde.js';
2
+ import { F as Factory } from '../../core-CYwEPfN4.js';
3
+ import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-m3IEDKjP.js';
4
+ import { T as ToClientMap } from '../../meta-BXKLFTgG.js';
5
5
  import 'phecda-core';
6
6
 
7
7
  interface KafkaCtx extends RpcContext {