phecda-server 7.0.0-alpha.0 → 7.0.0-alpha.1
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/assets/ps.json +24 -24
- package/bin/cli.mjs +5 -0
- package/dist/{chunk-BGXSMOLX.js → chunk-7YQ57BQS.js} +1 -1
- package/dist/{chunk-SW5IKE5H.js → chunk-GSPBHZBH.js} +47 -16
- package/dist/{chunk-P75VKZJY.mjs → chunk-V7EI76QQ.mjs} +48 -17
- package/dist/{chunk-5622RBNB.mjs → chunk-XYVMNY2X.mjs} +1 -1
- package/dist/helper.js +2 -2
- package/dist/helper.mjs +1 -1
- package/dist/http/elysia/index.js +17 -17
- package/dist/http/elysia/index.mjs +1 -1
- package/dist/http/express/index.js +17 -17
- package/dist/http/express/index.mjs +1 -1
- package/dist/http/fastify/index.js +16 -16
- package/dist/http/fastify/index.mjs +1 -1
- package/dist/http/h3/index.js +16 -16
- package/dist/http/h3/index.mjs +1 -1
- package/dist/http/hono/index.js +15 -15
- package/dist/http/hono/index.mjs +1 -1
- package/dist/http/hyper-express/index.js +15 -15
- package/dist/http/hyper-express/index.mjs +1 -1
- package/dist/http/koa/index.js +17 -17
- package/dist/http/koa/index.mjs +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +20 -20
- package/dist/index.mjs +2 -2
- package/dist/rpc/bullmq/index.js +8 -8
- package/dist/rpc/bullmq/index.mjs +1 -1
- package/dist/rpc/kafka/index.js +7 -7
- package/dist/rpc/kafka/index.mjs +1 -1
- package/dist/rpc/nats/index.js +7 -7
- package/dist/rpc/nats/index.mjs +1 -1
- package/dist/rpc/rabbitmq/index.js +8 -8
- package/dist/rpc/rabbitmq/index.mjs +1 -1
- package/dist/rpc/redis/index.js +8 -8
- package/dist/rpc/redis/index.mjs +1 -1
- package/dist/test.js +2 -2
- package/dist/test.mjs +1 -1
- package/package.json +1 -1
- package/register/loader.mjs +366 -367
package/dist/index.d.ts
CHANGED
|
@@ -138,7 +138,7 @@ declare class Context<Data extends BaseContext> {
|
|
|
138
138
|
declare function addPipe<C extends BaseContext>(key: PropertyKey, pipe: PipeType<C>): void;
|
|
139
139
|
declare function addFilter<C extends BaseContext>(key: PropertyKey, filter: FilterType<C>): void;
|
|
140
140
|
declare function addGuard<C extends BaseContext>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
|
|
141
|
-
declare function addAddon
|
|
141
|
+
declare function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority?: number): void;
|
|
142
142
|
|
|
143
143
|
declare class RPCGenerator extends Generator {
|
|
144
144
|
name: string;
|
|
@@ -207,7 +207,7 @@ declare abstract class PFilter<C extends BaseContext = any, E extends Exception
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
declare abstract class PGuard<C extends BaseContext = any> extends ServerBase {
|
|
210
|
-
abstract use(ctx: C
|
|
210
|
+
abstract use(ctx: C, next: () => Promise<any>): any;
|
|
211
211
|
readonly key: PropertyKey;
|
|
212
212
|
priority: number;
|
|
213
213
|
constructor(tag?: string);
|
|
@@ -230,7 +230,7 @@ declare abstract class PAddon extends ServerBase {
|
|
|
230
230
|
readonly key: PropertyKey;
|
|
231
231
|
priority: number;
|
|
232
232
|
constructor(tag?: string);
|
|
233
|
-
abstract use
|
|
233
|
+
abstract use(router: any, framework: string): undefined;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
interface PExtension<C extends BaseContext = any, E extends Exception = Exception> {
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk7YQ57BQSjs = require('./chunk-7YQ57BQS.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -56,7 +56,7 @@ var _chunkMBCHNDAYjs = require('./chunk-MBCHNDAY.js');
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
var
|
|
59
|
+
var _chunkGSPBHZBHjs = require('./chunk-GSPBHZBH.js');
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
|
|
@@ -98,7 +98,7 @@ var ServerBase = (_class = class extends _phecdacore.Base {constructor(...args2)
|
|
|
98
98
|
static {
|
|
99
99
|
_chunkJ5CFUN4Vjs.__name.call(void 0, this, "ServerBase");
|
|
100
100
|
}
|
|
101
|
-
__init() {this.emitter = exports.emitter =
|
|
101
|
+
__init() {this.emitter = exports.emitter = _chunk7YQ57BQSjs.emitter}
|
|
102
102
|
}, _class);
|
|
103
103
|
var HttpBase = class extends ServerBase {
|
|
104
104
|
static {
|
|
@@ -131,9 +131,9 @@ var PFilter = class extends ServerBase {
|
|
|
131
131
|
constructor(tag) {
|
|
132
132
|
super();
|
|
133
133
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
134
|
-
|
|
134
|
+
_chunkGSPBHZBHjs.addFilter.call(void 0, this.key, this.use.bind(this));
|
|
135
135
|
this.onUnmount(() => {
|
|
136
|
-
delete
|
|
136
|
+
delete _chunkGSPBHZBHjs.Context.filterRecord[this.key];
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
};
|
|
@@ -149,9 +149,9 @@ var PGuard = (_class2 = class extends ServerBase {
|
|
|
149
149
|
constructor(tag) {
|
|
150
150
|
super();_class2.prototype.__init2.call(this);;
|
|
151
151
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
152
|
-
|
|
152
|
+
_chunkGSPBHZBHjs.addGuard.call(void 0, this.key, this.use.bind(this), this.priority);
|
|
153
153
|
this.onUnmount(() => {
|
|
154
|
-
delete
|
|
154
|
+
delete _chunkGSPBHZBHjs.Context.guardRecord[this.key];
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
}, _class2);
|
|
@@ -166,9 +166,9 @@ var PPipe = class extends ServerBase {
|
|
|
166
166
|
constructor(tag) {
|
|
167
167
|
super();
|
|
168
168
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
169
|
-
|
|
169
|
+
_chunkGSPBHZBHjs.addPipe.call(void 0, this.key, this.use.bind(this));
|
|
170
170
|
this.onUnmount(() => {
|
|
171
|
-
delete
|
|
171
|
+
delete _chunkGSPBHZBHjs.Context.pipeRecord[this.key];
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
};
|
|
@@ -184,9 +184,9 @@ var PAddon = (_class3 = class extends ServerBase {
|
|
|
184
184
|
constructor(tag) {
|
|
185
185
|
super();_class3.prototype.__init3.call(this);;
|
|
186
186
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
187
|
-
|
|
187
|
+
_chunkGSPBHZBHjs.addAddon.call(void 0, this.key, this.use.bind(this), this.priority);
|
|
188
188
|
this.onUnmount(() => {
|
|
189
|
-
delete
|
|
189
|
+
delete _chunkGSPBHZBHjs.Context.addonRecord[this.key];
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
}, _class3);
|
|
@@ -204,27 +204,27 @@ var PExtension = class extends ServerBase {
|
|
|
204
204
|
super();
|
|
205
205
|
const key = this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
206
206
|
if (this.pipe) {
|
|
207
|
-
|
|
207
|
+
_chunkGSPBHZBHjs.addPipe.call(void 0, key, this.pipe.bind(this));
|
|
208
208
|
this.onUnmount(() => {
|
|
209
|
-
delete
|
|
209
|
+
delete _chunkGSPBHZBHjs.Context.pipeRecord[key];
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
if (this.addon) {
|
|
213
|
-
|
|
213
|
+
_chunkGSPBHZBHjs.addAddon.call(void 0, key, this.addon.bind(this), this.addonPriority);
|
|
214
214
|
this.onUnmount(() => {
|
|
215
|
-
delete
|
|
215
|
+
delete _chunkGSPBHZBHjs.Context.addonRecord[key];
|
|
216
216
|
});
|
|
217
217
|
}
|
|
218
218
|
if (this.guard) {
|
|
219
|
-
|
|
219
|
+
_chunkGSPBHZBHjs.addGuard.call(void 0, key, this.guard.bind(this), this.guardPriority);
|
|
220
220
|
this.onUnmount(() => {
|
|
221
|
-
delete
|
|
221
|
+
delete _chunkGSPBHZBHjs.Context.guardRecord[key];
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
224
|
if (this.filter) {
|
|
225
|
-
|
|
225
|
+
_chunkGSPBHZBHjs.addFilter.call(void 0, key, this.filter.bind(this));
|
|
226
226
|
this.onUnmount(() => {
|
|
227
|
-
delete
|
|
227
|
+
delete _chunkGSPBHZBHjs.Context.filterRecord[key];
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
230
|
}
|
|
@@ -404,4 +404,4 @@ return ret
|
|
|
404
404
|
|
|
405
405
|
|
|
406
406
|
|
|
407
|
-
exports.Addon = _chunkMBCHNDAYjs.Addon; exports.Arg = _chunkMBCHNDAYjs.Arg; exports.BadGatewayException =
|
|
407
|
+
exports.Addon = _chunkMBCHNDAYjs.Addon; exports.Arg = _chunkMBCHNDAYjs.Arg; exports.BadGatewayException = _chunkGSPBHZBHjs.BadGatewayException; exports.BadRequestException = _chunkGSPBHZBHjs.BadRequestException; exports.BaseParam = _chunkMBCHNDAYjs.BaseParam; exports.Body = _chunkMBCHNDAYjs.Body; exports.ConflictException = _chunkGSPBHZBHjs.ConflictException; exports.Context = _chunkGSPBHZBHjs.Context; exports.Controller = _chunkMBCHNDAYjs.Controller; exports.Ctx = _chunkMBCHNDAYjs.Ctx; exports.CustomResponse = CustomResponse; exports.Define = _chunkMBCHNDAYjs.Define; exports.Delete = _chunkMBCHNDAYjs.Delete; exports.ERROR_SYMBOL = _chunkJ5CFUN4Vjs.ERROR_SYMBOL; exports.Exception = _chunkGSPBHZBHjs.Exception; exports.Factory = _chunk7YQ57BQSjs.Factory; exports.Filter = _chunkMBCHNDAYjs.Filter; exports.ForbiddenException = _chunkGSPBHZBHjs.ForbiddenException; exports.FrameworkException = _chunkGSPBHZBHjs.FrameworkException; exports.Generator = Generator; exports.Get = _chunkMBCHNDAYjs.Get; exports.Guard = _chunkMBCHNDAYjs.Guard; exports.HTTPGenerator = HTTPGenerator; exports.Head = _chunkMBCHNDAYjs.Head; exports.Header = _chunkMBCHNDAYjs.Header; exports.HttpBase = HttpBase; exports.IS_HMR = _chunkJ5CFUN4Vjs.IS_HMR; exports.IS_ONLY_GENERATE = _chunkJ5CFUN4Vjs.IS_ONLY_GENERATE; exports.IS_STRICT = _chunkJ5CFUN4Vjs.IS_STRICT; exports.InvalidInputException = _chunkGSPBHZBHjs.InvalidInputException; exports.LOG_LEVEL = _chunkJ5CFUN4Vjs.LOG_LEVEL; exports.Meta = _chunk7YQ57BQSjs.Meta; exports.Mixin = _chunkJ5CFUN4Vjs.Mixin; exports.NotFoundException = _chunkGSPBHZBHjs.NotFoundException; exports.PAddon = PAddon; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PPipe = PPipe; exports.PS_EXIT_CODE = _chunkJ5CFUN4Vjs.PS_EXIT_CODE; exports.Param = _chunkMBCHNDAYjs.Param; exports.Patch = _chunkMBCHNDAYjs.Patch; exports.PayloadLargeException = _chunkGSPBHZBHjs.PayloadLargeException; exports.Pipe = _chunkMBCHNDAYjs.Pipe; exports.Post = _chunkMBCHNDAYjs.Post; exports.Put = _chunkMBCHNDAYjs.Put; exports.Query = _chunkMBCHNDAYjs.Query; exports.Queue = _chunkMBCHNDAYjs.Queue; exports.RPCGenerator = RPCGenerator; exports.Route = _chunkMBCHNDAYjs.Route; exports.Rpc = _chunkMBCHNDAYjs.Rpc; exports.RpcBase = RpcBase; exports.Search = _chunkMBCHNDAYjs.Search; exports.ServerBase = ServerBase; exports.ServerPhecda = _chunk7YQ57BQSjs.ServerPhecda; exports.ServiceUnavailableException = _chunkGSPBHZBHjs.ServiceUnavailableException; exports.TimeoutException = _chunkGSPBHZBHjs.TimeoutException; exports.TimerException = _chunkGSPBHZBHjs.TimerException; exports.UnauthorizedException = _chunkGSPBHZBHjs.UnauthorizedException; exports.UndefinedException = _chunkGSPBHZBHjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkGSPBHZBHjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkGSPBHZBHjs.ValidateException; exports.WorkerException = _chunkGSPBHZBHjs.WorkerException; exports.addAddon = _chunkGSPBHZBHjs.addAddon; exports.addFilter = _chunkGSPBHZBHjs.addFilter; exports.addGuard = _chunkGSPBHZBHjs.addGuard; exports.addPipe = _chunkGSPBHZBHjs.addPipe; exports.defaultPipe = _chunkGSPBHZBHjs.defaultPipe; exports.defaultServerInject = _chunk7YQ57BQSjs.defaultServerInject; exports.emitter = _chunk7YQ57BQSjs.emitter; exports.getLogger = _chunkJ5CFUN4Vjs.getLogger; exports.log = _chunkJ5CFUN4Vjs.log; exports.phecdaNamespace = _chunk7YQ57BQSjs.phecdaNamespace; exports.runMiddleware = _chunkJ5CFUN4Vjs.runMiddleware; exports.setLogger = _chunkJ5CFUN4Vjs.setLogger; exports.useS = _chunk7YQ57BQSjs.useS;
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
emitter,
|
|
7
7
|
phecdaNamespace,
|
|
8
8
|
useS
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XYVMNY2X.mjs";
|
|
10
10
|
import {
|
|
11
11
|
Addon,
|
|
12
12
|
Arg,
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
addGuard,
|
|
57
57
|
addPipe,
|
|
58
58
|
defaultPipe
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-V7EI76QQ.mjs";
|
|
60
60
|
import {
|
|
61
61
|
ERROR_SYMBOL,
|
|
62
62
|
IS_HMR,
|
package/dist/rpc/bullmq/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.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 = _chunkGSPBHZBHjs.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
|
+
_chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
guards: globalGuards
|
|
30
30
|
}, "rpc");
|
|
31
31
|
async function subscribeQueues() {
|
|
@@ -39,7 +39,7 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
39
39
|
if (existQueue.has(queue)) continue;
|
|
40
40
|
existQueue.add(queue);
|
|
41
41
|
workerMap[queue] = new (0, _bullmq.Worker)(queue, handleRequest, workerOpts);
|
|
42
|
-
|
|
42
|
+
_chunkGSPBHZBHjs.Context.applyAddons(addons, workerMap[queue], "bullmq");
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -53,12 +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 aop =
|
|
56
|
+
const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
|
|
57
57
|
globalFilter,
|
|
58
58
|
globalGuards,
|
|
59
59
|
globalPipe
|
|
60
60
|
});
|
|
61
|
-
const context = new (0,
|
|
61
|
+
const context = new (0, _chunkGSPBHZBHjs.Context)({
|
|
62
62
|
type: "bullmq",
|
|
63
63
|
moduleMap,
|
|
64
64
|
meta: meta2,
|
|
@@ -87,7 +87,7 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
87
87
|
}
|
|
88
88
|
_chunkJ5CFUN4Vjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
89
89
|
subscribeQueues();
|
|
90
|
-
|
|
90
|
+
_chunkGSPBHZBHjs.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 = _chunkGSPBHZBHjs.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;
|
package/dist/rpc/kafka/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
|
|
@@ -14,18 +14,18 @@ var debug = _debug2.default.call(void 0, "phecda-server/kafka");
|
|
|
14
14
|
async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
15
15
|
const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
16
16
|
const existQueue = /* @__PURE__ */ new Set();
|
|
17
|
-
const metaMap =
|
|
17
|
+
const metaMap = _chunkGSPBHZBHjs.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
|
+
_chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
|
-
|
|
28
|
+
_chunkGSPBHZBHjs.Context.applyAddons(globalAddons, {
|
|
29
29
|
consumer,
|
|
30
30
|
producer
|
|
31
31
|
}, "kafka");
|
|
@@ -59,12 +59,12 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
59
59
|
const meta2 = metaMap.get(tag)[func];
|
|
60
60
|
const { data: { rpc } } = meta2;
|
|
61
61
|
const isEvent = rpc.isEvent;
|
|
62
|
-
const aop =
|
|
62
|
+
const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
|
|
63
63
|
globalFilter,
|
|
64
64
|
globalGuards,
|
|
65
65
|
globalPipe
|
|
66
66
|
});
|
|
67
|
-
const context = new (0,
|
|
67
|
+
const context = new (0, _chunkGSPBHZBHjs.Context)({
|
|
68
68
|
type: "kafka",
|
|
69
69
|
moduleMap,
|
|
70
70
|
meta: meta2,
|
|
@@ -121,7 +121,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
121
121
|
let eventCount = 1;
|
|
122
122
|
const ret = {};
|
|
123
123
|
const emitter = new (0, _events.EventEmitter)();
|
|
124
|
-
const clientQueue =
|
|
124
|
+
const clientQueue = _chunkGSPBHZBHjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
125
125
|
await consumer.subscribe({
|
|
126
126
|
topic: clientQueue,
|
|
127
127
|
fromBeginning: true
|
package/dist/rpc/kafka/index.mjs
CHANGED
package/dist/rpc/nats/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
|
|
@@ -17,18 +17,18 @@ 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 = _chunkGSPBHZBHjs.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
|
+
_chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
addons: globalAddons,
|
|
29
29
|
guards: globalGuards
|
|
30
30
|
}, "rpc");
|
|
31
|
-
|
|
31
|
+
_chunkGSPBHZBHjs.Context.applyAddons(globalAddons, nc, "nats");
|
|
32
32
|
async function subscribeQueues() {
|
|
33
33
|
existQueue.clear();
|
|
34
34
|
for (const [tag, record] of metaMap) {
|
|
@@ -56,12 +56,12 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
56
56
|
const meta2 = metaMap.get(tag)[func];
|
|
57
57
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
58
58
|
if (isEvent) msg.respond("{}");
|
|
59
|
-
const aop =
|
|
59
|
+
const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
|
|
60
60
|
globalFilter,
|
|
61
61
|
globalGuards,
|
|
62
62
|
globalPipe
|
|
63
63
|
});
|
|
64
|
-
const context = new (0,
|
|
64
|
+
const context = new (0, _chunkGSPBHZBHjs.Context)({
|
|
65
65
|
type: "nats",
|
|
66
66
|
moduleMap,
|
|
67
67
|
meta: meta2,
|
|
@@ -89,7 +89,7 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
89
89
|
}
|
|
90
90
|
_chunkJ5CFUN4Vjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
91
91
|
subscribeQueues();
|
|
92
|
-
|
|
92
|
+
_chunkGSPBHZBHjs.HMR.call(void 0, async () => {
|
|
93
93
|
for (const i in subscriptionMap) subscriptionMap[i].unsubscribe();
|
|
94
94
|
await subscribeQueues();
|
|
95
95
|
});
|
package/dist/rpc/nats/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
|
|
@@ -14,19 +14,19 @@ 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, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
17
|
-
const metaMap =
|
|
17
|
+
const metaMap = _chunkGSPBHZBHjs.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
|
+
_chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
28
|
const existQueue = /* @__PURE__ */ new Set();
|
|
29
|
-
|
|
29
|
+
_chunkGSPBHZBHjs.Context.applyAddons(globalAddons, ch, "rabbitmq");
|
|
30
30
|
async function subscribeQueues() {
|
|
31
31
|
existQueue.clear();
|
|
32
32
|
for (const [tag, record] of metaMap) {
|
|
@@ -58,12 +58,12 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
58
58
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
59
59
|
const meta2 = metaMap.get(tag)[func];
|
|
60
60
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
61
|
-
const aop =
|
|
61
|
+
const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
|
|
62
62
|
globalFilter,
|
|
63
63
|
globalGuards,
|
|
64
64
|
globalPipe
|
|
65
65
|
});
|
|
66
|
-
const context = new (0,
|
|
66
|
+
const context = new (0, _chunkGSPBHZBHjs.Context)({
|
|
67
67
|
type: "rabbitmq",
|
|
68
68
|
moduleMap,
|
|
69
69
|
meta: meta2,
|
|
@@ -92,7 +92,7 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
92
92
|
}
|
|
93
93
|
_chunkJ5CFUN4Vjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
94
94
|
subscribeQueues();
|
|
95
|
-
|
|
95
|
+
_chunkGSPBHZBHjs.HMR.call(void 0, async () => {
|
|
96
96
|
for (const queue of existQueue) await ch.deleteQueue(queue);
|
|
97
97
|
await subscribeQueues();
|
|
98
98
|
});
|
|
@@ -106,7 +106,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
106
106
|
let eventCount = 0;
|
|
107
107
|
const ret = {};
|
|
108
108
|
const emitter = new (0, _events.EventEmitter)();
|
|
109
|
-
const clientQueue =
|
|
109
|
+
const clientQueue = _chunkGSPBHZBHjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
110
110
|
await ch.assertQueue(clientQueue);
|
|
111
111
|
ch.consume(clientQueue, (msg) => {
|
|
112
112
|
if (!msg) return;
|
package/dist/rpc/redis/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
|
|
@@ -14,19 +14,19 @@ 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, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
17
|
-
const metaMap =
|
|
17
|
+
const metaMap = _chunkGSPBHZBHjs.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
|
+
_chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
28
|
const existQueue = /* @__PURE__ */ new Set();
|
|
29
|
-
|
|
29
|
+
_chunkGSPBHZBHjs.Context.applyAddons(globalAddons, {
|
|
30
30
|
pub,
|
|
31
31
|
sub
|
|
32
32
|
}, "redis");
|
|
@@ -55,12 +55,12 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
55
55
|
if (_ps !== 1) return;
|
|
56
56
|
const meta2 = metaMap.get(tag)[func];
|
|
57
57
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
58
|
-
const aop =
|
|
58
|
+
const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
|
|
59
59
|
globalFilter,
|
|
60
60
|
globalGuards,
|
|
61
61
|
globalPipe
|
|
62
62
|
});
|
|
63
|
-
const context = new (0,
|
|
63
|
+
const context = new (0, _chunkGSPBHZBHjs.Context)({
|
|
64
64
|
type: "redis",
|
|
65
65
|
moduleMap,
|
|
66
66
|
redis: sub,
|
|
@@ -91,7 +91,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
subscribeQueues();
|
|
94
|
-
|
|
94
|
+
_chunkGSPBHZBHjs.HMR.call(void 0, async () => {
|
|
95
95
|
for (const queue of existQueue) await sub.unsubscribe(queue);
|
|
96
96
|
subscribeQueues();
|
|
97
97
|
});
|
|
@@ -105,7 +105,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
105
105
|
let eventId = 1;
|
|
106
106
|
let eventCount = 0;
|
|
107
107
|
const emitter = new (0, _events2.default)();
|
|
108
|
-
const clientQueue =
|
|
108
|
+
const clientQueue = _chunkGSPBHZBHjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
109
109
|
await sub.subscribe(clientQueue);
|
|
110
110
|
for (const i in controllers) {
|
|
111
111
|
ret[i] = new Proxy(new controllers[i](), {
|
package/dist/rpc/redis/index.mjs
CHANGED
package/dist/test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk7YQ57BQSjs = require('./chunk-7YQ57BQS.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkJ5CFUN4Vjs = require('./chunk-J5CFUN4V.js');
|
|
@@ -8,7 +8,7 @@ var _chunkJ5CFUN4Vjs = require('./chunk-J5CFUN4V.js');
|
|
|
8
8
|
// src/test.ts
|
|
9
9
|
var _phecdacore = require('phecda-core');
|
|
10
10
|
async function TestFactory(...Modules) {
|
|
11
|
-
const { moduleMap, modelMap } = await
|
|
11
|
+
const { moduleMap, modelMap } = await _chunk7YQ57BQSjs.Factory.call(void 0, Modules);
|
|
12
12
|
return {
|
|
13
13
|
get(Model) {
|
|
14
14
|
const tag = _phecdacore.getTag.call(void 0, Model);
|
package/dist/test.mjs
CHANGED