phecda-server 5.1.0 → 5.1.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/README.md +10 -10
- package/bin/cli.mjs +189 -189
- package/bin/schema.json +55 -55
- package/dist/{chunk-OTHER3YM.mjs → chunk-2HKQPZDT.mjs} +1 -2
- package/dist/{chunk-GHOKWS5V.js → chunk-3BV2GRS7.js} +38 -39
- package/dist/{chunk-BZP6GKM6.mjs → chunk-665MB62T.mjs} +1 -2
- package/dist/{chunk-QG4X6H5Y.js → chunk-FSBD5R22.js} +65 -66
- package/dist/{chunk-423JPSEB.js → chunk-HMPTPTFL.js} +17 -18
- package/dist/{chunk-6MQP6OHU.mjs → chunk-UU6RHGRF.mjs} +2 -3
- package/dist/{chunk-4YVAW3L4.mjs → chunk-VLV3AO3H.mjs} +0 -1
- package/dist/{chunk-Z4YJHEXT.js → chunk-ZP7HNASU.js} +0 -1
- package/dist/index.js +39 -40
- package/dist/index.mjs +4 -5
- package/dist/rpc/bullmq/index.js +12 -13
- package/dist/rpc/bullmq/index.mjs +2 -3
- package/dist/rpc/kafka/index.js +10 -11
- package/dist/rpc/kafka/index.mjs +2 -3
- package/dist/rpc/nats/index.js +11 -12
- package/dist/rpc/nats/index.mjs +2 -3
- package/dist/rpc/rabbitmq/index.js +13 -14
- package/dist/rpc/rabbitmq/index.mjs +2 -3
- package/dist/rpc/redis/index.js +11 -12
- package/dist/rpc/redis/index.mjs +2 -3
- package/dist/server/elysia/index.js +20 -21
- package/dist/server/elysia/index.mjs +3 -4
- package/dist/server/express/index.js +18 -19
- package/dist/server/express/index.mjs +2 -3
- package/dist/server/fastify/index.js +19 -20
- package/dist/server/fastify/index.mjs +3 -4
- package/dist/server/h3/index.js +16 -17
- package/dist/server/h3/index.mjs +2 -3
- package/dist/server/hono/index.js +17 -18
- package/dist/server/hono/index.mjs +2 -3
- package/dist/server/hyper-express/index.js +17 -18
- package/dist/server/hyper-express/index.mjs +2 -3
- package/dist/server/koa/index.js +18 -19
- package/dist/server/koa/index.mjs +2 -3
- package/dist/test.js +6 -7
- package/dist/test.mjs +2 -3
- package/package.json +2 -2
- package/register/index.mjs +40 -40
- package/register/loader.mjs +354 -341
- package/register/utils.mjs +81 -81
- package/dist/chunk-423JPSEB.js.map +0 -1
- package/dist/chunk-4R55T3HG.js +0 -253
- package/dist/chunk-4R55T3HG.js.map +0 -1
- package/dist/chunk-4YVAW3L4.mjs.map +0 -1
- package/dist/chunk-5DOVDDO7.mjs +0 -295
- package/dist/chunk-5DOVDDO7.mjs.map +0 -1
- package/dist/chunk-5WQ2SMIK.js +0 -295
- package/dist/chunk-5WQ2SMIK.js.map +0 -1
- package/dist/chunk-6MQP6OHU.mjs.map +0 -1
- package/dist/chunk-6Q2PCC3A.mjs +0 -295
- package/dist/chunk-6Q2PCC3A.mjs.map +0 -1
- package/dist/chunk-6UQYEBAN.js +0 -253
- package/dist/chunk-6UQYEBAN.js.map +0 -1
- package/dist/chunk-6W7CGOZC.mjs +0 -565
- package/dist/chunk-6W7CGOZC.mjs.map +0 -1
- package/dist/chunk-7Y37NSBM.js +0 -88
- package/dist/chunk-7Y37NSBM.js.map +0 -1
- package/dist/chunk-BQBSVGMG.mjs +0 -253
- package/dist/chunk-BQBSVGMG.mjs.map +0 -1
- package/dist/chunk-BZP6GKM6.mjs.map +0 -1
- package/dist/chunk-C5JAHCS2.mjs +0 -88
- package/dist/chunk-C5JAHCS2.mjs.map +0 -1
- package/dist/chunk-DTBKDALR.mjs +0 -295
- package/dist/chunk-DTBKDALR.mjs.map +0 -1
- package/dist/chunk-GHOKWS5V.js.map +0 -1
- package/dist/chunk-H4N6SHNG.mjs +0 -76
- package/dist/chunk-H4N6SHNG.mjs.map +0 -1
- package/dist/chunk-ICYHM4UM.js +0 -565
- package/dist/chunk-ICYHM4UM.js.map +0 -1
- package/dist/chunk-LOLXPM4J.mjs +0 -529
- package/dist/chunk-LOLXPM4J.mjs.map +0 -1
- package/dist/chunk-MSS6A2TU.js +0 -585
- package/dist/chunk-MSS6A2TU.js.map +0 -1
- package/dist/chunk-NEM3FY7C.mjs +0 -537
- package/dist/chunk-NEM3FY7C.mjs.map +0 -1
- package/dist/chunk-OTHER3YM.mjs.map +0 -1
- package/dist/chunk-Q2FYFIEY.js +0 -295
- package/dist/chunk-Q2FYFIEY.js.map +0 -1
- package/dist/chunk-QG4X6H5Y.js.map +0 -1
- package/dist/chunk-QIEZ6YTG.mjs +0 -295
- package/dist/chunk-QIEZ6YTG.mjs.map +0 -1
- package/dist/chunk-QOAKHCM7.js +0 -295
- package/dist/chunk-QOAKHCM7.js.map +0 -1
- package/dist/chunk-QVUD6L5X.js +0 -565
- package/dist/chunk-QVUD6L5X.js.map +0 -1
- package/dist/chunk-RGLTGKAU.js +0 -537
- package/dist/chunk-RGLTGKAU.js.map +0 -1
- package/dist/chunk-SHRK3TVB.js +0 -295
- package/dist/chunk-SHRK3TVB.js.map +0 -1
- package/dist/chunk-TCH6S42Z.js +0 -529
- package/dist/chunk-TCH6S42Z.js.map +0 -1
- package/dist/chunk-UCGRFVHC.mjs +0 -253
- package/dist/chunk-UCGRFVHC.mjs.map +0 -1
- package/dist/chunk-VOISXWVF.mjs +0 -295
- package/dist/chunk-VOISXWVF.mjs.map +0 -1
- package/dist/chunk-W6BC5INO.mjs +0 -295
- package/dist/chunk-W6BC5INO.mjs.map +0 -1
- package/dist/chunk-X5WQRO4R.js +0 -295
- package/dist/chunk-X5WQRO4R.js.map +0 -1
- package/dist/chunk-XDMCVVD3.mjs +0 -585
- package/dist/chunk-XDMCVVD3.mjs.map +0 -1
- package/dist/chunk-XNTMYLK6.js +0 -76
- package/dist/chunk-XNTMYLK6.js.map +0 -1
- package/dist/chunk-Y6LI4FDO.js +0 -537
- package/dist/chunk-Y6LI4FDO.js.map +0 -1
- package/dist/chunk-YZ2AQ6IL.mjs +0 -537
- package/dist/chunk-YZ2AQ6IL.mjs.map +0 -1
- package/dist/chunk-Z4YJHEXT.js.map +0 -1
- package/dist/chunk-ZE336SKZ.js +0 -295
- package/dist/chunk-ZE336SKZ.js.map +0 -1
- package/dist/chunk-ZJD235TO.mjs +0 -565
- package/dist/chunk-ZJD235TO.mjs.map +0 -1
- package/dist/core-930ea883.d.ts +0 -131
- package/dist/core-eb646fe5.d.ts +0 -139
- package/dist/core-fd134ffa.d.ts +0 -130
- package/dist/helper-06d25b37.d.ts +0 -19
- package/dist/helper-48454c0b.d.ts +0 -20
- package/dist/helper-73e8d2f0.d.ts +0 -18
- package/dist/helper-867a598d.d.ts +0 -18
- package/dist/helper-88b19c66.d.ts +0 -12
- package/dist/helper-9e206c66.d.ts +0 -12
- package/dist/helper-f29f082f.d.ts +0 -19
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/rpc/bullmq/index.js.map +0 -1
- package/dist/rpc/bullmq/index.mjs.map +0 -1
- package/dist/rpc/kafka/index.js.map +0 -1
- package/dist/rpc/kafka/index.mjs.map +0 -1
- package/dist/rpc/nats/index.js.map +0 -1
- package/dist/rpc/nats/index.mjs.map +0 -1
- package/dist/rpc/rabbitmq/index.js.map +0 -1
- package/dist/rpc/rabbitmq/index.mjs.map +0 -1
- package/dist/rpc/redis/index.js.map +0 -1
- package/dist/rpc/redis/index.mjs.map +0 -1
- package/dist/server/elysia/index.js.map +0 -1
- package/dist/server/elysia/index.mjs.map +0 -1
- package/dist/server/express/index.js.map +0 -1
- package/dist/server/express/index.mjs.map +0 -1
- package/dist/server/fastify/index.js.map +0 -1
- package/dist/server/fastify/index.mjs.map +0 -1
- package/dist/server/h3/index.js.map +0 -1
- package/dist/server/h3/index.mjs.map +0 -1
- package/dist/server/hono/index.js.map +0 -1
- package/dist/server/hono/index.mjs.map +0 -1
- package/dist/server/hyper-express/index.js.map +0 -1
- package/dist/server/hyper-express/index.mjs.map +0 -1
- package/dist/server/koa/index.js.map +0 -1
- package/dist/server/koa/index.mjs.map +0 -1
- package/dist/test.js.map +0 -1
- package/dist/test.mjs.map +0 -1
package/dist/server/h3/index.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkFSBD5R22js = require('../../chunk-FSBD5R22.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkZP7HNASUjs = require('../../chunk-ZP7HNASU.js');
|
|
11
11
|
|
|
12
12
|
// src/server/h3/bind.ts
|
|
13
13
|
var _h3 = require('h3');
|
|
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/h3");
|
|
|
16
16
|
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
|
-
const metaMap =
|
|
19
|
+
const metaMap = _chunkFSBD5R22js.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
20
20
|
const { controller, http, func, tag } = meta2.data;
|
|
21
21
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
22
22
|
debug(`register method "${func}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
_chunkFSBD5R22js.detectAopDep.call(void 0, meta, {
|
|
27
27
|
plugins: [
|
|
28
28
|
...globalPlugins,
|
|
29
29
|
...parallelPlugins
|
|
@@ -35,7 +35,7 @@ function bind(router, data, opts = {}) {
|
|
|
35
35
|
async function registerRoute() {
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
router.post(parallelRoute, _h3.eventHandler.call(void 0, {
|
|
38
|
-
onRequest:
|
|
38
|
+
onRequest: _chunkFSBD5R22js.Context.usePlugin([
|
|
39
39
|
...globalPlugins,
|
|
40
40
|
...parallelPlugins
|
|
41
41
|
], "h3").map(_h3.defineRequestMiddleware),
|
|
@@ -44,23 +44,23 @@ function bind(router, data, opts = {}) {
|
|
|
44
44
|
strict: true
|
|
45
45
|
});
|
|
46
46
|
async function errorHandler(e) {
|
|
47
|
-
const error = await
|
|
47
|
+
const error = await _chunkFSBD5R22js.Context.filterRecord.default(e);
|
|
48
48
|
_h3.setResponseStatus.call(void 0, event, error.status);
|
|
49
49
|
return error;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
_chunkZP7HNASUjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
52
52
|
if (!Array.isArray(body))
|
|
53
|
-
return errorHandler(new (0,
|
|
53
|
+
return errorHandler(new (0, _chunkFSBD5R22js.BadRequestException)("data format should be an array"));
|
|
54
54
|
try {
|
|
55
55
|
return Promise.all(body.map((item, i) => {
|
|
56
56
|
return new Promise(async (resolve) => {
|
|
57
57
|
const { tag, func } = item;
|
|
58
58
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
59
59
|
if (!metaMap.has(tag))
|
|
60
|
-
return resolve(await
|
|
60
|
+
return resolve(await _chunkFSBD5R22js.Context.filterRecord.default(new (0, _chunkFSBD5R22js.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
61
61
|
const meta2 = metaMap.get(tag)[func];
|
|
62
62
|
if (!meta2)
|
|
63
|
-
return resolve(await
|
|
63
|
+
return resolve(await _chunkFSBD5R22js.Context.filterRecord.default(new (0, _chunkFSBD5R22js.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
64
64
|
const { data: { params } } = meta2;
|
|
65
65
|
const contextData = {
|
|
66
66
|
type: "h3",
|
|
@@ -72,9 +72,9 @@ function bind(router, data, opts = {}) {
|
|
|
72
72
|
func,
|
|
73
73
|
parallel: true,
|
|
74
74
|
app: router,
|
|
75
|
-
...
|
|
75
|
+
..._chunkFSBD5R22js.argToReq.call(void 0, params, item.args, _h3.getRequestHeaders.call(void 0, event))
|
|
76
76
|
};
|
|
77
|
-
const context = new (0,
|
|
77
|
+
const context = new (0, _chunkFSBD5R22js.Context)(contextData);
|
|
78
78
|
context.run({
|
|
79
79
|
globalGuards,
|
|
80
80
|
globalInterceptors,
|
|
@@ -97,7 +97,7 @@ function bind(router, data, opts = {}) {
|
|
|
97
97
|
continue;
|
|
98
98
|
const needBody = params.some((item) => item.type === "body");
|
|
99
99
|
router[http.type](http.prefix + http.route, _h3.eventHandler.call(void 0, {
|
|
100
|
-
onRequest:
|
|
100
|
+
onRequest: _chunkFSBD5R22js.Context.usePlugin([
|
|
101
101
|
...globalPlugins,
|
|
102
102
|
...plugins
|
|
103
103
|
], "h3").map(_h3.defineRequestMiddleware),
|
|
@@ -118,7 +118,7 @@ function bind(router, data, opts = {}) {
|
|
|
118
118
|
strict: true
|
|
119
119
|
}) : void 0
|
|
120
120
|
};
|
|
121
|
-
const context = new (0,
|
|
121
|
+
const context = new (0, _chunkFSBD5R22js.Context)(contextData);
|
|
122
122
|
_h3.setHeaders.call(void 0, event, http.headers || {});
|
|
123
123
|
return context.run({
|
|
124
124
|
globalGuards,
|
|
@@ -134,10 +134,9 @@ function bind(router, data, opts = {}) {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
_chunkZP7HNASUjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
_chunkZP7HNASUjs.__name.call(void 0, bind, "bind");
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
exports.bind = bind;
|
|
143
|
-
//# sourceMappingURL=index.js.map
|
package/dist/server/h3/index.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-665MB62T.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-VLV3AO3H.mjs";
|
|
11
11
|
|
|
12
12
|
// src/server/h3/bind.ts
|
|
13
13
|
import { defineRequestMiddleware, eventHandler, getQuery, getRequestHeaders, getRouterParams, readBody, setHeaders, setResponseStatus } from "h3";
|
|
@@ -140,4 +140,3 @@ __name(bind, "bind");
|
|
|
140
140
|
export {
|
|
141
141
|
bind
|
|
142
142
|
};
|
|
143
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkFSBD5R22js = require('../../chunk-FSBD5R22.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkZP7HNASUjs = require('../../chunk-ZP7HNASU.js');
|
|
11
11
|
|
|
12
12
|
// src/server/hono/bind.ts
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -15,14 +15,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hono");
|
|
|
15
15
|
function bind(router, data, opts = {}) {
|
|
16
16
|
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
17
17
|
const { moduleMap, meta } = data;
|
|
18
|
-
const metaMap =
|
|
18
|
+
const metaMap = _chunkFSBD5R22js.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
19
19
|
const { controller, http, func, tag } = meta2.data;
|
|
20
20
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
21
21
|
debug(`register method "${func}" in module "${tag}"`);
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
_chunkFSBD5R22js.detectAopDep.call(void 0, meta, {
|
|
26
26
|
plugins: [
|
|
27
27
|
...globalPlugins,
|
|
28
28
|
...parallelPlugins
|
|
@@ -32,28 +32,28 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
async function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunkFSBD5R22js.Context.usePlugin(globalPlugins, "hono").forEach((p) => router.use(p));
|
|
36
36
|
if (parallelRoute) {
|
|
37
|
-
router.post(parallelRoute, ...
|
|
37
|
+
router.post(parallelRoute, ..._chunkFSBD5R22js.Context.usePlugin(parallelPlugins, "hono"), async (c) => {
|
|
38
38
|
const body = await c.req.json();
|
|
39
39
|
async function errorHandler(e) {
|
|
40
|
-
const error = await
|
|
40
|
+
const error = await _chunkFSBD5R22js.Context.filterRecord.default(e);
|
|
41
41
|
c.status(error.status);
|
|
42
42
|
return c.json(error);
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
_chunkZP7HNASUjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
45
45
|
if (!Array.isArray(body))
|
|
46
|
-
return errorHandler(new (0,
|
|
46
|
+
return errorHandler(new (0, _chunkFSBD5R22js.BadRequestException)("data format should be an array"));
|
|
47
47
|
try {
|
|
48
48
|
return Promise.all(body.map((item, i) => {
|
|
49
49
|
return new Promise(async (resolve) => {
|
|
50
50
|
const { tag, func } = item;
|
|
51
51
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
52
52
|
if (!metaMap.has(tag))
|
|
53
|
-
return resolve(await
|
|
53
|
+
return resolve(await _chunkFSBD5R22js.Context.filterRecord.default(new (0, _chunkFSBD5R22js.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
54
54
|
const meta2 = metaMap.get(tag)[func];
|
|
55
55
|
if (!meta2)
|
|
56
|
-
return resolve(await
|
|
56
|
+
return resolve(await _chunkFSBD5R22js.Context.filterRecord.default(new (0, _chunkFSBD5R22js.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
57
57
|
const { data: { params } } = meta2;
|
|
58
58
|
const contextData = {
|
|
59
59
|
type: "hono",
|
|
@@ -65,9 +65,9 @@ function bind(router, data, opts = {}) {
|
|
|
65
65
|
tag,
|
|
66
66
|
func,
|
|
67
67
|
app: router,
|
|
68
|
-
...
|
|
68
|
+
..._chunkFSBD5R22js.argToReq.call(void 0, params, item.args, c.req.header())
|
|
69
69
|
};
|
|
70
|
-
const context = new (0,
|
|
70
|
+
const context = new (0, _chunkFSBD5R22js.Context)(contextData);
|
|
71
71
|
context.run({
|
|
72
72
|
globalGuards,
|
|
73
73
|
globalInterceptors,
|
|
@@ -90,7 +90,7 @@ function bind(router, data, opts = {}) {
|
|
|
90
90
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
|
|
91
91
|
continue;
|
|
92
92
|
const needBody = params.some((item) => item.type === "body");
|
|
93
|
-
router[http.type](http.prefix + http.route, ...
|
|
93
|
+
router[http.type](http.prefix + http.route, ..._chunkFSBD5R22js.Context.usePlugin(plugins, "hono"), async (c) => {
|
|
94
94
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
95
95
|
const contextData = {
|
|
96
96
|
type: "hono",
|
|
@@ -105,7 +105,7 @@ function bind(router, data, opts = {}) {
|
|
|
105
105
|
headers: c.req.header(),
|
|
106
106
|
app: router
|
|
107
107
|
};
|
|
108
|
-
const context = new (0,
|
|
108
|
+
const context = new (0, _chunkFSBD5R22js.Context)(contextData);
|
|
109
109
|
if (http.headers) {
|
|
110
110
|
for (const name in http.headers)
|
|
111
111
|
c.header(name, http.headers[name]);
|
|
@@ -130,10 +130,9 @@ function bind(router, data, opts = {}) {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
_chunkZP7HNASUjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
_chunkZP7HNASUjs.__name.call(void 0, bind, "bind");
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
exports.bind = bind;
|
|
139
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-665MB62T.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-VLV3AO3H.mjs";
|
|
11
11
|
|
|
12
12
|
// src/server/hono/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
@@ -136,4 +136,3 @@ __name(bind, "bind");
|
|
|
136
136
|
export {
|
|
137
137
|
bind
|
|
138
138
|
};
|
|
139
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkFSBD5R22js = require('../../chunk-FSBD5R22.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkZP7HNASUjs = require('../../chunk-ZP7HNASU.js');
|
|
11
11
|
|
|
12
12
|
// src/server/hyper-express/bind.ts
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -15,14 +15,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hyper-express");
|
|
|
15
15
|
function bind(router, data, opts = {}) {
|
|
16
16
|
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
17
17
|
const { moduleMap, meta } = data;
|
|
18
|
-
const metaMap =
|
|
18
|
+
const metaMap = _chunkFSBD5R22js.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
19
19
|
const { controller, http, func, tag } = meta2.data;
|
|
20
20
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
21
21
|
debug(`register method "${func}" in module "${tag}"`);
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
_chunkFSBD5R22js.detectAopDep.call(void 0, meta, {
|
|
26
26
|
plugins: [
|
|
27
27
|
...globalPlugins,
|
|
28
28
|
...parallelPlugins
|
|
@@ -32,29 +32,29 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
async function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunkFSBD5R22js.Context.usePlugin(globalPlugins, "hyper-express").forEach((p) => router.use(p));
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
router.post(parallelRoute, {
|
|
38
|
-
middlewares:
|
|
38
|
+
middlewares: _chunkFSBD5R22js.Context.usePlugin(parallelPlugins, "hyper-express")
|
|
39
39
|
}, async (req, res, next) => {
|
|
40
40
|
const body = await req.json();
|
|
41
41
|
async function errorHandler(e) {
|
|
42
|
-
const error = await
|
|
42
|
+
const error = await _chunkFSBD5R22js.Context.filterRecord.default(e);
|
|
43
43
|
return res.status(error.status).json(error);
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
_chunkZP7HNASUjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
46
|
if (!Array.isArray(body))
|
|
47
|
-
return errorHandler(new (0,
|
|
47
|
+
return errorHandler(new (0, _chunkFSBD5R22js.BadRequestException)("data format should be an array"));
|
|
48
48
|
try {
|
|
49
49
|
return Promise.all(body.map((item, i) => {
|
|
50
50
|
return new Promise(async (resolve) => {
|
|
51
51
|
const { tag, func } = item;
|
|
52
52
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
53
53
|
if (!metaMap.has(tag))
|
|
54
|
-
return resolve(await
|
|
54
|
+
return resolve(await _chunkFSBD5R22js.Context.filterRecord.default(new (0, _chunkFSBD5R22js.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
55
55
|
const meta2 = metaMap.get(tag)[func];
|
|
56
56
|
if (!meta2)
|
|
57
|
-
return resolve(await
|
|
57
|
+
return resolve(await _chunkFSBD5R22js.Context.filterRecord.default(new (0, _chunkFSBD5R22js.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
58
58
|
const { data: { params } } = meta2;
|
|
59
59
|
const contextData = {
|
|
60
60
|
type: "hyper-express",
|
|
@@ -68,9 +68,9 @@ function bind(router, data, opts = {}) {
|
|
|
68
68
|
func,
|
|
69
69
|
next,
|
|
70
70
|
app: router,
|
|
71
|
-
...
|
|
71
|
+
..._chunkFSBD5R22js.argToReq.call(void 0, params, item.args, req.headers)
|
|
72
72
|
};
|
|
73
|
-
const context = new (0,
|
|
73
|
+
const context = new (0, _chunkFSBD5R22js.Context)(contextData);
|
|
74
74
|
context.run({
|
|
75
75
|
globalGuards,
|
|
76
76
|
globalInterceptors,
|
|
@@ -93,7 +93,7 @@ function bind(router, data, opts = {}) {
|
|
|
93
93
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
|
|
94
94
|
continue;
|
|
95
95
|
const needBody = params.some((item) => item.type === "body");
|
|
96
|
-
router[http.type](http.prefix + http.route, ...
|
|
96
|
+
router[http.type](http.prefix + http.route, ..._chunkFSBD5R22js.Context.usePlugin(plugins, "hyper-express"), async (req, res, next) => {
|
|
97
97
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
98
98
|
const contextData = {
|
|
99
99
|
type: "hyper-express",
|
|
@@ -110,7 +110,7 @@ function bind(router, data, opts = {}) {
|
|
|
110
110
|
headers: req.headers,
|
|
111
111
|
next
|
|
112
112
|
};
|
|
113
|
-
const context = new (0,
|
|
113
|
+
const context = new (0, _chunkFSBD5R22js.Context)(contextData);
|
|
114
114
|
if (http.headers) {
|
|
115
115
|
for (const name in http.headers)
|
|
116
116
|
res.set(name, http.headers[name]);
|
|
@@ -136,10 +136,9 @@ function bind(router, data, opts = {}) {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
_chunkZP7HNASUjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
_chunkZP7HNASUjs.__name.call(void 0, bind, "bind");
|
|
142
142
|
|
|
143
143
|
|
|
144
144
|
exports.bind = bind;
|
|
145
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-665MB62T.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-VLV3AO3H.mjs";
|
|
11
11
|
|
|
12
12
|
// src/server/hyper-express/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
@@ -142,4 +142,3 @@ __name(bind, "bind");
|
|
|
142
142
|
export {
|
|
143
143
|
bind
|
|
144
144
|
};
|
|
145
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/server/koa/index.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkFSBD5R22js = require('../../chunk-FSBD5R22.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkZP7HNASUjs = require('../../chunk-ZP7HNASU.js');
|
|
12
12
|
|
|
13
13
|
// src/server/koa/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 = _chunkFSBD5R22js.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
|
+
_chunkFSBD5R22js.detectAopDep.call(void 0, meta, {
|
|
28
28
|
plugins: [
|
|
29
29
|
...globalPlugins,
|
|
30
30
|
...parallelPlugins
|
|
@@ -34,28 +34,28 @@ function bind(router, data, opts = {}) {
|
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
36
|
async function registerRoute() {
|
|
37
|
-
|
|
37
|
+
_chunkFSBD5R22js.Context.usePlugin(globalPlugins, "koa").forEach((p) => router.use(p));
|
|
38
38
|
if (parallelRoute) {
|
|
39
|
-
router.post(parallelRoute, ...
|
|
39
|
+
router.post(parallelRoute, ..._chunkFSBD5R22js.Context.usePlugin(parallelPlugins, "koa"), async (ctx, next) => {
|
|
40
40
|
const { body } = ctx.request;
|
|
41
41
|
async function errorHandler(e) {
|
|
42
|
-
const error = await
|
|
42
|
+
const error = await _chunkFSBD5R22js.Context.filterRecord.default(e);
|
|
43
43
|
ctx.status = error.status;
|
|
44
44
|
ctx.body = error;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
_chunkZP7HNASUjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
47
|
if (!Array.isArray(body))
|
|
48
|
-
return errorHandler(new (0,
|
|
48
|
+
return errorHandler(new (0, _chunkFSBD5R22js.BadRequestException)("data format should be an array"));
|
|
49
49
|
try {
|
|
50
50
|
return Promise.all(body.map((item, i) => {
|
|
51
51
|
return new Promise(async (resolve) => {
|
|
52
52
|
const { tag, func } = item;
|
|
53
53
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
54
54
|
if (!metaMap.has(tag))
|
|
55
|
-
return resolve(await
|
|
55
|
+
return resolve(await _chunkFSBD5R22js.Context.filterRecord.default(new (0, _chunkFSBD5R22js.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
56
56
|
const meta2 = metaMap.get(tag)[func];
|
|
57
57
|
if (!meta2)
|
|
58
|
-
return resolve(await
|
|
58
|
+
return resolve(await _chunkFSBD5R22js.Context.filterRecord.default(new (0, _chunkFSBD5R22js.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
59
|
const { data: { params } } = meta2;
|
|
60
60
|
const contextData = {
|
|
61
61
|
type: "koa",
|
|
@@ -66,11 +66,11 @@ function bind(router, data, opts = {}) {
|
|
|
66
66
|
parallel: true,
|
|
67
67
|
next,
|
|
68
68
|
app: router,
|
|
69
|
-
...
|
|
69
|
+
..._chunkFSBD5R22js.argToReq.call(void 0, params, item.args, ctx.headers),
|
|
70
70
|
tag,
|
|
71
71
|
func
|
|
72
72
|
};
|
|
73
|
-
const context = new (0,
|
|
73
|
+
const context = new (0, _chunkFSBD5R22js.Context)(contextData);
|
|
74
74
|
context.run({
|
|
75
75
|
globalGuards,
|
|
76
76
|
globalInterceptors,
|
|
@@ -92,7 +92,7 @@ function bind(router, data, opts = {}) {
|
|
|
92
92
|
const { data: { plugins, http } } = meta2;
|
|
93
93
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
|
|
94
94
|
continue;
|
|
95
|
-
router[http.type](http.prefix + http.route, ...
|
|
95
|
+
router[http.type](http.prefix + http.route, ..._chunkFSBD5R22js.Context.usePlugin(plugins, "koa"), async (ctx, next) => {
|
|
96
96
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
97
97
|
const contextData = {
|
|
98
98
|
type: "koa",
|
|
@@ -108,7 +108,7 @@ function bind(router, data, opts = {}) {
|
|
|
108
108
|
headers: ctx.headers,
|
|
109
109
|
next
|
|
110
110
|
};
|
|
111
|
-
const context = new (0,
|
|
111
|
+
const context = new (0, _chunkFSBD5R22js.Context)(contextData);
|
|
112
112
|
if (http.headers) {
|
|
113
113
|
for (const name in http.headers)
|
|
114
114
|
ctx.set(name, http.headers[name]);
|
|
@@ -132,14 +132,13 @@ function bind(router, data, opts = {}) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
_chunkZP7HNASUjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
136
|
+
_chunkFSBD5R22js.HMR.call(void 0, async () => {
|
|
137
137
|
router.stack = originStack;
|
|
138
138
|
registerRoute();
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
_chunkZP7HNASUjs.__name.call(void 0, bind, "bind");
|
|
142
142
|
|
|
143
143
|
|
|
144
144
|
exports.bind = bind;
|
|
145
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
7
|
detectAopDep
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-665MB62T.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-VLV3AO3H.mjs";
|
|
12
12
|
|
|
13
13
|
// src/server/koa/bind.ts
|
|
14
14
|
import Debug from "debug";
|
|
@@ -142,4 +142,3 @@ __name(bind, "bind");
|
|
|
142
142
|
export {
|
|
143
143
|
bind
|
|
144
144
|
};
|
|
145
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/test.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkHMPTPTFLjs = require('./chunk-HMPTPTFL.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkZP7HNASUjs = require('./chunk-ZP7HNASU.js');
|
|
7
7
|
|
|
8
8
|
// src/test.ts
|
|
9
9
|
var _phecdacore = require('phecda-core');
|
|
10
10
|
async function TestFactory(...Modules) {
|
|
11
|
-
const { moduleMap, constructorMap } = await
|
|
11
|
+
const { moduleMap, constructorMap } = await _chunkHMPTPTFLjs.Factory.call(void 0, Modules);
|
|
12
12
|
return {
|
|
13
13
|
get(Module) {
|
|
14
14
|
const tag = _phecdacore.getTag.call(void 0, Module);
|
|
@@ -21,7 +21,7 @@ async function TestFactory(...Modules) {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
_chunkZP7HNASUjs.__name.call(void 0, TestFactory, "TestFactory");
|
|
25
25
|
async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
26
26
|
const { default: request, agent } = await Promise.resolve().then(() => require("supertest"));
|
|
27
27
|
const Agent = agent(app);
|
|
@@ -67,13 +67,12 @@ async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
_chunkZP7HNASUjs.__name.call(void 0, module, "module");
|
|
71
71
|
Agent.module = module;
|
|
72
72
|
return Agent;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
_chunkZP7HNASUjs.__name.call(void 0, TestHttp, "TestHttp");
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
exports.TestFactory = TestFactory; exports.TestHttp = TestHttp;
|
|
79
|
-
//# sourceMappingURL=test.js.map
|
package/dist/test.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Factory
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2HKQPZDT.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VLV3AO3H.mjs";
|
|
7
7
|
|
|
8
8
|
// src/test.ts
|
|
9
9
|
import { getTag } from "phecda-core";
|
|
@@ -76,4 +76,3 @@ export {
|
|
|
76
76
|
TestFactory,
|
|
77
77
|
TestHttp
|
|
78
78
|
};
|
|
79
|
-
//# sourceMappingURL=test.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"nats": "^2.22.0",
|
|
157
157
|
"supertest": "^6.3.3",
|
|
158
158
|
"tsup": "^6.5.0",
|
|
159
|
-
"typescript": "^5.
|
|
159
|
+
"typescript": "^5.4.5",
|
|
160
160
|
"unimport": "^3.7.1"
|
|
161
161
|
},
|
|
162
162
|
"dependencies": {
|