phecda-server 5.2.2 → 5.2.3
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 +1 -0
- package/dist/{chunk-VMLHTEW3.js → chunk-AWY6FTH4.js} +38 -38
- package/dist/{chunk-ZP7HNASU.js → chunk-FNJWO324.js} +1 -1
- package/dist/{chunk-BSE2DSDK.js → chunk-H6NYBVBV.js} +64 -64
- package/dist/{chunk-V3WIKOP3.mjs → chunk-IJNA24EZ.mjs} +2 -2
- package/dist/{chunk-5BVUCNMA.js → chunk-J5SL4QLN.js} +24 -21
- package/dist/{chunk-JE6BBDXW.mjs → chunk-Q4AGVGVA.mjs} +1 -1
- package/dist/{chunk-VLV3AO3H.mjs → chunk-VYDBNZJ2.mjs} +1 -1
- package/dist/{chunk-CKQW3FDK.mjs → chunk-YAVIRFUE.mjs} +7 -4
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/index.js +54 -48
- package/dist/index.mjs +20 -14
- package/dist/rpc/bullmq/index.js +12 -12
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.js +10 -10
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.js +12 -11
- package/dist/rpc/nats/index.mjs +3 -2
- package/dist/rpc/rabbitmq/index.js +13 -13
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.js +11 -11
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/server/elysia/index.js +20 -20
- package/dist/server/elysia/index.mjs +3 -3
- package/dist/server/express/index.js +18 -18
- package/dist/server/express/index.mjs +2 -2
- package/dist/server/fastify/index.js +19 -19
- package/dist/server/fastify/index.mjs +3 -3
- package/dist/server/h3/index.js +16 -16
- package/dist/server/h3/index.mjs +2 -2
- package/dist/server/hono/index.js +17 -17
- package/dist/server/hono/index.mjs +2 -2
- package/dist/server/hyper-express/index.js +17 -17
- package/dist/server/hyper-express/index.mjs +2 -2
- package/dist/server/koa/index.js +18 -18
- package/dist/server/koa/index.mjs +2 -2
- package/dist/test.d.ts +1 -1
- package/dist/test.js +8 -8
- package/dist/test.mjs +2 -2
- package/package.json +1 -1
- package/register/loader.mjs +1 -1
package/dist/rpc/bullmq/index.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
|
|
11
11
|
|
|
12
12
|
// src/rpc/bullmq/bind.ts
|
|
13
13
|
var _bullmq = require('bullmq');
|
|
@@ -18,14 +18,14 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
18
18
|
const workerMap = {};
|
|
19
19
|
const queueMap = {};
|
|
20
20
|
const existQueue = /* @__PURE__ */ new Set();
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkH6NYBVBVjs.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
|
-
|
|
28
|
+
_chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
guards: globalGuards,
|
|
30
30
|
interceptors: globalInterceptors
|
|
31
31
|
}, "rpc");
|
|
@@ -45,7 +45,7 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
_chunkFNJWO324js.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
49
49
|
async function handleRequest(job) {
|
|
50
50
|
const { data } = job;
|
|
51
51
|
const { tag, func, args, id, queue: clientQueue, _ps } = data;
|
|
@@ -56,7 +56,7 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
56
56
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
57
57
|
if (!isEvent && !(clientQueue in queueMap))
|
|
58
58
|
queueMap[clientQueue] = new (0, _bullmq.Queue)(clientQueue, queueOpts);
|
|
59
|
-
const context = new (0,
|
|
59
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)({
|
|
60
60
|
type: "bullmq",
|
|
61
61
|
moduleMap,
|
|
62
62
|
meta: meta2,
|
|
@@ -89,9 +89,9 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
_chunkFNJWO324js.__name.call(void 0, handleRequest, "handleRequest");
|
|
93
93
|
subscribeQueues();
|
|
94
|
-
|
|
94
|
+
_chunkH6NYBVBVjs.HMR.call(void 0, async () => {
|
|
95
95
|
for (const i in workerMap)
|
|
96
96
|
await workerMap[i].close(true);
|
|
97
97
|
for (const i in queueMap)
|
|
@@ -103,7 +103,7 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
103
103
|
queueMap
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
_chunkFNJWO324js.__name.call(void 0, create, "create");
|
|
107
107
|
|
|
108
108
|
// src/rpc/bullmq/client.ts
|
|
109
109
|
var _events = require('events');
|
|
@@ -114,7 +114,7 @@ async function createClient(controllers, opts = {}) {
|
|
|
114
114
|
const { max, workerOpts, queueOpts, timeout, key } = opts;
|
|
115
115
|
const ret = {};
|
|
116
116
|
const emitter = new (0, _events.EventEmitter)();
|
|
117
|
-
const clientQueue =
|
|
117
|
+
const clientQueue = _chunkH6NYBVBVjs.genClientQueue.call(void 0, key);
|
|
118
118
|
const queueMap = {};
|
|
119
119
|
new (0, _bullmq.Worker)(clientQueue, async (job) => {
|
|
120
120
|
const { data, id, error } = job.data;
|
|
@@ -166,7 +166,7 @@ async function createClient(controllers, opts = {}) {
|
|
|
166
166
|
else
|
|
167
167
|
resolve(data);
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
_chunkFNJWO324js.__name.call(void 0, listener, "listener");
|
|
170
170
|
eventCount++;
|
|
171
171
|
emitter.once(id, listener);
|
|
172
172
|
});
|
|
@@ -176,7 +176,7 @@ async function createClient(controllers, opts = {}) {
|
|
|
176
176
|
}
|
|
177
177
|
return ret;
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
_chunkFNJWO324js.__name.call(void 0, createClient, "createClient");
|
|
180
180
|
|
|
181
181
|
|
|
182
182
|
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-Q4AGVGVA.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-VYDBNZJ2.mjs";
|
|
11
11
|
|
|
12
12
|
// src/rpc/bullmq/bind.ts
|
|
13
13
|
import { Queue, Worker } from "bullmq";
|
package/dist/rpc/kafka/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
|
|
10
10
|
|
|
11
11
|
// src/rpc/kafka/bind.ts
|
|
12
12
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -14,14 +14,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/kafka");
|
|
|
14
14
|
async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
15
15
|
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
16
16
|
const existQueue = /* @__PURE__ */ new Set();
|
|
17
|
-
const metaMap =
|
|
17
|
+
const metaMap = _chunkH6NYBVBVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
18
18
|
const { controller, rpc, func, tag } = meta2.data;
|
|
19
19
|
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
|
|
20
20
|
debug(`register method "${func}" in module "${tag}"`);
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
_chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
interceptors: globalInterceptors
|
|
27
27
|
}, "rpc");
|
|
@@ -44,7 +44,7 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
_chunkFNJWO324js.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
48
48
|
await subscribeQueues();
|
|
49
49
|
await consumer.run({
|
|
50
50
|
eachMessage: async ({ message, partition, topic, heartbeat, pause }) => {
|
|
@@ -58,7 +58,7 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
58
58
|
const meta2 = metaMap.get(tag)[func];
|
|
59
59
|
const { data: { rpc } } = meta2;
|
|
60
60
|
const isEvent = rpc.isEvent;
|
|
61
|
-
const context = new (0,
|
|
61
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)({
|
|
62
62
|
type: "kafka",
|
|
63
63
|
moduleMap,
|
|
64
64
|
meta: meta2,
|
|
@@ -111,7 +111,7 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
_chunkFNJWO324js.__name.call(void 0, bind, "bind");
|
|
115
115
|
|
|
116
116
|
// src/rpc/kafka/client.ts
|
|
117
117
|
var _events = require('events');
|
|
@@ -120,7 +120,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
120
120
|
let eventCount = 1;
|
|
121
121
|
const ret = {};
|
|
122
122
|
const emitter = new (0, _events.EventEmitter)();
|
|
123
|
-
const clientQueue =
|
|
123
|
+
const clientQueue = _chunkH6NYBVBVjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
124
124
|
await consumer.subscribe({
|
|
125
125
|
topic: clientQueue,
|
|
126
126
|
fromBeginning: true
|
|
@@ -176,7 +176,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
176
176
|
else
|
|
177
177
|
resolve(data);
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
_chunkFNJWO324js.__name.call(void 0, listener, "listener");
|
|
180
180
|
eventCount++;
|
|
181
181
|
emitter.once(id, listener);
|
|
182
182
|
});
|
|
@@ -194,7 +194,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
194
194
|
});
|
|
195
195
|
return ret;
|
|
196
196
|
}
|
|
197
|
-
|
|
197
|
+
_chunkFNJWO324js.__name.call(void 0, createClient, "createClient");
|
|
198
198
|
|
|
199
199
|
|
|
200
200
|
|
package/dist/rpc/kafka/index.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
createControllerMetaMap,
|
|
4
4
|
detectAopDep,
|
|
5
5
|
genClientQueue
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-Q4AGVGVA.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-VYDBNZJ2.mjs";
|
|
10
10
|
|
|
11
11
|
// src/rpc/kafka/bind.ts
|
|
12
12
|
import Debug from "debug";
|
package/dist/rpc/nats/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
|
|
10
10
|
|
|
11
11
|
// src/rpc/nats/bind.ts
|
|
12
12
|
var _nats = require('nats');
|
|
@@ -17,14 +17,14 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
17
17
|
const sc = _nats.StringCodec.call(void 0, );
|
|
18
18
|
const subscriptionMap = {};
|
|
19
19
|
const existQueue = /* @__PURE__ */ new Set();
|
|
20
|
-
const metaMap =
|
|
20
|
+
const metaMap = _chunkH6NYBVBVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
21
21
|
const { controller, rpc, func, tag } = meta2.data;
|
|
22
22
|
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _2 => _2.queue]) !== void 0) {
|
|
23
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
_chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
guards: globalGuards,
|
|
29
29
|
interceptors: globalInterceptors
|
|
30
30
|
}, "rpc");
|
|
@@ -47,7 +47,7 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
_chunkFNJWO324js.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
51
51
|
async function handleRequest(_, msg) {
|
|
52
52
|
const data = JSON.parse(sc.decode(msg.data));
|
|
53
53
|
const { tag, func, id, _ps, args } = data;
|
|
@@ -58,7 +58,7 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
58
58
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
59
59
|
if (isEvent)
|
|
60
60
|
msg.respond("{}");
|
|
61
|
-
const context = new (0,
|
|
61
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)({
|
|
62
62
|
type: "nats",
|
|
63
63
|
moduleMap,
|
|
64
64
|
meta: meta2,
|
|
@@ -68,6 +68,7 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
68
68
|
id,
|
|
69
69
|
msg,
|
|
70
70
|
isEvent,
|
|
71
|
+
// @ts-expect-error nats ts problem
|
|
71
72
|
queue: msg._msg.subject.toString()
|
|
72
73
|
});
|
|
73
74
|
await context.run({
|
|
@@ -90,15 +91,15 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
90
91
|
})));
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
_chunkFNJWO324js.__name.call(void 0, handleRequest, "handleRequest");
|
|
94
95
|
subscribeQueues();
|
|
95
|
-
|
|
96
|
+
_chunkH6NYBVBVjs.HMR.call(void 0, async () => {
|
|
96
97
|
for (const i in subscriptionMap)
|
|
97
98
|
subscriptionMap[i].unsubscribe();
|
|
98
99
|
await subscribeQueues();
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
+
_chunkFNJWO324js.__name.call(void 0, bind, "bind");
|
|
102
103
|
|
|
103
104
|
// src/rpc/nats/client.ts
|
|
104
105
|
|
|
@@ -155,7 +156,7 @@ async function createClient(nc, controllers, opts) {
|
|
|
155
156
|
else
|
|
156
157
|
resolve(data);
|
|
157
158
|
}
|
|
158
|
-
|
|
159
|
+
_chunkFNJWO324js.__name.call(void 0, handler, "handler");
|
|
159
160
|
eventCount++;
|
|
160
161
|
});
|
|
161
162
|
};
|
|
@@ -164,7 +165,7 @@ async function createClient(nc, controllers, opts) {
|
|
|
164
165
|
}
|
|
165
166
|
return ret;
|
|
166
167
|
}
|
|
167
|
-
|
|
168
|
+
_chunkFNJWO324js.__name.call(void 0, createClient, "createClient");
|
|
168
169
|
|
|
169
170
|
|
|
170
171
|
|
package/dist/rpc/nats/index.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
HMR,
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-Q4AGVGVA.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-VYDBNZJ2.mjs";
|
|
10
10
|
|
|
11
11
|
// src/rpc/nats/bind.ts
|
|
12
12
|
import { StringCodec } from "nats";
|
|
@@ -68,6 +68,7 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
68
68
|
id,
|
|
69
69
|
msg,
|
|
70
70
|
isEvent,
|
|
71
|
+
// @ts-expect-error nats ts problem
|
|
71
72
|
queue: msg._msg.subject.toString()
|
|
72
73
|
});
|
|
73
74
|
await context.run({
|
|
@@ -4,24 +4,24 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
|
|
11
11
|
|
|
12
12
|
// src/rpc/rabbitmq/bind.ts
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
14
14
|
var debug = _debug2.default.call(void 0, "phecda-server/rabbitmq");
|
|
15
15
|
async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
16
16
|
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
17
|
-
const metaMap =
|
|
17
|
+
const metaMap = _chunkH6NYBVBVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
18
18
|
const { controller, rpc, func, tag } = meta2.data;
|
|
19
19
|
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
|
|
20
20
|
debug(`register method "${func}" in module "${tag}"`);
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
_chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
interceptors: globalInterceptors
|
|
27
27
|
}, "rpc");
|
|
@@ -45,12 +45,12 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
_chunkFNJWO324js.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
49
49
|
async function handleRequest(msg) {
|
|
50
50
|
function send(queue, data) {
|
|
51
51
|
ch.sendToQueue(queue, Buffer.from(JSON.stringify(data)));
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
_chunkFNJWO324js.__name.call(void 0, send, "send");
|
|
54
54
|
if (msg) {
|
|
55
55
|
const data = JSON.parse(msg.content.toString());
|
|
56
56
|
const { tag, func, id, queue: clientQueue, _ps, args } = data;
|
|
@@ -59,7 +59,7 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
59
59
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
60
60
|
const meta2 = metaMap.get(tag)[func];
|
|
61
61
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
62
|
-
const context = new (0,
|
|
62
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)({
|
|
63
63
|
type: "rabbitmq",
|
|
64
64
|
moduleMap,
|
|
65
65
|
meta: meta2,
|
|
@@ -93,15 +93,15 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
_chunkFNJWO324js.__name.call(void 0, handleRequest, "handleRequest");
|
|
97
97
|
subscribeQueues();
|
|
98
|
-
|
|
98
|
+
_chunkH6NYBVBVjs.HMR.call(void 0, async () => {
|
|
99
99
|
for (const queue of existQueue)
|
|
100
100
|
await ch.deleteQueue(queue);
|
|
101
101
|
await subscribeQueues();
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
_chunkFNJWO324js.__name.call(void 0, bind, "bind");
|
|
105
105
|
|
|
106
106
|
// src/rpc/rabbitmq/client.ts
|
|
107
107
|
var _events = require('events');
|
|
@@ -110,7 +110,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
110
110
|
let eventCount = 0;
|
|
111
111
|
const ret = {};
|
|
112
112
|
const emitter = new (0, _events.EventEmitter)();
|
|
113
|
-
const clientQueue =
|
|
113
|
+
const clientQueue = _chunkH6NYBVBVjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
114
114
|
await ch.assertQueue(clientQueue);
|
|
115
115
|
ch.consume(clientQueue, (msg) => {
|
|
116
116
|
if (!msg)
|
|
@@ -162,7 +162,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
162
162
|
else
|
|
163
163
|
resolve(data);
|
|
164
164
|
}
|
|
165
|
-
|
|
165
|
+
_chunkFNJWO324js.__name.call(void 0, listener, "listener");
|
|
166
166
|
eventCount++;
|
|
167
167
|
emitter.once(id, listener);
|
|
168
168
|
});
|
|
@@ -172,7 +172,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
172
172
|
}
|
|
173
173
|
return ret;
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
_chunkFNJWO324js.__name.call(void 0, createClient, "createClient");
|
|
176
176
|
|
|
177
177
|
|
|
178
178
|
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-Q4AGVGVA.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-VYDBNZJ2.mjs";
|
|
11
11
|
|
|
12
12
|
// src/rpc/rabbitmq/bind.ts
|
|
13
13
|
import Debug from "debug";
|
package/dist/rpc/redis/index.js
CHANGED
|
@@ -4,24 +4,24 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
|
|
11
11
|
|
|
12
12
|
// src/rpc/redis/bind.ts
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
14
14
|
var debug = _debug2.default.call(void 0, "phecda-server/redis");
|
|
15
15
|
function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
16
16
|
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
17
|
-
const metaMap =
|
|
17
|
+
const metaMap = _chunkH6NYBVBVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
18
18
|
const { controller, rpc, func, tag } = meta2.data;
|
|
19
19
|
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
|
|
20
20
|
debug(`register method "${func}" in module "${tag}"`);
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
_chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
interceptors: globalInterceptors
|
|
27
27
|
}, "rpc");
|
|
@@ -42,7 +42,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
_chunkFNJWO324js.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
46
46
|
sub.on("message", async (channel, msg) => {
|
|
47
47
|
if (!existQueue.has(channel))
|
|
48
48
|
return;
|
|
@@ -54,7 +54,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
54
54
|
return;
|
|
55
55
|
const meta2 = metaMap.get(tag)[func];
|
|
56
56
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
57
|
-
const context = new (0,
|
|
57
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)({
|
|
58
58
|
type: "redis",
|
|
59
59
|
moduleMap,
|
|
60
60
|
redis: sub,
|
|
@@ -91,13 +91,13 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
subscribeQueues();
|
|
94
|
-
|
|
94
|
+
_chunkH6NYBVBVjs.HMR.call(void 0, async () => {
|
|
95
95
|
for (const queue of existQueue)
|
|
96
96
|
await sub.unsubscribe(queue);
|
|
97
97
|
subscribeQueues();
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
_chunkFNJWO324js.__name.call(void 0, bind, "bind");
|
|
101
101
|
|
|
102
102
|
// src/rpc/redis/client.ts
|
|
103
103
|
var _events = require('events'); var _events2 = _interopRequireDefault(_events);
|
|
@@ -106,7 +106,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
106
106
|
let eventId = 1;
|
|
107
107
|
let eventCount = 0;
|
|
108
108
|
const emitter = new (0, _events2.default)();
|
|
109
|
-
const clientQueue =
|
|
109
|
+
const clientQueue = _chunkH6NYBVBVjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
110
110
|
await sub.subscribe(clientQueue);
|
|
111
111
|
for (const i in controllers) {
|
|
112
112
|
ret[i] = new Proxy(new controllers[i](), {
|
|
@@ -152,7 +152,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
152
152
|
else
|
|
153
153
|
resolve(data);
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
_chunkFNJWO324js.__name.call(void 0, listener, "listener");
|
|
156
156
|
eventCount++;
|
|
157
157
|
emitter.once(id, listener);
|
|
158
158
|
});
|
|
@@ -168,7 +168,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
168
168
|
});
|
|
169
169
|
return ret;
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
_chunkFNJWO324js.__name.call(void 0, createClient, "createClient");
|
|
172
172
|
|
|
173
173
|
|
|
174
174
|
|
package/dist/rpc/redis/index.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-Q4AGVGVA.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-VYDBNZJ2.mjs";
|
|
11
11
|
|
|
12
12
|
// src/rpc/redis/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
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; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkAWY6FTH4js = require('../../chunk-AWY6FTH4.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
|
|
14
14
|
|
|
15
15
|
// src/server/elysia/bind.ts
|
|
16
16
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -19,14 +19,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/elysia");
|
|
|
19
19
|
function bind(app, data, opts = {}) {
|
|
20
20
|
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
21
21
|
const { moduleMap, meta } = data;
|
|
22
|
-
const metaMap =
|
|
22
|
+
const metaMap = _chunkH6NYBVBVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
23
23
|
const { controller, http, func, tag } = meta2.data;
|
|
24
24
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
25
25
|
debug(`register method "${func}" in module "${tag}"`);
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
-
|
|
29
|
+
_chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
|
|
30
30
|
plugins: [
|
|
31
31
|
...globalPlugins,
|
|
32
32
|
...parallelPlugins
|
|
@@ -36,30 +36,30 @@ function bind(app, data, opts = {}) {
|
|
|
36
36
|
});
|
|
37
37
|
registerRoute();
|
|
38
38
|
async function registerRoute() {
|
|
39
|
-
|
|
39
|
+
_chunkH6NYBVBVjs.Context.usePlugin(globalPlugins, "elysia").forEach((p) => p(app));
|
|
40
40
|
const parallelRouter = new (0, _elysia.Elysia)();
|
|
41
|
-
|
|
41
|
+
_chunkH6NYBVBVjs.Context.usePlugin(parallelPlugins, "elysia").forEach((p) => p(parallelRouter));
|
|
42
42
|
if (parallelRoute) {
|
|
43
43
|
parallelRouter.post(parallelRoute, async (c) => {
|
|
44
44
|
const { body } = c;
|
|
45
45
|
async function errorHandler(e) {
|
|
46
|
-
const error = await
|
|
46
|
+
const error = await _chunkH6NYBVBVjs.Context.filterRecord.default(e);
|
|
47
47
|
c.set.status = error.status;
|
|
48
48
|
return error;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
_chunkFNJWO324js.__name.call(void 0, errorHandler, "errorHandler");
|
|
51
51
|
if (!Array.isArray(body))
|
|
52
|
-
return errorHandler(new (0,
|
|
52
|
+
return errorHandler(new (0, _chunkH6NYBVBVjs.BadRequestException)("data format should be an array"));
|
|
53
53
|
try {
|
|
54
54
|
return Promise.all(body.map((item, i) => {
|
|
55
55
|
return new Promise(async (resolve) => {
|
|
56
56
|
const { tag, func } = item;
|
|
57
57
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
58
58
|
if (!metaMap.has(tag))
|
|
59
|
-
return resolve(await
|
|
59
|
+
return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
60
60
|
const meta2 = metaMap.get(tag)[func];
|
|
61
61
|
if (!meta2)
|
|
62
|
-
return resolve(await
|
|
62
|
+
return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
63
63
|
const { data: { params } } = meta2;
|
|
64
64
|
const contextData = {
|
|
65
65
|
type: "elysia",
|
|
@@ -71,9 +71,9 @@ function bind(app, data, opts = {}) {
|
|
|
71
71
|
tag,
|
|
72
72
|
func,
|
|
73
73
|
app,
|
|
74
|
-
...
|
|
74
|
+
..._chunkH6NYBVBVjs.argToReq.call(void 0, params, item.args, c.headers)
|
|
75
75
|
};
|
|
76
|
-
const context = new (0,
|
|
76
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
|
|
77
77
|
context.run({
|
|
78
78
|
globalGuards,
|
|
79
79
|
globalInterceptors,
|
|
@@ -97,7 +97,7 @@ function bind(app, data, opts = {}) {
|
|
|
97
97
|
const funcRouter = new (0, _elysia.Elysia)();
|
|
98
98
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
|
|
99
99
|
continue;
|
|
100
|
-
|
|
100
|
+
_chunkH6NYBVBVjs.Context.usePlugin(plugins, "elysia").forEach((p) => p(funcRouter));
|
|
101
101
|
funcRouter[http.type](http.prefix + http.route, async (c) => {
|
|
102
102
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
103
103
|
const contextData = {
|
|
@@ -113,7 +113,7 @@ function bind(app, data, opts = {}) {
|
|
|
113
113
|
headers: c.headers,
|
|
114
114
|
app
|
|
115
115
|
};
|
|
116
|
-
const context = new (0,
|
|
116
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
|
|
117
117
|
if (http.headers)
|
|
118
118
|
c.set.headers = http.headers;
|
|
119
119
|
return context.run({
|
|
@@ -130,13 +130,13 @@ function bind(app, data, opts = {}) {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
_chunkFNJWO324js.__name.call(void 0, registerRoute, "registerRoute");
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
_chunkFNJWO324js.__name.call(void 0, bind, "bind");
|
|
136
136
|
function Elysia(opts) {
|
|
137
|
-
return
|
|
137
|
+
return _chunkAWY6FTH4js.Define.call(void 0, "elysia", opts);
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
_chunkFNJWO324js.__name.call(void 0, Elysia, "Elysia");
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
|