phecda-server 6.0.0 → 6.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/dist/{chunk-TZYATAJX.js → chunk-7SYPUIBY.js} +2 -5
- package/dist/{chunk-2UTKBEZE.mjs → chunk-F3W3NN7F.mjs} +5 -0
- package/dist/{chunk-YUXERDQ6.mjs → chunk-WXFZZZRY.mjs} +8 -11
- package/dist/{chunk-PALEEADE.js → chunk-XCND2QW3.js} +6 -1
- package/dist/{core-Blq8frmr.d.ts → core-2SNw8m2B.d.mts} +1 -1
- package/dist/{core-D2oL8Ge0.d.mts → core-BmJJLUqj.d.ts} +1 -1
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +2 -2
- package/dist/helper.mjs +1 -1
- package/dist/index.d.mts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +28 -26
- package/dist/index.mjs +12 -10
- package/dist/{types-BlIBlnVT.d.mts → meta-KtfiBIde.d.mts} +44 -44
- package/dist/{types-BlIBlnVT.d.ts → meta-KtfiBIde.d.ts} +44 -44
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +6 -6
- package/dist/rpc/bullmq/index.mjs +1 -1
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +5 -5
- package/dist/rpc/kafka/index.mjs +1 -1
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +5 -5
- package/dist/rpc/nats/index.mjs +1 -1
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +6 -6
- package/dist/rpc/rabbitmq/index.mjs +1 -1
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +6 -6
- package/dist/rpc/redis/index.mjs +1 -1
- package/dist/server/elysia/index.d.mts +3 -3
- package/dist/server/elysia/index.d.ts +3 -3
- package/dist/server/elysia/index.js +29 -17
- package/dist/server/elysia/index.mjs +16 -4
- package/dist/server/express/index.d.mts +3 -3
- package/dist/server/express/index.d.ts +3 -3
- package/dist/server/express/index.js +20 -16
- package/dist/server/express/index.mjs +7 -3
- package/dist/server/fastify/index.d.mts +3 -3
- package/dist/server/fastify/index.d.ts +3 -3
- package/dist/server/fastify/index.js +21 -17
- package/dist/server/fastify/index.mjs +8 -4
- package/dist/server/h3/index.d.mts +3 -3
- package/dist/server/h3/index.d.ts +3 -3
- package/dist/server/h3/index.js +18 -14
- package/dist/server/h3/index.mjs +7 -3
- package/dist/server/hono/index.d.mts +3 -3
- package/dist/server/hono/index.d.ts +3 -3
- package/dist/server/hono/index.js +19 -15
- package/dist/server/hono/index.mjs +7 -3
- package/dist/server/hyper-express/index.d.mts +3 -3
- package/dist/server/hyper-express/index.d.ts +3 -3
- package/dist/server/hyper-express/index.js +19 -15
- package/dist/server/hyper-express/index.mjs +7 -3
- package/dist/server/koa/index.d.mts +3 -3
- package/dist/server/koa/index.d.ts +3 -3
- package/dist/server/koa/index.js +20 -16
- package/dist/server/koa/index.mjs +7 -3
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/{types-Dgxirc9f.d.mts → types-BvD3B5Ny.d.mts} +4 -2
- package/dist/{types-BCJhmpQh.d.ts → types-DIw7B6Up.d.ts} +4 -2
- package/dist/{types-B-ZFZajI.d.ts → types-JVT0mgLD.d.ts} +1 -1
- package/dist/{types-AgVwUXPC.d.mts → types-t9D1fU6G.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
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 '../../
|
|
2
|
+
import { F as Factory } from '../../core-2SNw8m2B.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';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface BullmqCtx extends RpcContext {
|
|
@@ -1,7 +1,7 @@
|
|
|
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 '../../
|
|
2
|
+
import { F as Factory } from '../../core-BmJJLUqj.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';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface BullmqCtx extends RpcContext {
|
package/dist/rpc/bullmq/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
@@ -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 = _chunk7SYPUIBYjs.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
|
+
_chunk7SYPUIBYjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
guards: globalGuards,
|
|
30
30
|
interceptors: globalInterceptors
|
|
31
31
|
}, "rpc");
|
|
@@ -53,7 +53,7 @@ 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,
|
|
56
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)({
|
|
57
57
|
type: "bullmq",
|
|
58
58
|
moduleMap,
|
|
59
59
|
meta: meta2,
|
|
@@ -87,7 +87,7 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
87
87
|
}
|
|
88
88
|
_chunkGHFSIZUOjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
89
89
|
subscribeQueues();
|
|
90
|
-
|
|
90
|
+
_chunk7SYPUIBYjs.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();
|
|
@@ -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 = _chunk7SYPUIBYjs.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;
|
|
@@ -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 '../../
|
|
2
|
+
import { F as Factory } from '../../core-2SNw8m2B.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';
|
|
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 '../../
|
|
2
|
+
import { F as Factory } from '../../core-BmJJLUqj.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';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface KafkaCtx extends RpcContext {
|
package/dist/rpc/kafka/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
@@ -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 = _chunk7SYPUIBYjs.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
|
+
_chunk7SYPUIBYjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
interceptors: globalInterceptors
|
|
27
27
|
}, "rpc");
|
|
@@ -55,7 +55,7 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
55
55
|
const meta2 = metaMap.get(tag)[func];
|
|
56
56
|
const { data: { rpc } } = meta2;
|
|
57
57
|
const isEvent = rpc.isEvent;
|
|
58
|
-
const context = new (0,
|
|
58
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)({
|
|
59
59
|
type: "kafka",
|
|
60
60
|
moduleMap,
|
|
61
61
|
meta: meta2,
|
|
@@ -117,7 +117,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
117
117
|
let eventCount = 1;
|
|
118
118
|
const ret = {};
|
|
119
119
|
const emitter = new (0, _events.EventEmitter)();
|
|
120
|
-
const clientQueue =
|
|
120
|
+
const clientQueue = _chunk7SYPUIBYjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
121
121
|
await consumer.subscribe({
|
|
122
122
|
topic: clientQueue,
|
|
123
123
|
fromBeginning: true
|
package/dist/rpc/kafka/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NatsConnection } from 'nats';
|
|
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 '../../
|
|
2
|
+
import { F as Factory } from '../../core-2SNw8m2B.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';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface NatsCtx extends RpcContext {
|
package/dist/rpc/nats/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NatsConnection } from 'nats';
|
|
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 '../../
|
|
2
|
+
import { F as Factory } from '../../core-BmJJLUqj.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';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface NatsCtx extends RpcContext {
|
package/dist/rpc/nats/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
@@ -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 = _chunk7SYPUIBYjs.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
|
+
_chunk7SYPUIBYjs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
guards: globalGuards,
|
|
29
29
|
interceptors: globalInterceptors
|
|
30
30
|
}, "rpc");
|
|
@@ -55,7 +55,7 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
55
55
|
const meta2 = metaMap.get(tag)[func];
|
|
56
56
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
57
57
|
if (isEvent) msg.respond("{}");
|
|
58
|
-
const context = new (0,
|
|
58
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)({
|
|
59
59
|
type: "nats",
|
|
60
60
|
moduleMap,
|
|
61
61
|
meta: meta2,
|
|
@@ -88,7 +88,7 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
88
88
|
}
|
|
89
89
|
_chunkGHFSIZUOjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
90
90
|
subscribeQueues();
|
|
91
|
-
|
|
91
|
+
_chunk7SYPUIBYjs.HMR.call(void 0, async () => {
|
|
92
92
|
for (const i in subscriptionMap) subscriptionMap[i].unsubscribe();
|
|
93
93
|
await subscribeQueues();
|
|
94
94
|
});
|
package/dist/rpc/nats/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import amqplib from 'amqplib';
|
|
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 '../../
|
|
2
|
+
import { F as Factory } from '../../core-2SNw8m2B.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';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface RabbitmqCtx extends RpcContext {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import amqplib from 'amqplib';
|
|
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 '../../
|
|
2
|
+
import { F as Factory } from '../../core-BmJJLUqj.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';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface RabbitmqCtx extends RpcContext {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
@@ -14,14 +14,14 @@ 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 = _chunk7SYPUIBYjs.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
|
+
_chunk7SYPUIBYjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
interceptors: globalInterceptors
|
|
27
27
|
}, "rpc");
|
|
@@ -57,7 +57,7 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
57
57
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
58
58
|
const meta2 = metaMap.get(tag)[func];
|
|
59
59
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
60
|
-
const context = new (0,
|
|
60
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)({
|
|
61
61
|
type: "rabbitmq",
|
|
62
62
|
moduleMap,
|
|
63
63
|
meta: meta2,
|
|
@@ -91,7 +91,7 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
91
91
|
}
|
|
92
92
|
_chunkGHFSIZUOjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
93
93
|
subscribeQueues();
|
|
94
|
-
|
|
94
|
+
_chunk7SYPUIBYjs.HMR.call(void 0, async () => {
|
|
95
95
|
for (const queue of existQueue) await ch.deleteQueue(queue);
|
|
96
96
|
await subscribeQueues();
|
|
97
97
|
});
|
|
@@ -105,7 +105,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
105
105
|
let eventCount = 0;
|
|
106
106
|
const ret = {};
|
|
107
107
|
const emitter = new (0, _events.EventEmitter)();
|
|
108
|
-
const clientQueue =
|
|
108
|
+
const clientQueue = _chunk7SYPUIBYjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
109
109
|
await ch.assertQueue(clientQueue);
|
|
110
110
|
ch.consume(clientQueue, (msg) => {
|
|
111
111
|
if (!msg) return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
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 '../../
|
|
2
|
+
import { F as Factory } from '../../core-2SNw8m2B.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';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface RedisCtx extends RpcContext {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
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 '../../
|
|
2
|
+
import { F as Factory } from '../../core-BmJJLUqj.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';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface RedisCtx extends RpcContext {
|
package/dist/rpc/redis/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
@@ -14,14 +14,14 @@ 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 = _chunk7SYPUIBYjs.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
|
+
_chunk7SYPUIBYjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
interceptors: globalInterceptors
|
|
27
27
|
}, "rpc");
|
|
@@ -51,7 +51,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
51
51
|
if (_ps !== 1) return;
|
|
52
52
|
const meta2 = metaMap.get(tag)[func];
|
|
53
53
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
54
|
-
const context = new (0,
|
|
54
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)({
|
|
55
55
|
type: "redis",
|
|
56
56
|
moduleMap,
|
|
57
57
|
redis: sub,
|
|
@@ -87,7 +87,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
subscribeQueues();
|
|
90
|
-
|
|
90
|
+
_chunk7SYPUIBYjs.HMR.call(void 0, async () => {
|
|
91
91
|
for (const queue of existQueue) await sub.unsubscribe(queue);
|
|
92
92
|
subscribeQueues();
|
|
93
93
|
});
|
|
@@ -101,7 +101,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
101
101
|
let eventId = 1;
|
|
102
102
|
let eventCount = 0;
|
|
103
103
|
const emitter = new (0, _events2.default)();
|
|
104
|
-
const clientQueue =
|
|
104
|
+
const clientQueue = _chunk7SYPUIBYjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
105
105
|
await sub.subscribe(clientQueue);
|
|
106
106
|
for (const i in controllers) {
|
|
107
107
|
ret[i] = new Proxy(new controllers[i](), {
|
package/dist/rpc/redis/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
|
|
2
2
|
import { BaseMacro } from 'elysia/dist/types';
|
|
3
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
|
|
4
|
+
import { F as Factory } from '../../core-2SNw8m2B.mjs';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../
|
|
6
|
+
import '../../meta-KtfiBIde.mjs';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
9
|
interface ElysiaCtx extends HttpContext {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
|
|
2
2
|
import { BaseMacro } from 'elysia/dist/types';
|
|
3
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
|
|
4
|
+
import { F as Factory } from '../../core-BmJJLUqj.js';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../
|
|
6
|
+
import '../../meta-KtfiBIde.js';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
9
|
interface ElysiaCtx extends HttpContext {
|
|
@@ -1,13 +1,13 @@
|
|
|
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 _chunkXCND2QW3js = require('../../chunk-XCND2QW3.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
@@ -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 = _chunk7SYPUIBYjs.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
|
+
_chunk7SYPUIBYjs.detectAopDep.call(void 0, meta, {
|
|
30
30
|
plugins: [
|
|
31
31
|
...globalPlugins,
|
|
32
32
|
...parallelPlugins
|
|
@@ -36,27 +36,27 @@ function bind(app, data, opts = {}) {
|
|
|
36
36
|
});
|
|
37
37
|
registerRoute();
|
|
38
38
|
async function registerRoute() {
|
|
39
|
-
|
|
39
|
+
_chunk7SYPUIBYjs.Context.usePlugin(globalPlugins, "elysia").forEach((p) => p(app));
|
|
40
40
|
const parallelRouter = new (0, _elysia.Elysia)();
|
|
41
|
-
|
|
41
|
+
_chunk7SYPUIBYjs.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 _chunk7SYPUIBYjs.Context.filterRecord.default(e);
|
|
47
47
|
c.set.status = error.status;
|
|
48
48
|
return error;
|
|
49
49
|
}
|
|
50
50
|
_chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
51
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
51
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk7SYPUIBYjs.BadRequestException)("data format should be an array"));
|
|
52
52
|
try {
|
|
53
53
|
return Promise.all(body.map((item, i) => {
|
|
54
54
|
return new Promise(async (resolve) => {
|
|
55
55
|
const { tag, func } = item;
|
|
56
56
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
57
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
57
|
+
if (!metaMap.has(tag)) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
58
58
|
const meta2 = metaMap.get(tag)[func];
|
|
59
|
-
if (!meta2) return resolve(await
|
|
59
|
+
if (!meta2) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
60
60
|
const { data: { params } } = meta2;
|
|
61
61
|
const contextData = {
|
|
62
62
|
type: "elysia",
|
|
@@ -68,7 +68,7 @@ function bind(app, data, opts = {}) {
|
|
|
68
68
|
tag,
|
|
69
69
|
func,
|
|
70
70
|
app,
|
|
71
|
-
...
|
|
71
|
+
..._chunk7SYPUIBYjs.argToReq.call(void 0, params, item.args, c.headers),
|
|
72
72
|
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
|
|
73
73
|
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
|
|
74
74
|
...opts2,
|
|
@@ -77,9 +77,15 @@ function bind(app, data, opts = {}) {
|
|
|
77
77
|
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
|
|
78
78
|
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
79
79
|
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
|
|
80
|
-
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.set.status = status, "setResStatus")
|
|
80
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.set.status = status, "setResStatus"),
|
|
81
|
+
getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => {
|
|
82
|
+
throw new Error("elysia can't support getRequest");
|
|
83
|
+
}, "getRequest"),
|
|
84
|
+
getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => {
|
|
85
|
+
throw new Error("elysia can't support getResponse");
|
|
86
|
+
}, "getResponse")
|
|
81
87
|
};
|
|
82
|
-
const context = new (0,
|
|
88
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
|
|
83
89
|
context.run({
|
|
84
90
|
globalGuards,
|
|
85
91
|
globalInterceptors,
|
|
@@ -102,7 +108,7 @@ function bind(app, data, opts = {}) {
|
|
|
102
108
|
const { data: { define, plugins, http } } = meta2;
|
|
103
109
|
const funcRouter = new (0, _elysia.Elysia)();
|
|
104
110
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
105
|
-
|
|
111
|
+
_chunk7SYPUIBYjs.Context.usePlugin(plugins, "elysia").forEach((p) => p(funcRouter));
|
|
106
112
|
funcRouter[http.type](http.prefix + http.route, async (c) => {
|
|
107
113
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
108
114
|
const contextData = {
|
|
@@ -125,9 +131,15 @@ function bind(app, data, opts = {}) {
|
|
|
125
131
|
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
|
|
126
132
|
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
127
133
|
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
|
|
128
|
-
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.set.status = status, "setResStatus")
|
|
134
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.set.status = status, "setResStatus"),
|
|
135
|
+
getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => {
|
|
136
|
+
throw new Error("elysia can't support getRequest");
|
|
137
|
+
}, "getRequest"),
|
|
138
|
+
getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => {
|
|
139
|
+
throw new Error("elysia can't support getResponse");
|
|
140
|
+
}, "getResponse")
|
|
129
141
|
};
|
|
130
|
-
const context = new (0,
|
|
142
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
|
|
131
143
|
if (http.headers) c.set.headers = http.headers;
|
|
132
144
|
return context.run({
|
|
133
145
|
globalGuards,
|
|
@@ -147,7 +159,7 @@ function bind(app, data, opts = {}) {
|
|
|
147
159
|
}
|
|
148
160
|
_chunkGHFSIZUOjs.__name.call(void 0, bind, "bind");
|
|
149
161
|
function Elysia(opts) {
|
|
150
|
-
return
|
|
162
|
+
return _chunkXCND2QW3js.Define.call(void 0, "elysia", opts);
|
|
151
163
|
}
|
|
152
164
|
_chunkGHFSIZUOjs.__name.call(void 0, Elysia, "Elysia");
|
|
153
165
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-F3W3NN7F.mjs";
|
|
4
4
|
import {
|
|
5
5
|
BadRequestException,
|
|
6
6
|
Context,
|
|
7
7
|
argToReq,
|
|
8
8
|
createControllerMetaMap,
|
|
9
9
|
detectAopDep
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-WXFZZZRY.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
13
|
} from "../../chunk-UXD62LGG.mjs";
|
|
@@ -77,7 +77,13 @@ function bind(app, data, opts = {}) {
|
|
|
77
77
|
delCookie: /* @__PURE__ */ __name((key) => c.cookie[key].remove(), "delCookie"),
|
|
78
78
|
redirect: /* @__PURE__ */ __name((url) => c.redirect(url), "redirect"),
|
|
79
79
|
setResHeaders: /* @__PURE__ */ __name((headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
|
|
80
|
-
setResStatus: /* @__PURE__ */ __name((status) => c.set.status = status, "setResStatus")
|
|
80
|
+
setResStatus: /* @__PURE__ */ __name((status) => c.set.status = status, "setResStatus"),
|
|
81
|
+
getRequest: /* @__PURE__ */ __name(() => {
|
|
82
|
+
throw new Error("elysia can't support getRequest");
|
|
83
|
+
}, "getRequest"),
|
|
84
|
+
getResponse: /* @__PURE__ */ __name(() => {
|
|
85
|
+
throw new Error("elysia can't support getResponse");
|
|
86
|
+
}, "getResponse")
|
|
81
87
|
};
|
|
82
88
|
const context = new Context(contextData);
|
|
83
89
|
context.run({
|
|
@@ -125,7 +131,13 @@ function bind(app, data, opts = {}) {
|
|
|
125
131
|
delCookie: /* @__PURE__ */ __name((key) => c.cookie[key].remove(), "delCookie"),
|
|
126
132
|
redirect: /* @__PURE__ */ __name((url) => c.redirect(url), "redirect"),
|
|
127
133
|
setResHeaders: /* @__PURE__ */ __name((headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
|
|
128
|
-
setResStatus: /* @__PURE__ */ __name((status) => c.set.status = status, "setResStatus")
|
|
134
|
+
setResStatus: /* @__PURE__ */ __name((status) => c.set.status = status, "setResStatus"),
|
|
135
|
+
getRequest: /* @__PURE__ */ __name(() => {
|
|
136
|
+
throw new Error("elysia can't support getRequest");
|
|
137
|
+
}, "getRequest"),
|
|
138
|
+
getResponse: /* @__PURE__ */ __name(() => {
|
|
139
|
+
throw new Error("elysia can't support getResponse");
|
|
140
|
+
}, "getResponse")
|
|
129
141
|
};
|
|
130
142
|
const context = new Context(contextData);
|
|
131
143
|
if (http.headers) c.set.headers = http.headers;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, RequestHandler } from 'express';
|
|
2
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-2SNw8m2B.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../
|
|
5
|
+
import '../../meta-KtfiBIde.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface ExpressCtx extends HttpContext {
|