phecda-server 5.0.0 → 5.0.2
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/schema.json +7 -0
- package/dist/{chunk-5VMFQOJ7.mjs → chunk-AB4OX3WV.mjs} +13 -5
- package/dist/{chunk-VMXI3KFJ.js → chunk-BXLBWRHS.js} +12 -12
- package/dist/{chunk-C7MN5B36.mjs → chunk-W5EOVGQD.mjs} +1 -1
- package/dist/{chunk-5YYZLGGN.js → chunk-YERBWZCS.js} +13 -5
- package/dist/{core-eb646fe5.d.ts → core-fd134ffa.d.ts} +6 -15
- package/dist/helper-73e8d2f0.d.ts +18 -0
- package/dist/helper-f29f082f.d.ts +19 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +23 -23
- package/dist/index.mjs +2 -2
- package/dist/rpc/bullmq/index.d.ts +2 -3
- package/dist/rpc/bullmq/index.js +14 -17
- package/dist/rpc/bullmq/index.mjs +9 -12
- package/dist/rpc/kafka/index.d.ts +2 -3
- package/dist/rpc/kafka/index.js +14 -17
- package/dist/rpc/kafka/index.mjs +9 -12
- package/dist/rpc/nats/index.d.ts +2 -3
- package/dist/rpc/nats/index.js +13 -16
- package/dist/rpc/nats/index.mjs +9 -12
- package/dist/rpc/rabbitmq/index.d.ts +2 -3
- package/dist/rpc/rabbitmq/index.js +14 -17
- package/dist/rpc/rabbitmq/index.mjs +9 -12
- package/dist/rpc/redis/index.d.ts +2 -3
- package/dist/rpc/redis/index.js +14 -17
- package/dist/rpc/redis/index.mjs +9 -12
- package/dist/server/elysia/index.d.ts +4 -4
- package/dist/server/elysia/index.js +30 -30
- package/dist/server/elysia/index.mjs +17 -17
- package/dist/server/express/index.d.ts +4 -4
- package/dist/server/express/index.js +28 -28
- package/dist/server/express/index.mjs +16 -16
- package/dist/server/fastify/index.d.ts +4 -4
- package/dist/server/fastify/index.js +30 -30
- package/dist/server/fastify/index.mjs +17 -17
- package/dist/server/h3/index.d.ts +5 -10
- package/dist/server/h3/index.js +28 -28
- package/dist/server/h3/index.mjs +16 -16
- package/dist/server/hono/index.d.ts +4 -4
- package/dist/server/hono/index.js +28 -28
- package/dist/server/hono/index.mjs +16 -16
- package/dist/server/hyper-express/index.d.ts +4 -4
- package/dist/server/hyper-express/index.js +28 -28
- package/dist/server/hyper-express/index.mjs +16 -16
- package/dist/server/koa/index.d.ts +4 -4
- package/dist/server/koa/index.js +28 -28
- package/dist/server/koa/index.mjs +16 -16
- package/dist/test.d.ts +1 -2
- package/dist/test.js +8 -1
- package/dist/test.mjs +8 -1
- package/package.json +2 -2
- package/register/loader.mjs +36 -8
- package/dist/helper-88b19c66.d.ts +0 -12
- package/dist/helper-9e206c66.d.ts +0 -12
package/dist/rpc/kafka/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkYERBWZCSjs = require('../../chunk-YERBWZCS.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
@@ -11,8 +11,8 @@ var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
|
11
11
|
// src/rpc/kafka/bind.ts
|
|
12
12
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
13
13
|
var debug = _debug2.default.call(void 0, "phecda-server/kafka");
|
|
14
|
-
async function bind(consumer, producer, { moduleMap, meta }, opts) {
|
|
15
|
-
const { globalGuards
|
|
14
|
+
async function bind(consumer, producer, { moduleMap, meta }, opts = {}) {
|
|
15
|
+
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
16
16
|
const metaMap = /* @__PURE__ */ new Map();
|
|
17
17
|
const existQueue = /* @__PURE__ */ new Set();
|
|
18
18
|
function handleMeta() {
|
|
@@ -21,14 +21,6 @@ async function bind(consumer, producer, { moduleMap, meta }, opts) {
|
|
|
21
21
|
const { tag, func, controller, rpc } = item.data;
|
|
22
22
|
if (controller !== "rpc" || _optionalChain([rpc, 'optionalAccess', _ => _.queue]) === void 0)
|
|
23
23
|
continue;
|
|
24
|
-
item.data.guards = [
|
|
25
|
-
...globalGuards,
|
|
26
|
-
...item.data.guards
|
|
27
|
-
];
|
|
28
|
-
item.data.interceptors = [
|
|
29
|
-
...globalInterceptors,
|
|
30
|
-
...item.data.interceptors
|
|
31
|
-
];
|
|
32
24
|
if (metaMap.has(tag))
|
|
33
25
|
metaMap.get(tag)[func] = item;
|
|
34
26
|
else
|
|
@@ -58,7 +50,7 @@ async function bind(consumer, producer, { moduleMap, meta }, opts) {
|
|
|
58
50
|
}
|
|
59
51
|
}
|
|
60
52
|
_chunkYR5Q5F2Kjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
61
|
-
|
|
53
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
62
54
|
guards: globalGuards,
|
|
63
55
|
interceptors: globalInterceptors
|
|
64
56
|
}, "rpc");
|
|
@@ -76,7 +68,7 @@ async function bind(consumer, producer, { moduleMap, meta }, opts) {
|
|
|
76
68
|
const meta2 = metaMap.get(tag)[func];
|
|
77
69
|
const { data: { rpc } } = meta2;
|
|
78
70
|
const isEvent = rpc.isEvent;
|
|
79
|
-
const context = new (0,
|
|
71
|
+
const context = new (0, _chunkYERBWZCSjs.Context)({
|
|
80
72
|
type: "kafka",
|
|
81
73
|
moduleMap,
|
|
82
74
|
meta: meta2,
|
|
@@ -91,7 +83,12 @@ async function bind(consumer, producer, { moduleMap, meta }, opts) {
|
|
|
91
83
|
isEvent,
|
|
92
84
|
queue: topic
|
|
93
85
|
});
|
|
94
|
-
await context.run(
|
|
86
|
+
await context.run({
|
|
87
|
+
globalGuards,
|
|
88
|
+
globalInterceptors,
|
|
89
|
+
globalFilter,
|
|
90
|
+
globalPipe
|
|
91
|
+
}, (returnData) => {
|
|
95
92
|
if (!isEvent) {
|
|
96
93
|
producer.send({
|
|
97
94
|
topic: clientQueue,
|
|
@@ -123,8 +120,8 @@ async function bind(consumer, producer, { moduleMap, meta }, opts) {
|
|
|
123
120
|
});
|
|
124
121
|
}
|
|
125
122
|
});
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
_chunkYERBWZCSjs.HMR.call(void 0, async () => {
|
|
124
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
128
125
|
guards: globalGuards,
|
|
129
126
|
interceptors: globalInterceptors
|
|
130
127
|
}, "rpc");
|
|
@@ -140,7 +137,7 @@ async function createClient(producer, consumer, controllers, opts) {
|
|
|
140
137
|
let eventCount = 1;
|
|
141
138
|
const ret = {};
|
|
142
139
|
const emitter = new (0, _events.EventEmitter)();
|
|
143
|
-
const clientQueue =
|
|
140
|
+
const clientQueue = _chunkYERBWZCSjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
144
141
|
await consumer.subscribe({
|
|
145
142
|
topic: clientQueue,
|
|
146
143
|
fromBeginning: true
|
package/dist/rpc/kafka/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
HMR,
|
|
4
4
|
detectAopDep,
|
|
5
5
|
genClientQueue
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-AB4OX3WV.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
9
|
} from "../../chunk-ITTD2GBR.mjs";
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
// src/rpc/kafka/bind.ts
|
|
12
12
|
import Debug from "debug";
|
|
13
13
|
var debug = Debug("phecda-server/kafka");
|
|
14
|
-
async function bind(consumer, producer, { moduleMap, meta }, opts) {
|
|
15
|
-
const { globalGuards
|
|
14
|
+
async function bind(consumer, producer, { moduleMap, meta }, opts = {}) {
|
|
15
|
+
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
16
16
|
const metaMap = /* @__PURE__ */ new Map();
|
|
17
17
|
const existQueue = /* @__PURE__ */ new Set();
|
|
18
18
|
function handleMeta() {
|
|
@@ -21,14 +21,6 @@ async function bind(consumer, producer, { moduleMap, meta }, opts) {
|
|
|
21
21
|
const { tag, func, controller, rpc } = item.data;
|
|
22
22
|
if (controller !== "rpc" || rpc?.queue === void 0)
|
|
23
23
|
continue;
|
|
24
|
-
item.data.guards = [
|
|
25
|
-
...globalGuards,
|
|
26
|
-
...item.data.guards
|
|
27
|
-
];
|
|
28
|
-
item.data.interceptors = [
|
|
29
|
-
...globalInterceptors,
|
|
30
|
-
...item.data.interceptors
|
|
31
|
-
];
|
|
32
24
|
if (metaMap.has(tag))
|
|
33
25
|
metaMap.get(tag)[func] = item;
|
|
34
26
|
else
|
|
@@ -91,7 +83,12 @@ async function bind(consumer, producer, { moduleMap, meta }, opts) {
|
|
|
91
83
|
isEvent,
|
|
92
84
|
queue: topic
|
|
93
85
|
});
|
|
94
|
-
await context.run(
|
|
86
|
+
await context.run({
|
|
87
|
+
globalGuards,
|
|
88
|
+
globalInterceptors,
|
|
89
|
+
globalFilter,
|
|
90
|
+
globalPipe
|
|
91
|
+
}, (returnData) => {
|
|
95
92
|
if (!isEvent) {
|
|
96
93
|
producer.send({
|
|
97
94
|
topic: clientQueue,
|
package/dist/rpc/nats/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { NatsConnection } from 'nats';
|
|
2
|
-
import {
|
|
3
|
-
import { R as RpcServerOptions, a as RpcClientOptions } from '../../helper-
|
|
2
|
+
import { F as Factory, T as ToClientMap } from '../../core-fd134ffa.js';
|
|
3
|
+
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../helper-73e8d2f0.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import 'http';
|
|
6
5
|
|
|
7
6
|
interface NatsCtx extends RpcContext {
|
|
8
7
|
type: 'nats';
|
package/dist/rpc/nats/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkYERBWZCSjs = require('../../chunk-YERBWZCS.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
@@ -11,8 +11,8 @@ var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
|
11
11
|
var _nats = require('nats');
|
|
12
12
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
13
13
|
var debug = _debug2.default.call(void 0, "phecda-server/nats");
|
|
14
|
-
async function bind(nc, { moduleMap, meta }, opts) {
|
|
15
|
-
const { globalGuards
|
|
14
|
+
async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
15
|
+
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
16
16
|
const sc = _nats.StringCodec.call(void 0, );
|
|
17
17
|
const subscriptionMap = {};
|
|
18
18
|
const metaMap = /* @__PURE__ */ new Map();
|
|
@@ -23,14 +23,6 @@ async function bind(nc, { moduleMap, meta }, opts) {
|
|
|
23
23
|
const { tag, func, controller, rpc } = item.data;
|
|
24
24
|
if (controller !== "rpc" || _optionalChain([rpc, 'optionalAccess', _2 => _2.queue]) === void 0)
|
|
25
25
|
continue;
|
|
26
|
-
item.data.guards = [
|
|
27
|
-
...globalGuards,
|
|
28
|
-
...item.data.guards
|
|
29
|
-
];
|
|
30
|
-
item.data.interceptors = [
|
|
31
|
-
...globalInterceptors,
|
|
32
|
-
...item.data.interceptors
|
|
33
|
-
];
|
|
34
26
|
if (metaMap.has(tag))
|
|
35
27
|
metaMap.get(tag)[func] = item;
|
|
36
28
|
else
|
|
@@ -70,7 +62,7 @@ async function bind(nc, { moduleMap, meta }, opts) {
|
|
|
70
62
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
71
63
|
if (isEvent)
|
|
72
64
|
msg.respond("{}");
|
|
73
|
-
const context = new (0,
|
|
65
|
+
const context = new (0, _chunkYERBWZCSjs.Context)({
|
|
74
66
|
type: "nats",
|
|
75
67
|
moduleMap,
|
|
76
68
|
meta: meta2,
|
|
@@ -82,7 +74,12 @@ async function bind(nc, { moduleMap, meta }, opts) {
|
|
|
82
74
|
isEvent,
|
|
83
75
|
queue: msg._msg.subject.toString()
|
|
84
76
|
});
|
|
85
|
-
await context.run(
|
|
77
|
+
await context.run({
|
|
78
|
+
globalGuards,
|
|
79
|
+
globalInterceptors,
|
|
80
|
+
globalFilter,
|
|
81
|
+
globalPipe
|
|
82
|
+
}, (returnData) => {
|
|
86
83
|
if (!isEvent)
|
|
87
84
|
msg.respond(sc.encode(JSON.stringify({
|
|
88
85
|
data: returnData,
|
|
@@ -98,14 +95,14 @@ async function bind(nc, { moduleMap, meta }, opts) {
|
|
|
98
95
|
});
|
|
99
96
|
}
|
|
100
97
|
_chunkYR5Q5F2Kjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
101
|
-
|
|
98
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
102
99
|
guards: globalGuards,
|
|
103
100
|
interceptors: globalInterceptors
|
|
104
101
|
}, "rpc");
|
|
105
102
|
handleMeta();
|
|
106
103
|
subscribeQueues();
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
_chunkYERBWZCSjs.HMR.call(void 0, async () => {
|
|
105
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
109
106
|
guards: globalGuards,
|
|
110
107
|
interceptors: globalInterceptors
|
|
111
108
|
}, "rpc");
|
package/dist/rpc/nats/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
Context,
|
|
3
3
|
HMR,
|
|
4
4
|
detectAopDep
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-AB4OX3WV.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "../../chunk-ITTD2GBR.mjs";
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
import { StringCodec } from "nats";
|
|
12
12
|
import Debug from "debug";
|
|
13
13
|
var debug = Debug("phecda-server/nats");
|
|
14
|
-
async function bind(nc, { moduleMap, meta }, opts) {
|
|
15
|
-
const { globalGuards
|
|
14
|
+
async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
15
|
+
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
16
16
|
const sc = StringCodec();
|
|
17
17
|
const subscriptionMap = {};
|
|
18
18
|
const metaMap = /* @__PURE__ */ new Map();
|
|
@@ -23,14 +23,6 @@ async function bind(nc, { moduleMap, meta }, opts) {
|
|
|
23
23
|
const { tag, func, controller, rpc } = item.data;
|
|
24
24
|
if (controller !== "rpc" || rpc?.queue === void 0)
|
|
25
25
|
continue;
|
|
26
|
-
item.data.guards = [
|
|
27
|
-
...globalGuards,
|
|
28
|
-
...item.data.guards
|
|
29
|
-
];
|
|
30
|
-
item.data.interceptors = [
|
|
31
|
-
...globalInterceptors,
|
|
32
|
-
...item.data.interceptors
|
|
33
|
-
];
|
|
34
26
|
if (metaMap.has(tag))
|
|
35
27
|
metaMap.get(tag)[func] = item;
|
|
36
28
|
else
|
|
@@ -82,7 +74,12 @@ async function bind(nc, { moduleMap, meta }, opts) {
|
|
|
82
74
|
isEvent,
|
|
83
75
|
queue: msg._msg.subject.toString()
|
|
84
76
|
});
|
|
85
|
-
await context.run(
|
|
77
|
+
await context.run({
|
|
78
|
+
globalGuards,
|
|
79
|
+
globalInterceptors,
|
|
80
|
+
globalFilter,
|
|
81
|
+
globalPipe
|
|
82
|
+
}, (returnData) => {
|
|
86
83
|
if (!isEvent)
|
|
87
84
|
msg.respond(sc.encode(JSON.stringify({
|
|
88
85
|
data: returnData,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import amqplib from 'amqplib';
|
|
2
|
-
import {
|
|
3
|
-
import { R as RpcServerOptions, a as RpcClientOptions } from '../../helper-
|
|
2
|
+
import { F as Factory, T as ToClientMap } from '../../core-fd134ffa.js';
|
|
3
|
+
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../helper-73e8d2f0.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import 'http';
|
|
6
5
|
|
|
7
6
|
interface RabbitmqCtx extends RpcContext {
|
|
8
7
|
type: 'rabbitmq';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkYERBWZCSjs = require('../../chunk-YERBWZCS.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
@@ -11,8 +11,8 @@ var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
|
11
11
|
// src/rpc/rabbitmq/bind.ts
|
|
12
12
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
13
13
|
var debug = _debug2.default.call(void 0, "phecda-server/rabbitmq");
|
|
14
|
-
async function bind(ch, { moduleMap, meta }, opts) {
|
|
15
|
-
const { globalGuards
|
|
14
|
+
async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
15
|
+
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
16
16
|
const metaMap = /* @__PURE__ */ new Map();
|
|
17
17
|
const existQueue = /* @__PURE__ */ new Set();
|
|
18
18
|
function handleMeta() {
|
|
@@ -21,14 +21,6 @@ async function bind(ch, { moduleMap, meta }, opts) {
|
|
|
21
21
|
const { tag, func, controller, rpc } = item.data;
|
|
22
22
|
if (controller !== "rpc" || _optionalChain([rpc, 'optionalAccess', _ => _.queue]) === void 0)
|
|
23
23
|
continue;
|
|
24
|
-
item.data.guards = [
|
|
25
|
-
...globalGuards,
|
|
26
|
-
...item.data.guards
|
|
27
|
-
];
|
|
28
|
-
item.data.interceptors = [
|
|
29
|
-
...globalInterceptors,
|
|
30
|
-
...item.data.interceptors
|
|
31
|
-
];
|
|
32
24
|
if (metaMap.has(tag))
|
|
33
25
|
metaMap.get(tag)[func] = item;
|
|
34
26
|
else
|
|
@@ -71,7 +63,7 @@ async function bind(ch, { moduleMap, meta }, opts) {
|
|
|
71
63
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
72
64
|
const meta2 = metaMap.get(tag)[func];
|
|
73
65
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
74
|
-
const context = new (0,
|
|
66
|
+
const context = new (0, _chunkYERBWZCSjs.Context)({
|
|
75
67
|
type: "rabbitmq",
|
|
76
68
|
moduleMap,
|
|
77
69
|
meta: meta2,
|
|
@@ -84,7 +76,12 @@ async function bind(ch, { moduleMap, meta }, opts) {
|
|
|
84
76
|
isEvent,
|
|
85
77
|
queue: msg.fields.routingKey
|
|
86
78
|
});
|
|
87
|
-
await context.run(
|
|
79
|
+
await context.run({
|
|
80
|
+
globalGuards,
|
|
81
|
+
globalInterceptors,
|
|
82
|
+
globalFilter,
|
|
83
|
+
globalPipe
|
|
84
|
+
}, (returnData) => {
|
|
88
85
|
if (!isEvent)
|
|
89
86
|
send(clientQueue, {
|
|
90
87
|
data: returnData,
|
|
@@ -101,14 +98,14 @@ async function bind(ch, { moduleMap, meta }, opts) {
|
|
|
101
98
|
}
|
|
102
99
|
}
|
|
103
100
|
_chunkYR5Q5F2Kjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
104
|
-
|
|
101
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
105
102
|
guards: globalGuards,
|
|
106
103
|
interceptors: globalInterceptors
|
|
107
104
|
}, "rpc");
|
|
108
105
|
handleMeta();
|
|
109
106
|
subscribeQueues();
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
_chunkYERBWZCSjs.HMR.call(void 0, async () => {
|
|
108
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
112
109
|
guards: globalGuards,
|
|
113
110
|
interceptors: globalInterceptors
|
|
114
111
|
}, "rpc");
|
|
@@ -127,7 +124,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
127
124
|
let eventCount = 0;
|
|
128
125
|
const ret = {};
|
|
129
126
|
const emitter = new (0, _events.EventEmitter)();
|
|
130
|
-
const clientQueue =
|
|
127
|
+
const clientQueue = _chunkYERBWZCSjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
131
128
|
await ch.assertQueue(clientQueue);
|
|
132
129
|
ch.consume(clientQueue, (msg) => {
|
|
133
130
|
if (!msg)
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
HMR,
|
|
4
4
|
detectAopDep,
|
|
5
5
|
genClientQueue
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-AB4OX3WV.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
9
|
} from "../../chunk-ITTD2GBR.mjs";
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
// src/rpc/rabbitmq/bind.ts
|
|
12
12
|
import Debug from "debug";
|
|
13
13
|
var debug = Debug("phecda-server/rabbitmq");
|
|
14
|
-
async function bind(ch, { moduleMap, meta }, opts) {
|
|
15
|
-
const { globalGuards
|
|
14
|
+
async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
15
|
+
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
16
16
|
const metaMap = /* @__PURE__ */ new Map();
|
|
17
17
|
const existQueue = /* @__PURE__ */ new Set();
|
|
18
18
|
function handleMeta() {
|
|
@@ -21,14 +21,6 @@ async function bind(ch, { moduleMap, meta }, opts) {
|
|
|
21
21
|
const { tag, func, controller, rpc } = item.data;
|
|
22
22
|
if (controller !== "rpc" || rpc?.queue === void 0)
|
|
23
23
|
continue;
|
|
24
|
-
item.data.guards = [
|
|
25
|
-
...globalGuards,
|
|
26
|
-
...item.data.guards
|
|
27
|
-
];
|
|
28
|
-
item.data.interceptors = [
|
|
29
|
-
...globalInterceptors,
|
|
30
|
-
...item.data.interceptors
|
|
31
|
-
];
|
|
32
24
|
if (metaMap.has(tag))
|
|
33
25
|
metaMap.get(tag)[func] = item;
|
|
34
26
|
else
|
|
@@ -84,7 +76,12 @@ async function bind(ch, { moduleMap, meta }, opts) {
|
|
|
84
76
|
isEvent,
|
|
85
77
|
queue: msg.fields.routingKey
|
|
86
78
|
});
|
|
87
|
-
await context.run(
|
|
79
|
+
await context.run({
|
|
80
|
+
globalGuards,
|
|
81
|
+
globalInterceptors,
|
|
82
|
+
globalFilter,
|
|
83
|
+
globalPipe
|
|
84
|
+
}, (returnData) => {
|
|
88
85
|
if (!isEvent)
|
|
89
86
|
send(clientQueue, {
|
|
90
87
|
data: returnData,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
|
-
import {
|
|
3
|
-
import { R as RpcServerOptions, a as RpcClientOptions } from '../../helper-
|
|
2
|
+
import { F as Factory, T as ToClientMap } from '../../core-fd134ffa.js';
|
|
3
|
+
import { b as RpcContext, R as RpcServerOptions, a as RpcClientOptions } from '../../helper-73e8d2f0.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import 'http';
|
|
6
5
|
|
|
7
6
|
interface RedisCtx extends RpcContext {
|
|
8
7
|
type: 'redis';
|
package/dist/rpc/redis/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkYERBWZCSjs = require('../../chunk-YERBWZCS.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
@@ -11,8 +11,8 @@ var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
|
11
11
|
// src/rpc/redis/bind.ts
|
|
12
12
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
13
13
|
var debug = _debug2.default.call(void 0, "phecda-server/redis");
|
|
14
|
-
function bind(sub, pub, { moduleMap, meta }, opts) {
|
|
15
|
-
const { globalGuards
|
|
14
|
+
function bind(sub, pub, { moduleMap, meta }, opts = {}) {
|
|
15
|
+
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
16
16
|
const metaMap = /* @__PURE__ */ new Map();
|
|
17
17
|
const existQueue = /* @__PURE__ */ new Set();
|
|
18
18
|
function handleMeta() {
|
|
@@ -21,14 +21,6 @@ function bind(sub, pub, { moduleMap, meta }, opts) {
|
|
|
21
21
|
const { tag, func, controller, rpc } = item.data;
|
|
22
22
|
if (controller !== "rpc" || _optionalChain([rpc, 'optionalAccess', _ => _.queue]) === void 0)
|
|
23
23
|
continue;
|
|
24
|
-
item.data.guards = [
|
|
25
|
-
...globalGuards,
|
|
26
|
-
...item.data.guards
|
|
27
|
-
];
|
|
28
|
-
item.data.interceptors = [
|
|
29
|
-
...globalInterceptors,
|
|
30
|
-
...item.data.interceptors
|
|
31
|
-
];
|
|
32
24
|
if (metaMap.has(tag))
|
|
33
25
|
metaMap.get(tag)[func] = item;
|
|
34
26
|
else
|
|
@@ -66,7 +58,7 @@ function bind(sub, pub, { moduleMap, meta }, opts) {
|
|
|
66
58
|
return;
|
|
67
59
|
const meta2 = metaMap.get(tag)[func];
|
|
68
60
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
69
|
-
const context = new (0,
|
|
61
|
+
const context = new (0, _chunkYERBWZCSjs.Context)({
|
|
70
62
|
type: "redis",
|
|
71
63
|
moduleMap,
|
|
72
64
|
redis: sub,
|
|
@@ -80,7 +72,12 @@ function bind(sub, pub, { moduleMap, meta }, opts) {
|
|
|
80
72
|
isEvent,
|
|
81
73
|
queue: channel
|
|
82
74
|
});
|
|
83
|
-
await context.run(
|
|
75
|
+
await context.run({
|
|
76
|
+
globalGuards,
|
|
77
|
+
globalInterceptors,
|
|
78
|
+
globalFilter,
|
|
79
|
+
globalPipe
|
|
80
|
+
}, (returnData) => {
|
|
84
81
|
if (!isEvent)
|
|
85
82
|
pub.publish(clientQueue, JSON.stringify({
|
|
86
83
|
data: returnData,
|
|
@@ -97,14 +94,14 @@ function bind(sub, pub, { moduleMap, meta }, opts) {
|
|
|
97
94
|
});
|
|
98
95
|
}
|
|
99
96
|
});
|
|
100
|
-
|
|
97
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
101
98
|
guards: globalGuards,
|
|
102
99
|
interceptors: globalInterceptors
|
|
103
100
|
}, "rpc");
|
|
104
101
|
handleMeta();
|
|
105
102
|
subscribeQueues();
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
_chunkYERBWZCSjs.HMR.call(void 0, async () => {
|
|
104
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
108
105
|
guards: globalGuards,
|
|
109
106
|
interceptors: globalInterceptors
|
|
110
107
|
}, "rpc");
|
|
@@ -123,7 +120,7 @@ async function createClient(pub, sub, controllers, opts) {
|
|
|
123
120
|
let eventId = 1;
|
|
124
121
|
let eventCount = 0;
|
|
125
122
|
const emitter = new (0, _events2.default)();
|
|
126
|
-
const clientQueue =
|
|
123
|
+
const clientQueue = _chunkYERBWZCSjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
127
124
|
await sub.subscribe(clientQueue);
|
|
128
125
|
for (const i in controllers) {
|
|
129
126
|
ret[i] = new Proxy(new controllers[i](), {
|
package/dist/rpc/redis/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
HMR,
|
|
4
4
|
detectAopDep,
|
|
5
5
|
genClientQueue
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-AB4OX3WV.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
9
|
} from "../../chunk-ITTD2GBR.mjs";
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
// src/rpc/redis/bind.ts
|
|
12
12
|
import Debug from "debug";
|
|
13
13
|
var debug = Debug("phecda-server/redis");
|
|
14
|
-
function bind(sub, pub, { moduleMap, meta }, opts) {
|
|
15
|
-
const { globalGuards
|
|
14
|
+
function bind(sub, pub, { moduleMap, meta }, opts = {}) {
|
|
15
|
+
const { globalGuards, globalInterceptors, globalFilter, globalPipe } = opts;
|
|
16
16
|
const metaMap = /* @__PURE__ */ new Map();
|
|
17
17
|
const existQueue = /* @__PURE__ */ new Set();
|
|
18
18
|
function handleMeta() {
|
|
@@ -21,14 +21,6 @@ function bind(sub, pub, { moduleMap, meta }, opts) {
|
|
|
21
21
|
const { tag, func, controller, rpc } = item.data;
|
|
22
22
|
if (controller !== "rpc" || rpc?.queue === void 0)
|
|
23
23
|
continue;
|
|
24
|
-
item.data.guards = [
|
|
25
|
-
...globalGuards,
|
|
26
|
-
...item.data.guards
|
|
27
|
-
];
|
|
28
|
-
item.data.interceptors = [
|
|
29
|
-
...globalInterceptors,
|
|
30
|
-
...item.data.interceptors
|
|
31
|
-
];
|
|
32
24
|
if (metaMap.has(tag))
|
|
33
25
|
metaMap.get(tag)[func] = item;
|
|
34
26
|
else
|
|
@@ -80,7 +72,12 @@ function bind(sub, pub, { moduleMap, meta }, opts) {
|
|
|
80
72
|
isEvent,
|
|
81
73
|
queue: channel
|
|
82
74
|
});
|
|
83
|
-
await context.run(
|
|
75
|
+
await context.run({
|
|
76
|
+
globalGuards,
|
|
77
|
+
globalInterceptors,
|
|
78
|
+
globalFilter,
|
|
79
|
+
globalPipe
|
|
80
|
+
}, (returnData) => {
|
|
84
81
|
if (!isEvent)
|
|
85
82
|
pub.publish(clientQueue, JSON.stringify({
|
|
86
83
|
data: returnData,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
|
|
2
2
|
import { BaseMacro } from 'elysia/dist/types';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { a as HttpContext, H as HttpOptions } from '../../helper-f29f082f.js';
|
|
4
|
+
import { F as Factory } from '../../core-fd134ffa.js';
|
|
5
|
+
import 'node:http';
|
|
5
6
|
import 'phecda-core';
|
|
6
|
-
import 'http';
|
|
7
7
|
|
|
8
8
|
interface ElysiaCtx extends HttpContext {
|
|
9
9
|
type: 'elysia';
|
|
10
10
|
app: Elysia$1;
|
|
11
11
|
context: Context;
|
|
12
12
|
}
|
|
13
|
-
declare function bind(app: Elysia$1<any>, data: Awaited<ReturnType<typeof Factory>>,
|
|
13
|
+
declare function bind(app: Elysia$1<any>, data: Awaited<ReturnType<typeof Factory>>, opts?: HttpOptions): void;
|
|
14
14
|
declare function Elysia(opts: LocalHook<InputSchema, RouteSchema, SingletonBase, Record<string, Error>, BaseMacro>): any;
|
|
15
15
|
|
|
16
16
|
export { Elysia, ElysiaCtx, bind };
|