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.
- package/bin/cli.mjs +160 -157
- package/dist/{chunk-3H3T54IC.mjs → chunk-5622RBNB.mjs} +3 -4
- package/dist/{chunk-NL6QBQAR.js → chunk-BGXSMOLX.js} +20 -21
- package/dist/{chunk-J7B24YSE.mjs → chunk-HMVLXNV3.mjs} +5 -14
- package/dist/{chunk-TVT62GIX.js → chunk-J5CFUN4V.js} +8 -1
- package/dist/{chunk-JDV2XJYE.js → chunk-MBCHNDAY.js} +27 -36
- package/dist/{chunk-2CFYUXPM.mjs → chunk-P75VKZJY.mjs} +101 -137
- package/dist/chunk-SW5IKE5H.js +503 -0
- package/dist/{chunk-G7TD2VB7.mjs → chunk-WHJ5FALK.mjs} +7 -0
- package/dist/{core-P1CsH6jz.d.mts → core-BIcUwV18.d.mts} +1 -1
- package/dist/{core-BlN0Spy9.d.ts → core-CYwEPfN4.d.ts} +1 -1
- package/dist/helper.d.mts +4 -6
- package/dist/helper.d.ts +4 -6
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/{server → http}/elysia/index.d.mts +5 -5
- package/dist/{server → http}/elysia/index.d.ts +5 -5
- package/dist/{server → http}/elysia/index.js +80 -62
- package/dist/{server → http}/elysia/index.mjs +50 -32
- package/dist/{server → http}/express/index.d.mts +5 -5
- package/dist/{server → http}/express/index.d.ts +5 -5
- package/dist/{server → http}/express/index.js +71 -55
- package/dist/{server → http}/express/index.mjs +42 -26
- package/dist/{server → http}/fastify/index.d.mts +5 -5
- package/dist/{server → http}/fastify/index.d.ts +5 -5
- package/dist/{server → http}/fastify/index.js +72 -72
- package/dist/{server → http}/fastify/index.mjs +47 -47
- package/dist/{server → http}/h3/index.d.mts +5 -5
- package/dist/{server → http}/h3/index.d.ts +5 -5
- package/dist/http/h3/index.js +160 -0
- package/dist/{server → http}/h3/index.mjs +68 -62
- package/dist/{server → http}/hono/index.d.mts +5 -5
- package/dist/{server → http}/hono/index.d.ts +5 -5
- package/dist/{server → http}/hono/index.js +69 -54
- package/dist/{server → http}/hono/index.mjs +41 -26
- package/dist/{server → http}/hyper-express/index.d.mts +5 -5
- package/dist/{server → http}/hyper-express/index.d.ts +5 -5
- package/dist/{server → http}/hyper-express/index.js +69 -56
- package/dist/{server → http}/hyper-express/index.mjs +41 -28
- package/dist/{server → http}/koa/index.d.mts +5 -5
- package/dist/{server → http}/koa/index.d.ts +5 -5
- package/dist/{server → http}/koa/index.js +71 -55
- package/dist/{server → http}/koa/index.mjs +42 -26
- package/dist/index.d.mts +51 -40
- package/dist/index.d.ts +51 -40
- package/dist/index.js +59 -81
- package/dist/index.mjs +39 -61
- package/dist/{meta-KtfiBIde.d.ts → meta-BXKLFTgG.d.mts} +2 -3
- package/dist/{meta-KtfiBIde.d.mts → meta-BXKLFTgG.d.ts} +2 -3
- package/dist/rpc/bullmq/index.d.mts +6 -6
- package/dist/rpc/bullmq/index.d.ts +6 -6
- package/dist/rpc/bullmq/index.js +24 -24
- package/dist/rpc/bullmq/index.mjs +14 -14
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +25 -21
- package/dist/rpc/kafka/index.mjs +15 -11
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +22 -21
- package/dist/rpc/nats/index.mjs +13 -12
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +23 -22
- package/dist/rpc/rabbitmq/index.mjs +12 -11
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +24 -20
- package/dist/rpc/redis/index.mjs +15 -11
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types-JVT0mgLD.d.ts → types-BtbL49Zs.d.mts} +2 -1
- package/dist/{types-DIw7B6Up.d.ts → types-VFzEM7LL.d.ts} +5 -5
- package/dist/{types-BvD3B5Ny.d.mts → types-h40T3cRG.d.mts} +5 -5
- package/dist/{types-t9D1fU6G.d.mts → types-m3IEDKjP.d.ts} +2 -1
- package/package.json +23 -23
- package/dist/chunk-DVTBLV6I.js +0 -539
- 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-
|
|
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-
|
|
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-
|
|
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
|
|
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 ||
|
|
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/
|
|
194
|
-
import { getTag as
|
|
195
|
-
var
|
|
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, "
|
|
180
|
+
__name(this, "PAddon");
|
|
198
181
|
}
|
|
199
182
|
key;
|
|
183
|
+
priority = 0;
|
|
200
184
|
constructor(tag) {
|
|
201
185
|
super();
|
|
202
|
-
this.key = tag ||
|
|
203
|
-
|
|
186
|
+
this.key = tag || getTag4(this);
|
|
187
|
+
addAddon(this.key, this.use.bind(this), this.priority);
|
|
204
188
|
this.onUnmount(() => {
|
|
205
|
-
delete Context.
|
|
189
|
+
delete Context.addonRecord[this.key];
|
|
206
190
|
});
|
|
207
191
|
}
|
|
208
192
|
};
|
|
209
193
|
|
|
210
194
|
// src/modules/extension.ts
|
|
211
|
-
import { getTag as
|
|
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 ||
|
|
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.
|
|
227
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
3
|
-
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
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
|
-
|
|
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
|
|
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-
|
|
3
|
-
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
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
|
-
|
|
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
|
|
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
|
}>;
|
package/dist/rpc/bullmq/index.js
CHANGED
|
@@ -4,47 +4,47 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkSW5IKE5Hjs = require('../../chunk-SW5IKE5H.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
|
|
11
11
|
|
|
12
|
-
// src/rpc/bullmq/
|
|
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,
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
88
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
89
89
|
subscribeQueues();
|
|
90
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
7
|
+
} from "../../chunk-P75VKZJY.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-WHJ5FALK.mjs";
|
|
11
11
|
|
|
12
|
-
// src/rpc/bullmq/
|
|
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,
|
|
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-
|
|
3
|
-
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
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-
|
|
3
|
-
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
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 {
|