phecda-server 5.3.1 → 5.3.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/dist/{chunk-ODUYOCDF.js → chunk-2HVTWYS2.js} +37 -37
- package/dist/{chunk-N4ULJDEQ.js → chunk-3D7AROG2.js} +36 -25
- package/dist/{chunk-BZKJ5NBU.mjs → chunk-3IPYLGY2.mjs} +1 -1
- package/dist/{chunk-LHLQIQPH.mjs → chunk-ECSI4QBK.mjs} +18 -7
- package/dist/{chunk-RVWBJ6LV.js → chunk-GHFSIZUO.js} +2 -10
- package/dist/{chunk-QYX5Q7KO.js → chunk-RZ7IXJYQ.js} +60 -60
- package/dist/{chunk-ORQAEOSE.mjs → chunk-SXOZVIKW.mjs} +2 -2
- package/dist/{chunk-MESZCLSS.mjs → chunk-UXD62LGG.mjs} +2 -10
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +43 -43
- package/dist/index.mjs +6 -6
- package/dist/rpc/bullmq/index.js +12 -12
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.js +12 -12
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.js +11 -11
- package/dist/rpc/nats/index.mjs +2 -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 +32 -32
- package/dist/server/elysia/index.mjs +3 -3
- package/dist/server/express/index.js +30 -30
- package/dist/server/express/index.mjs +2 -2
- package/dist/server/fastify/index.js +31 -31
- package/dist/server/fastify/index.mjs +3 -3
- package/dist/server/h3/index.js +30 -30
- package/dist/server/h3/index.mjs +2 -2
- package/dist/server/hono/index.js +29 -29
- package/dist/server/hono/index.mjs +2 -2
- package/dist/server/hyper-express/index.js +29 -29
- package/dist/server/hyper-express/index.mjs +2 -2
- package/dist/server/koa/index.js +30 -30
- package/dist/server/koa/index.mjs +2 -2
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/package.json +2 -1
|
@@ -4,24 +4,24 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkRZ7IXJYQjs = require('../../chunk-RZ7IXJYQ.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.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 = _chunkRZ7IXJYQjs.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
|
+
_chunkRZ7IXJYQjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
interceptors: globalInterceptors
|
|
27
27
|
}, "rpc");
|
|
@@ -44,12 +44,12 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
_chunkGHFSIZUOjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
48
48
|
async function handleRequest(msg) {
|
|
49
49
|
function send(queue, data) {
|
|
50
50
|
ch.sendToQueue(queue, Buffer.from(JSON.stringify(data)));
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
_chunkGHFSIZUOjs.__name.call(void 0, send, "send");
|
|
53
53
|
if (msg) {
|
|
54
54
|
const data = JSON.parse(msg.content.toString());
|
|
55
55
|
const { tag, func, id, queue: clientQueue, _ps, args } = data;
|
|
@@ -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, _chunkRZ7IXJYQjs.Context)({
|
|
61
61
|
type: "rabbitmq",
|
|
62
62
|
moduleMap,
|
|
63
63
|
meta: meta2,
|
|
@@ -89,14 +89,14 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
_chunkGHFSIZUOjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
93
93
|
subscribeQueues();
|
|
94
|
-
|
|
94
|
+
_chunkRZ7IXJYQjs.HMR.call(void 0, async () => {
|
|
95
95
|
for (const queue of existQueue) await ch.deleteQueue(queue);
|
|
96
96
|
await subscribeQueues();
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
_chunkGHFSIZUOjs.__name.call(void 0, bind, "bind");
|
|
100
100
|
|
|
101
101
|
// src/rpc/rabbitmq/client.ts
|
|
102
102
|
var _events = require('events');
|
|
@@ -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 = _chunkRZ7IXJYQjs.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;
|
|
@@ -150,7 +150,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
150
150
|
if (error) reject(data);
|
|
151
151
|
else resolve(data);
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
_chunkGHFSIZUOjs.__name.call(void 0, listener, "listener");
|
|
154
154
|
eventCount++;
|
|
155
155
|
emitter.once(id, listener);
|
|
156
156
|
});
|
|
@@ -160,7 +160,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
160
160
|
}
|
|
161
161
|
return ret;
|
|
162
162
|
}
|
|
163
|
-
|
|
163
|
+
_chunkGHFSIZUOjs.__name.call(void 0, createClient, "createClient");
|
|
164
164
|
|
|
165
165
|
|
|
166
166
|
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-3IPYLGY2.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-UXD62LGG.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 _chunkRZ7IXJYQjs = require('../../chunk-RZ7IXJYQ.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.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 = _chunkRZ7IXJYQjs.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
|
+
_chunkRZ7IXJYQjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
interceptors: globalInterceptors
|
|
27
27
|
}, "rpc");
|
|
@@ -41,7 +41,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
_chunkGHFSIZUOjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
45
45
|
sub.on("message", async (channel, msg) => {
|
|
46
46
|
if (!existQueue.has(channel)) return;
|
|
47
47
|
if (msg) {
|
|
@@ -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, _chunkRZ7IXJYQjs.Context)({
|
|
55
55
|
type: "redis",
|
|
56
56
|
moduleMap,
|
|
57
57
|
redis: sub,
|
|
@@ -87,12 +87,12 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
subscribeQueues();
|
|
90
|
-
|
|
90
|
+
_chunkRZ7IXJYQjs.HMR.call(void 0, async () => {
|
|
91
91
|
for (const queue of existQueue) await sub.unsubscribe(queue);
|
|
92
92
|
subscribeQueues();
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
_chunkGHFSIZUOjs.__name.call(void 0, bind, "bind");
|
|
96
96
|
|
|
97
97
|
// src/rpc/redis/client.ts
|
|
98
98
|
var _events = require('events'); var _events2 = _interopRequireDefault(_events);
|
|
@@ -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 = _chunkRZ7IXJYQjs.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](), {
|
|
@@ -141,7 +141,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
141
141
|
if (error) reject(data);
|
|
142
142
|
else resolve(data);
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
_chunkGHFSIZUOjs.__name.call(void 0, listener, "listener");
|
|
145
145
|
eventCount++;
|
|
146
146
|
emitter.once(id, listener);
|
|
147
147
|
});
|
|
@@ -157,7 +157,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
157
157
|
});
|
|
158
158
|
return ret;
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
_chunkGHFSIZUOjs.__name.call(void 0, createClient, "createClient");
|
|
161
161
|
|
|
162
162
|
|
|
163
163
|
|
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-3IPYLGY2.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-UXD62LGG.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 _chunk2HVTWYS2js = require('../../chunk-2HVTWYS2.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkRZ7IXJYQjs = require('../../chunk-RZ7IXJYQ.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.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 = _chunkRZ7IXJYQjs.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
|
+
_chunkRZ7IXJYQjs.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
|
+
_chunkRZ7IXJYQjs.Context.usePlugin(globalPlugins, "elysia").forEach((p) => p(app));
|
|
40
40
|
const parallelRouter = new (0, _elysia.Elysia)();
|
|
41
|
-
|
|
41
|
+
_chunkRZ7IXJYQjs.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 _chunkRZ7IXJYQjs.Context.filterRecord.default(e);
|
|
47
47
|
c.set.status = error.status;
|
|
48
48
|
return error;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
50
|
+
_chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
51
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkRZ7IXJYQjs.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 _chunkRZ7IXJYQjs.Context.filterRecord.default(new (0, _chunkRZ7IXJYQjs.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 _chunkRZ7IXJYQjs.Context.filterRecord.default(new (0, _chunkRZ7IXJYQjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
60
60
|
const { data: { params } } = meta2;
|
|
61
61
|
const contextData = {
|
|
62
62
|
type: "elysia",
|
|
@@ -68,18 +68,18 @@ function bind(app, data, opts = {}) {
|
|
|
68
68
|
tag,
|
|
69
69
|
func,
|
|
70
70
|
app,
|
|
71
|
-
...
|
|
72
|
-
getCookie: /* @__PURE__ */
|
|
73
|
-
setCookie: /* @__PURE__ */
|
|
71
|
+
..._chunkRZ7IXJYQjs.argToReq.call(void 0, params, item.args, c.headers),
|
|
72
|
+
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
|
|
73
|
+
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
|
|
74
74
|
...opts2,
|
|
75
75
|
value
|
|
76
76
|
}), "setCookie"),
|
|
77
|
-
delCookie: /* @__PURE__ */
|
|
78
|
-
redirect: /* @__PURE__ */
|
|
79
|
-
setResHeaders: /* @__PURE__ */
|
|
80
|
-
setResStatus: /* @__PURE__ */
|
|
77
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
|
|
78
|
+
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
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")
|
|
81
81
|
};
|
|
82
|
-
const context = new (0,
|
|
82
|
+
const context = new (0, _chunkRZ7IXJYQjs.Context)(contextData);
|
|
83
83
|
context.run({
|
|
84
84
|
globalGuards,
|
|
85
85
|
globalInterceptors,
|
|
@@ -102,7 +102,7 @@ function bind(app, data, opts = {}) {
|
|
|
102
102
|
const { data: { define, plugins, http } } = meta2;
|
|
103
103
|
const funcRouter = new (0, _elysia.Elysia)();
|
|
104
104
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
105
|
-
|
|
105
|
+
_chunkRZ7IXJYQjs.Context.usePlugin(plugins, "elysia").forEach((p) => p(funcRouter));
|
|
106
106
|
funcRouter[http.type](http.prefix + http.route, async (c) => {
|
|
107
107
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
108
108
|
const contextData = {
|
|
@@ -117,17 +117,17 @@ function bind(app, data, opts = {}) {
|
|
|
117
117
|
params: c.params,
|
|
118
118
|
headers: c.headers,
|
|
119
119
|
app,
|
|
120
|
-
getCookie: /* @__PURE__ */
|
|
121
|
-
setCookie: /* @__PURE__ */
|
|
120
|
+
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
|
|
121
|
+
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
|
|
122
122
|
...opts2,
|
|
123
123
|
value
|
|
124
124
|
}), "setCookie"),
|
|
125
|
-
delCookie: /* @__PURE__ */
|
|
126
|
-
redirect: /* @__PURE__ */
|
|
127
|
-
setResHeaders: /* @__PURE__ */
|
|
128
|
-
setResStatus: /* @__PURE__ */
|
|
125
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
|
|
126
|
+
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
127
|
+
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")
|
|
129
129
|
};
|
|
130
|
-
const context = new (0,
|
|
130
|
+
const context = new (0, _chunkRZ7IXJYQjs.Context)(contextData);
|
|
131
131
|
if (http.headers) c.set.headers = http.headers;
|
|
132
132
|
return context.run({
|
|
133
133
|
globalGuards,
|
|
@@ -143,13 +143,13 @@ function bind(app, data, opts = {}) {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
_chunkGHFSIZUOjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
_chunkGHFSIZUOjs.__name.call(void 0, bind, "bind");
|
|
149
149
|
function Elysia(opts) {
|
|
150
|
-
return
|
|
150
|
+
return _chunk2HVTWYS2js.Define.call(void 0, "elysia", opts);
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
_chunkGHFSIZUOjs.__name.call(void 0, Elysia, "Elysia");
|
|
153
153
|
|
|
154
154
|
|
|
155
155
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-SXOZVIKW.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-3IPYLGY2.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-UXD62LGG.mjs";
|
|
14
14
|
|
|
15
15
|
// src/server/elysia/bind.ts
|
|
16
16
|
import Debug from "debug";
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkRZ7IXJYQjs = require('../../chunk-RZ7IXJYQ.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
12
12
|
|
|
13
13
|
// src/server/express/bind.ts
|
|
14
14
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -17,14 +17,14 @@ function bind(router, data, opts = {}) {
|
|
|
17
17
|
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
19
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
20
|
-
const metaMap =
|
|
20
|
+
const metaMap = _chunkRZ7IXJYQjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
21
21
|
const { controller, http, func, tag } = meta2.data;
|
|
22
22
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
23
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
_chunkRZ7IXJYQjs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
plugins: [
|
|
29
29
|
...globalPlugins,
|
|
30
30
|
...parallelPlugins
|
|
@@ -33,29 +33,29 @@ function bind(router, data, opts = {}) {
|
|
|
33
33
|
interceptors: globalInterceptors
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
|
-
|
|
36
|
+
_chunkRZ7IXJYQjs.HMR.call(void 0, async () => {
|
|
37
37
|
router.stack = originStack;
|
|
38
38
|
registerRoute();
|
|
39
39
|
});
|
|
40
40
|
async function registerRoute() {
|
|
41
|
-
|
|
41
|
+
_chunkRZ7IXJYQjs.Context.usePlugin(globalPlugins, "express").forEach((p) => router.use(p));
|
|
42
42
|
if (parallelRoute) {
|
|
43
|
-
router.post(parallelRoute, ...
|
|
43
|
+
router.post(parallelRoute, ..._chunkRZ7IXJYQjs.Context.usePlugin(parallelPlugins, "express"), async (req, res, next) => {
|
|
44
44
|
const { body } = req;
|
|
45
45
|
async function errorHandler(e) {
|
|
46
|
-
const error = await
|
|
46
|
+
const error = await _chunkRZ7IXJYQjs.Context.filterRecord.default(e);
|
|
47
47
|
return res.status(error.status).json(error);
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
49
|
+
_chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkRZ7IXJYQjs.BadRequestException)("data format should be an array"));
|
|
51
51
|
try {
|
|
52
52
|
return Promise.all(body.map((item, i) => {
|
|
53
53
|
return new Promise(async (resolve) => {
|
|
54
54
|
const { tag, func } = item;
|
|
55
55
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
56
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
56
|
+
if (!metaMap.has(tag)) return resolve(await _chunkRZ7IXJYQjs.Context.filterRecord.default(new (0, _chunkRZ7IXJYQjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
57
57
|
const meta2 = metaMap.get(tag)[func];
|
|
58
|
-
if (!meta2) return resolve(await
|
|
58
|
+
if (!meta2) return resolve(await _chunkRZ7IXJYQjs.Context.filterRecord.default(new (0, _chunkRZ7IXJYQjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
59
|
const { data: { params } } = meta2;
|
|
60
60
|
const contextData = {
|
|
61
61
|
type: "express",
|
|
@@ -69,17 +69,17 @@ function bind(router, data, opts = {}) {
|
|
|
69
69
|
func,
|
|
70
70
|
next,
|
|
71
71
|
app: router,
|
|
72
|
-
...
|
|
73
|
-
getCookie: /* @__PURE__ */
|
|
74
|
-
setCookie: /* @__PURE__ */
|
|
75
|
-
delCookie: /* @__PURE__ */
|
|
72
|
+
..._chunkRZ7IXJYQjs.argToReq.call(void 0, params, item.args, req.headers),
|
|
73
|
+
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
74
|
+
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
|
|
75
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => res.cookie(key, "", {
|
|
76
76
|
expires: /* @__PURE__ */ new Date(0)
|
|
77
77
|
}), "delCookie"),
|
|
78
|
-
redirect: /* @__PURE__ */
|
|
79
|
-
setResHeaders: /* @__PURE__ */
|
|
80
|
-
setResStatus: /* @__PURE__ */
|
|
78
|
+
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
79
|
+
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
80
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
|
|
81
81
|
};
|
|
82
|
-
const context = new (0,
|
|
82
|
+
const context = new (0, _chunkRZ7IXJYQjs.Context)(contextData);
|
|
83
83
|
context.run({
|
|
84
84
|
globalGuards,
|
|
85
85
|
globalInterceptors,
|
|
@@ -100,7 +100,7 @@ function bind(router, data, opts = {}) {
|
|
|
100
100
|
const meta2 = metaMap.get(tag)[func];
|
|
101
101
|
const { data: { plugins, http } } = meta2;
|
|
102
102
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
103
|
-
router[http.type](http.prefix + http.route, ...
|
|
103
|
+
router[http.type](http.prefix + http.route, ..._chunkRZ7IXJYQjs.Context.usePlugin(plugins, "express"), async (req, res, next) => {
|
|
104
104
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
105
105
|
const contextData = {
|
|
106
106
|
type: "express",
|
|
@@ -116,16 +116,16 @@ function bind(router, data, opts = {}) {
|
|
|
116
116
|
headers: req.headers,
|
|
117
117
|
app: router,
|
|
118
118
|
next,
|
|
119
|
-
getCookie: /* @__PURE__ */
|
|
120
|
-
setCookie: /* @__PURE__ */
|
|
121
|
-
delCookie: /* @__PURE__ */
|
|
119
|
+
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
120
|
+
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
|
|
121
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => res.cookie(key, "", {
|
|
122
122
|
expires: /* @__PURE__ */ new Date(0)
|
|
123
123
|
}), "delCookie"),
|
|
124
|
-
redirect: /* @__PURE__ */
|
|
125
|
-
setResHeaders: /* @__PURE__ */
|
|
126
|
-
setResStatus: /* @__PURE__ */
|
|
124
|
+
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
125
|
+
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
126
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
|
|
127
127
|
};
|
|
128
|
-
const context = new (0,
|
|
128
|
+
const context = new (0, _chunkRZ7IXJYQjs.Context)(contextData);
|
|
129
129
|
if (http.headers) res.set(http.headers);
|
|
130
130
|
await context.run({
|
|
131
131
|
globalGuards,
|
|
@@ -144,9 +144,9 @@ function bind(router, data, opts = {}) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
_chunkGHFSIZUOjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
_chunkGHFSIZUOjs.__name.call(void 0, bind, "bind");
|
|
150
150
|
|
|
151
151
|
|
|
152
152
|
exports.bind = bind;
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
7
|
detectAopDep
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-3IPYLGY2.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-UXD62LGG.mjs";
|
|
12
12
|
|
|
13
13
|
// src/server/express/bind.ts
|
|
14
14
|
import Debug from "debug";
|