phecda-server 5.0.2 → 5.1.0
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 -108
- package/bin/cli.mjs +189 -186
- package/bin/schema.json +55 -55
- package/dist/{chunk-F5YWXY5W.js → chunk-423JPSEB.js} +18 -17
- package/dist/chunk-423JPSEB.js.map +1 -0
- package/dist/chunk-4R55T3HG.js +253 -0
- package/dist/chunk-4R55T3HG.js.map +1 -0
- package/dist/chunk-4YVAW3L4.mjs +76 -0
- package/dist/chunk-4YVAW3L4.mjs.map +1 -0
- package/dist/{chunk-W5EOVGQD.mjs → chunk-5DOVDDO7.mjs} +3 -2
- package/dist/chunk-5DOVDDO7.mjs.map +1 -0
- package/dist/{chunk-BXLBWRHS.js → chunk-5WQ2SMIK.js} +39 -38
- package/dist/chunk-5WQ2SMIK.js.map +1 -0
- package/dist/chunk-6MQP6OHU.mjs +295 -0
- package/dist/chunk-6MQP6OHU.mjs.map +1 -0
- package/dist/chunk-6Q2PCC3A.mjs +295 -0
- package/dist/chunk-6Q2PCC3A.mjs.map +1 -0
- package/dist/chunk-6UQYEBAN.js +253 -0
- package/dist/chunk-6UQYEBAN.js.map +1 -0
- package/dist/chunk-6W7CGOZC.mjs +565 -0
- package/dist/chunk-6W7CGOZC.mjs.map +1 -0
- package/dist/{chunk-YR5Q5F2K.js → chunk-7Y37NSBM.js} +1 -0
- package/dist/chunk-7Y37NSBM.js.map +1 -0
- package/dist/{chunk-RCTOVYZY.mjs → chunk-BQBSVGMG.mjs} +2 -1
- package/dist/chunk-BQBSVGMG.mjs.map +1 -0
- package/dist/chunk-BZP6GKM6.mjs +565 -0
- package/dist/chunk-BZP6GKM6.mjs.map +1 -0
- package/dist/{chunk-ITTD2GBR.mjs → chunk-C5JAHCS2.mjs} +1 -0
- package/dist/chunk-C5JAHCS2.mjs.map +1 -0
- package/dist/chunk-DTBKDALR.mjs +295 -0
- package/dist/chunk-DTBKDALR.mjs.map +1 -0
- package/dist/chunk-GHOKWS5V.js +295 -0
- package/dist/chunk-GHOKWS5V.js.map +1 -0
- package/dist/chunk-H4N6SHNG.mjs +76 -0
- package/dist/chunk-H4N6SHNG.mjs.map +1 -0
- package/dist/chunk-ICYHM4UM.js +565 -0
- package/dist/chunk-ICYHM4UM.js.map +1 -0
- package/dist/chunk-LOLXPM4J.mjs +529 -0
- package/dist/chunk-LOLXPM4J.mjs.map +1 -0
- package/dist/chunk-MSS6A2TU.js +585 -0
- package/dist/chunk-MSS6A2TU.js.map +1 -0
- package/dist/{chunk-AB4OX3WV.mjs → chunk-NEM3FY7C.mjs} +2 -1
- package/dist/chunk-NEM3FY7C.mjs.map +1 -0
- package/dist/chunk-OTHER3YM.mjs +253 -0
- package/dist/chunk-OTHER3YM.mjs.map +1 -0
- package/dist/chunk-Q2FYFIEY.js +295 -0
- package/dist/chunk-Q2FYFIEY.js.map +1 -0
- package/dist/chunk-QG4X6H5Y.js +565 -0
- package/dist/chunk-QG4X6H5Y.js.map +1 -0
- package/dist/chunk-QIEZ6YTG.mjs +295 -0
- package/dist/chunk-QIEZ6YTG.mjs.map +1 -0
- package/dist/chunk-QOAKHCM7.js +295 -0
- package/dist/chunk-QOAKHCM7.js.map +1 -0
- package/dist/chunk-QVUD6L5X.js +565 -0
- package/dist/chunk-QVUD6L5X.js.map +1 -0
- package/dist/{chunk-YERBWZCS.js → chunk-RGLTGKAU.js} +64 -63
- package/dist/chunk-RGLTGKAU.js.map +1 -0
- package/dist/chunk-SHRK3TVB.js +295 -0
- package/dist/chunk-SHRK3TVB.js.map +1 -0
- package/dist/chunk-TCH6S42Z.js +529 -0
- package/dist/chunk-TCH6S42Z.js.map +1 -0
- package/dist/chunk-UCGRFVHC.mjs +253 -0
- package/dist/chunk-UCGRFVHC.mjs.map +1 -0
- package/dist/chunk-VOISXWVF.mjs +295 -0
- package/dist/chunk-VOISXWVF.mjs.map +1 -0
- package/dist/chunk-W6BC5INO.mjs +295 -0
- package/dist/chunk-W6BC5INO.mjs.map +1 -0
- package/dist/chunk-X5WQRO4R.js +295 -0
- package/dist/chunk-X5WQRO4R.js.map +1 -0
- package/dist/chunk-XDMCVVD3.mjs +585 -0
- package/dist/chunk-XDMCVVD3.mjs.map +1 -0
- package/dist/chunk-XNTMYLK6.js +76 -0
- package/dist/chunk-XNTMYLK6.js.map +1 -0
- package/dist/chunk-Y6LI4FDO.js +537 -0
- package/dist/chunk-Y6LI4FDO.js.map +1 -0
- package/dist/chunk-YZ2AQ6IL.mjs +537 -0
- package/dist/chunk-YZ2AQ6IL.mjs.map +1 -0
- package/dist/chunk-Z4YJHEXT.js +76 -0
- package/dist/chunk-Z4YJHEXT.js.map +1 -0
- package/dist/chunk-ZE336SKZ.js +295 -0
- package/dist/chunk-ZE336SKZ.js.map +1 -0
- package/dist/chunk-ZJD235TO.mjs +565 -0
- package/dist/chunk-ZJD235TO.mjs.map +1 -0
- package/dist/core-39f27fe8.d.ts +131 -0
- package/dist/core-930ea883.d.ts +131 -0
- package/dist/core-eb646fe5.d.ts +139 -0
- package/dist/helper-06d25b37.d.ts +19 -0
- package/dist/helper-48454c0b.d.ts +20 -0
- package/dist/helper-6133f78f.d.ts +18 -0
- package/dist/helper-867a598d.d.ts +18 -0
- package/dist/helper-88b19c66.d.ts +12 -0
- package/dist/helper-9e206c66.d.ts +12 -0
- package/dist/helper-fcbf6aa8.d.ts +20 -0
- package/dist/index.d.ts +27 -32
- package/dist/index.js +45 -40
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +15 -10
- package/dist/index.mjs.map +1 -0
- package/dist/rpc/bullmq/index.d.ts +10 -6
- package/dist/rpc/bullmq/index.js +33 -53
- package/dist/rpc/bullmq/index.js.map +1 -0
- package/dist/rpc/bullmq/index.mjs +27 -47
- package/dist/rpc/bullmq/index.mjs.map +1 -0
- package/dist/rpc/kafka/index.d.ts +10 -4
- package/dist/rpc/kafka/index.js +21 -37
- package/dist/rpc/kafka/index.js.map +1 -0
- package/dist/rpc/kafka/index.mjs +16 -32
- package/dist/rpc/kafka/index.mjs.map +1 -0
- package/dist/rpc/nats/index.d.ts +2 -2
- package/dist/rpc/nats/index.js +21 -34
- package/dist/rpc/nats/index.js.map +1 -0
- package/dist/rpc/nats/index.mjs +14 -27
- package/dist/rpc/nats/index.mjs.map +1 -0
- package/dist/rpc/rabbitmq/index.d.ts +2 -2
- package/dist/rpc/rabbitmq/index.js +24 -37
- package/dist/rpc/rabbitmq/index.js.map +1 -0
- package/dist/rpc/rabbitmq/index.mjs +15 -28
- package/dist/rpc/rabbitmq/index.mjs.map +1 -0
- package/dist/rpc/redis/index.d.ts +10 -4
- package/dist/rpc/redis/index.js +24 -37
- package/dist/rpc/redis/index.js.map +1 -0
- package/dist/rpc/redis/index.mjs +17 -30
- package/dist/rpc/redis/index.mjs.map +1 -0
- package/dist/server/elysia/index.d.ts +4 -3
- package/dist/server/elysia/index.js +78 -94
- package/dist/server/elysia/index.js.map +1 -0
- package/dist/server/elysia/index.mjs +75 -91
- package/dist/server/elysia/index.mjs.map +1 -0
- package/dist/server/express/index.d.ts +5 -4
- package/dist/server/express/index.js +80 -93
- package/dist/server/express/index.js.map +1 -0
- package/dist/server/express/index.mjs +78 -91
- package/dist/server/express/index.mjs.map +1 -0
- package/dist/server/fastify/index.d.ts +8 -5
- package/dist/server/fastify/index.js +84 -102
- package/dist/server/fastify/index.js.map +1 -0
- package/dist/server/fastify/index.mjs +80 -98
- package/dist/server/fastify/index.mjs.map +1 -0
- package/dist/server/h3/index.d.ts +5 -4
- package/dist/server/h3/index.js +82 -97
- package/dist/server/h3/index.js.map +1 -0
- package/dist/server/h3/index.mjs +81 -96
- package/dist/server/h3/index.mjs.map +1 -0
- package/dist/server/hono/index.d.ts +5 -4
- package/dist/server/hono/index.js +74 -90
- package/dist/server/hono/index.js.map +1 -0
- package/dist/server/hono/index.mjs +73 -89
- package/dist/server/hono/index.mjs.map +1 -0
- package/dist/server/hyper-express/index.d.ts +6 -5
- package/dist/server/hyper-express/index.js +79 -96
- package/dist/server/hyper-express/index.js.map +1 -0
- package/dist/server/hyper-express/index.mjs +78 -95
- package/dist/server/hyper-express/index.mjs.map +1 -0
- package/dist/server/koa/index.d.ts +5 -4
- package/dist/server/koa/index.js +80 -92
- package/dist/server/koa/index.js.map +1 -0
- package/dist/server/koa/index.mjs +77 -89
- package/dist/server/koa/index.mjs.map +1 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +7 -6
- package/dist/test.js.map +1 -0
- package/dist/test.mjs +3 -2
- package/dist/test.mjs.map +1 -0
- package/package.json +8 -7
- package/register/index.mjs +40 -40
- package/register/loader.mjs +341 -340
- package/register/utils.mjs +81 -81
package/dist/server/koa/index.js
CHANGED
|
@@ -4,95 +4,95 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var _chunkYERBWZCSjs = require('../../chunk-YERBWZCS.js');
|
|
8
7
|
|
|
8
|
+
var _chunkQG4X6H5Yjs = require('../../chunk-QG4X6H5Y.js');
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
var _chunkXNTMYLK6js = require('../../chunk-XNTMYLK6.js');
|
|
11
12
|
|
|
12
13
|
// src/server/koa/bind.ts
|
|
13
14
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
14
15
|
var debug = _debug2.default.call(void 0, "phecda-server/koa");
|
|
15
|
-
function bind(router,
|
|
16
|
-
const { globalGuards, globalInterceptors,
|
|
17
|
-
|
|
18
|
-
plugins: [],
|
|
19
|
-
...opts
|
|
20
|
-
};
|
|
16
|
+
function bind(router, data, opts = {}) {
|
|
17
|
+
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
18
|
+
const { moduleMap, meta } = data;
|
|
21
19
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
22
|
-
const metaMap =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for (const item of meta) {
|
|
26
|
-
const { tag, func, controller, http } = item.data;
|
|
27
|
-
if (controller !== "http" || !_optionalChain([http, 'optionalAccess', _ => _.type]))
|
|
28
|
-
continue;
|
|
20
|
+
const metaMap = _chunkQG4X6H5Yjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
21
|
+
const { controller, http, func, tag } = meta2.data;
|
|
22
|
+
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
29
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
30
|
-
|
|
31
|
-
metaMap.get(tag)[func] = item;
|
|
32
|
-
else
|
|
33
|
-
metaMap.set(tag, {
|
|
34
|
-
[func]: item
|
|
35
|
-
});
|
|
24
|
+
return true;
|
|
36
25
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
26
|
+
});
|
|
27
|
+
_chunkQG4X6H5Yjs.detectAopDep.call(void 0, meta, {
|
|
28
|
+
plugins: [
|
|
29
|
+
...globalPlugins,
|
|
30
|
+
...parallelPlugins
|
|
31
|
+
],
|
|
32
|
+
guards: globalGuards,
|
|
33
|
+
interceptors: globalInterceptors
|
|
34
|
+
});
|
|
35
|
+
registerRoute();
|
|
36
|
+
async function registerRoute() {
|
|
37
|
+
_chunkQG4X6H5Yjs.Context.usePlugin(globalPlugins, "koa").forEach((p) => router.use(p));
|
|
38
|
+
if (parallelRoute) {
|
|
39
|
+
router.post(parallelRoute, ..._chunkQG4X6H5Yjs.Context.usePlugin(parallelPlugins, "koa"), async (ctx, next) => {
|
|
40
|
+
const { body } = ctx.request;
|
|
41
|
+
async function errorHandler(e) {
|
|
42
|
+
const error = await _chunkQG4X6H5Yjs.Context.filterRecord.default(e);
|
|
43
|
+
ctx.status = error.status;
|
|
44
|
+
ctx.body = error;
|
|
45
|
+
}
|
|
46
|
+
_chunkXNTMYLK6js.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
|
+
if (!Array.isArray(body))
|
|
48
|
+
return errorHandler(new (0, _chunkQG4X6H5Yjs.BadRequestException)("data format should be an array"));
|
|
49
|
+
try {
|
|
50
|
+
return Promise.all(body.map((item, i) => {
|
|
51
|
+
return new Promise(async (resolve) => {
|
|
52
|
+
const { tag, func } = item;
|
|
53
|
+
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
54
|
+
if (!metaMap.has(tag))
|
|
55
|
+
return resolve(await _chunkQG4X6H5Yjs.Context.filterRecord.default(new (0, _chunkQG4X6H5Yjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
56
|
+
const meta2 = metaMap.get(tag)[func];
|
|
57
|
+
if (!meta2)
|
|
58
|
+
return resolve(await _chunkQG4X6H5Yjs.Context.filterRecord.default(new (0, _chunkQG4X6H5Yjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
|
+
const { data: { params } } = meta2;
|
|
60
|
+
const contextData = {
|
|
61
|
+
type: "koa",
|
|
62
|
+
index: i,
|
|
63
|
+
ctx,
|
|
64
|
+
meta: meta2,
|
|
65
|
+
moduleMap,
|
|
66
|
+
parallel: true,
|
|
67
|
+
next,
|
|
68
|
+
app: router,
|
|
69
|
+
..._chunkQG4X6H5Yjs.argToReq.call(void 0, params, item.args, ctx.headers),
|
|
70
|
+
tag,
|
|
71
|
+
func
|
|
72
|
+
};
|
|
73
|
+
const context = new (0, _chunkQG4X6H5Yjs.Context)(contextData);
|
|
74
|
+
context.run({
|
|
75
|
+
globalGuards,
|
|
76
|
+
globalInterceptors,
|
|
77
|
+
globalFilter,
|
|
78
|
+
globalPipe
|
|
79
|
+
}, resolve, resolve);
|
|
80
|
+
});
|
|
81
|
+
})).then((ret) => {
|
|
82
|
+
ctx.body = ret;
|
|
81
83
|
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
});
|
|
84
|
+
} catch (e) {
|
|
85
|
+
return errorHandler(e);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
89
|
for (const [tag, record] of metaMap) {
|
|
90
90
|
for (const func in record) {
|
|
91
91
|
const meta2 = metaMap.get(tag)[func];
|
|
92
|
-
const { data: { plugins
|
|
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, ..._chunkQG4X6H5Yjs.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, { moduleMap, meta }, opts = {}) {
|
|
|
108
108
|
headers: ctx.headers,
|
|
109
109
|
next
|
|
110
110
|
};
|
|
111
|
-
const context = new (0,
|
|
111
|
+
const context = new (0, _chunkQG4X6H5Yjs.Context)(contextData);
|
|
112
112
|
if (http.headers) {
|
|
113
113
|
for (const name in http.headers)
|
|
114
114
|
ctx.set(name, http.headers[name]);
|
|
@@ -132,26 +132,14 @@ function bind(router, { moduleMap, meta }, opts = {}) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
plugins,
|
|
138
|
-
guards: globalGuards,
|
|
139
|
-
interceptors: globalInterceptors
|
|
140
|
-
});
|
|
141
|
-
handleMeta();
|
|
142
|
-
createRoute();
|
|
143
|
-
_chunkYERBWZCSjs.HMR.call(void 0, async () => {
|
|
135
|
+
_chunkXNTMYLK6js.__name.call(void 0, registerRoute, "registerRoute");
|
|
136
|
+
_chunkQG4X6H5Yjs.HMR.call(void 0, async () => {
|
|
144
137
|
router.stack = originStack;
|
|
145
|
-
|
|
146
|
-
plugins,
|
|
147
|
-
guards: globalGuards,
|
|
148
|
-
interceptors: globalInterceptors
|
|
149
|
-
});
|
|
150
|
-
handleMeta();
|
|
151
|
-
createRoute();
|
|
138
|
+
registerRoute();
|
|
152
139
|
});
|
|
153
140
|
}
|
|
154
|
-
|
|
141
|
+
_chunkXNTMYLK6js.__name.call(void 0, bind, "bind");
|
|
155
142
|
|
|
156
143
|
|
|
157
144
|
exports.bind = bind;
|
|
145
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/koa/bind.ts"],"names":["Debug","debug","bind","router","data","opts","globalGuards","globalInterceptors","parallelRoute","globalPlugins","parallelPlugins","globalFilter","globalPipe","moduleMap","meta","originStack","stack","slice","length","metaMap","createControllerMetaMap","controller","http","func","tag","type","detectAopDep","plugins","guards","interceptors","registerRoute","Context","usePlugin","forEach","p","use","post","ctx","next","body","request","errorHandler","e","error","filterRecord","default","status","Array","isArray","BadRequestException","Promise","all","map","item","i","resolve","has","get","params","contextData","index","parallel","app","argToReq","args","headers","context","run","then","ret","record","prefix","route","query","name","set","returnData","res","writableEnded","err","HMR"],"mappings":";;;;;;;;;;;;;AAGA,OAAOA,WAAW;AAUlB,IAAMC,QAAQD,MAAM,mBAAA;AAUb,SAASE,KAAKC,QAAgBC,MA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QAAQC,UAAkBL,SAAS,KAAA,GAAQ,OAAOU,KAAKC,SAAS;AAC7GrC,gBAAM,kBAAkBsB,oBAAoBC,MAAM;AAElD,gBAAMmC,cAAc;YAClBlC,MAAM;YACNqC,KAAK3D;YAELkC;YACAvB,MAAAA;YACAD;YACAW;YACAD;YACAkD,OAAOpC,IAAIoC;YACXf,QAAQrB,IAAIqB;YACZnB,MAAOF,IAAIG,QAAgBD;YAC3B0B,SAAS5B,IAAI4B;YACb3B;UACF;AACA,gBAAM4B,UAAU,IAAInC,QAAgB4B,WAAAA;AACpC,cAAIrC,KAAK2C,SAAS;AAChB,uBAAWS,QAAQpD,KAAK2C;AACtB5B,kBAAIsC,IAAID,MAAMpD,KAAK2C,QAAQS,KAAK;UACpC;AACA,gBAAMR,QAAQC,IAAI;YAEhB7D;YAAcC;YAAoBI;YAAcC;UAClD,GAAG,CACDgE,eACG;AACH,gBAAIvC,IAAIwC,IAAIC;AACV;AACFzC,gBAAIE,OAAOqC;UACb,GAAG,CAACG,QAAQ;AACV,gBAAI1C,IAAIwC,IAAIC;AACV;AACFzC,gBAAIS,SAASiC,IAAIjC;AACjBT,gBAAIE,OAAOwC;UACb,CAAA;QACF,CAAA;MACF;IACF;EACF;AAvHejD;AAyHfkD,MAAI,YAAY;AACd7E,WAAOa,QAAQD;AACfe,kBAAAA;EACF,CAAA;AACF;AAhJgB5B","sourcesContent":["import type Router from '@koa/router'\r\nimport type { RouterParamContext } from '@koa/router'\r\nimport type { DefaultContext, DefaultState } from 'koa'\r\nimport Debug from 'debug'\r\nimport type { HttpContext, HttpOptions } from '../helper'\r\nimport { argToReq } from '../helper'\r\nimport type { Factory } from '../../core'\r\nimport { BadRequestException } from '../../exception'\r\nimport { Context } from '../../context'\r\n\r\nimport { HMR } from '../../hmr'\r\nimport { createControllerMetaMap, detectAopDep } from '../../helper'\r\n\r\nconst debug = Debug('phecda-server/koa')\r\nexport interface KoaCtx extends HttpContext {\r\n type: 'koa'\r\n ctx: DefaultContext & RouterParamContext<DefaultState, DefaultContext>\r\n next: Function\r\n app: Router\r\n}\r\n\r\nexport type Plugin = Router.Middleware\r\n\r\nexport function bind(router: Router, data: Awaited<ReturnType<typeof Factory>>, opts: HttpOptions = {}) {\r\n const { globalGuards, globalInterceptors, parallelRoute = '/__PHECDA_SERVER__', globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts\r\n\r\n const { moduleMap, meta } = data\r\n const originStack = router.stack.slice(0, router.stack.length)\r\n\r\n const metaMap = createControllerMetaMap(meta, (meta) => {\r\n const { controller, http, func, tag } = meta.data\r\n if (controller === 'http' && http?.type) {\r\n debug(`register method \"${func}\" in module \"${tag}\"`)\r\n return true\r\n }\r\n })\r\n detectAopDep(meta, {\r\n plugins: [...globalPlugins, ...parallelPlugins],\r\n guards: globalGuards,\r\n interceptors: globalInterceptors,\r\n })\r\n registerRoute()\r\n async function registerRoute() {\r\n Context.usePlugin<Plugin>(globalPlugins, 'koa').forEach(p => router.use(p))\r\n\r\n if (parallelRoute) {\r\n router.post(parallelRoute, ...Context.usePlugin<Plugin>(parallelPlugins, 'koa'), async (ctx, next) => {\r\n const { body } = ctx.request as any\r\n\r\n async function errorHandler(e: any) {\r\n const error = await Context.filterRecord.default(e)\r\n ctx.status = error.status\r\n ctx.body = error\r\n }\r\n\r\n if (!Array.isArray(body))\r\n return errorHandler(new BadRequestException('data format should be an array'))\r\n\r\n try {\r\n return Promise.all(body.map((item: any, i) => {\r\n // eslint-disable-next-line no-async-promise-executor\r\n return new Promise(async (resolve) => {\r\n const { tag, func } = item\r\n debug(`(parallel)invoke method \"${func}\" in module \"${tag}\"`)\r\n\r\n if (!metaMap.has(tag))\r\n return resolve(await Context.filterRecord.default(new BadRequestException(`module \"${tag}\" doesn't exist`)))\r\n\r\n const meta = metaMap.get(tag)![func]\r\n if (!meta)\r\n return resolve(await Context.filterRecord.default(new BadRequestException(`\"${func}\" in \"${tag}\" doesn't exist`)))\r\n\r\n const {\r\n data: {\r\n params,\r\n\r\n },\r\n } = meta\r\n\r\n const contextData = {\r\n type: 'koa' as const,\r\n index: i,\r\n ctx,\r\n meta,\r\n moduleMap,\r\n parallel: true,\r\n next,\r\n app: router,\r\n ...argToReq(params, item.args, ctx.headers),\r\n tag,\r\n func,\r\n }\r\n const context = new Context<KoaCtx>(contextData)\r\n context.run({\r\n globalGuards, globalInterceptors, globalFilter, globalPipe,\r\n }, resolve, resolve)\r\n })\r\n })).then((ret) => {\r\n ctx.body = ret\r\n })\r\n }\r\n catch (e) {\r\n return errorHandler(e)\r\n }\r\n })\r\n }\r\n\r\n for (const [tag, record] of metaMap) {\r\n for (const func in record) {\r\n const meta = metaMap.get(tag)![func]\r\n\r\n const {\r\n data: {\r\n plugins,\r\n http,\r\n },\r\n } = meta\r\n\r\n if (!http?.type)\r\n continue\r\n router[http.type](http.prefix + http.route, ...Context.usePlugin<Plugin>(plugins, 'koa'), async (ctx, next) => {\r\n debug(`invoke method \"${func}\" in module \"${tag}\"`)\r\n\r\n const contextData = {\r\n type: 'koa' as const,\r\n app: router,\r\n\r\n ctx,\r\n meta,\r\n moduleMap,\r\n tag,\r\n func,\r\n query: ctx.query,\r\n params: ctx.params,\r\n body: (ctx.request as any).body,\r\n headers: ctx.headers,\r\n next,\r\n }\r\n const context = new Context<KoaCtx>(contextData)\r\n if (http.headers) {\r\n for (const name in http.headers)\r\n ctx.set(name, http.headers[name])\r\n }\r\n await context.run({\r\n\r\n globalGuards, globalInterceptors, globalFilter, globalPipe,\r\n }, (\r\n returnData,\r\n ) => {\r\n if (ctx.res.writableEnded)\r\n return\r\n ctx.body = returnData\r\n }, (err) => {\r\n if (ctx.res.writableEnded)\r\n return\r\n ctx.status = err.status\r\n ctx.body = err\r\n })\r\n })\r\n }\r\n }\r\n }\r\n\r\n HMR(async () => {\r\n router.stack = originStack\r\n registerRoute()\r\n })\r\n}\r\n"]}
|
|
@@ -3,96 +3,96 @@ import {
|
|
|
3
3
|
Context,
|
|
4
4
|
HMR,
|
|
5
5
|
argToReq,
|
|
6
|
+
createControllerMetaMap,
|
|
6
7
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-ZJD235TO.mjs";
|
|
8
9
|
import {
|
|
9
10
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-H4N6SHNG.mjs";
|
|
11
12
|
|
|
12
13
|
// src/server/koa/bind.ts
|
|
13
14
|
import Debug from "debug";
|
|
14
15
|
var debug = Debug("phecda-server/koa");
|
|
15
|
-
function bind(router,
|
|
16
|
-
const { globalGuards, globalInterceptors,
|
|
17
|
-
|
|
18
|
-
plugins: [],
|
|
19
|
-
...opts
|
|
20
|
-
};
|
|
16
|
+
function bind(router, data, opts = {}) {
|
|
17
|
+
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
18
|
+
const { moduleMap, meta } = data;
|
|
21
19
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
22
|
-
const metaMap =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for (const item of meta) {
|
|
26
|
-
const { tag, func, controller, http } = item.data;
|
|
27
|
-
if (controller !== "http" || !http?.type)
|
|
28
|
-
continue;
|
|
20
|
+
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
21
|
+
const { controller, http, func, tag } = meta2.data;
|
|
22
|
+
if (controller === "http" && http?.type) {
|
|
29
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
30
|
-
|
|
31
|
-
metaMap.get(tag)[func] = item;
|
|
32
|
-
else
|
|
33
|
-
metaMap.set(tag, {
|
|
34
|
-
[func]: item
|
|
35
|
-
});
|
|
24
|
+
return true;
|
|
36
25
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
26
|
+
});
|
|
27
|
+
detectAopDep(meta, {
|
|
28
|
+
plugins: [
|
|
29
|
+
...globalPlugins,
|
|
30
|
+
...parallelPlugins
|
|
31
|
+
],
|
|
32
|
+
guards: globalGuards,
|
|
33
|
+
interceptors: globalInterceptors
|
|
34
|
+
});
|
|
35
|
+
registerRoute();
|
|
36
|
+
async function registerRoute() {
|
|
37
|
+
Context.usePlugin(globalPlugins, "koa").forEach((p) => router.use(p));
|
|
38
|
+
if (parallelRoute) {
|
|
39
|
+
router.post(parallelRoute, ...Context.usePlugin(parallelPlugins, "koa"), async (ctx, next) => {
|
|
40
|
+
const { body } = ctx.request;
|
|
41
|
+
async function errorHandler(e) {
|
|
42
|
+
const error = await Context.filterRecord.default(e);
|
|
43
|
+
ctx.status = error.status;
|
|
44
|
+
ctx.body = error;
|
|
45
|
+
}
|
|
46
|
+
__name(errorHandler, "errorHandler");
|
|
47
|
+
if (!Array.isArray(body))
|
|
48
|
+
return errorHandler(new BadRequestException("data format should be an array"));
|
|
49
|
+
try {
|
|
50
|
+
return Promise.all(body.map((item, i) => {
|
|
51
|
+
return new Promise(async (resolve) => {
|
|
52
|
+
const { tag, func } = item;
|
|
53
|
+
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
54
|
+
if (!metaMap.has(tag))
|
|
55
|
+
return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
56
|
+
const meta2 = metaMap.get(tag)[func];
|
|
57
|
+
if (!meta2)
|
|
58
|
+
return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
|
+
const { data: { params } } = meta2;
|
|
60
|
+
const contextData = {
|
|
61
|
+
type: "koa",
|
|
62
|
+
index: i,
|
|
63
|
+
ctx,
|
|
64
|
+
meta: meta2,
|
|
65
|
+
moduleMap,
|
|
66
|
+
parallel: true,
|
|
67
|
+
next,
|
|
68
|
+
app: router,
|
|
69
|
+
...argToReq(params, item.args, ctx.headers),
|
|
70
|
+
tag,
|
|
71
|
+
func
|
|
72
|
+
};
|
|
73
|
+
const context = new Context(contextData);
|
|
74
|
+
context.run({
|
|
75
|
+
globalGuards,
|
|
76
|
+
globalInterceptors,
|
|
77
|
+
globalFilter,
|
|
78
|
+
globalPipe
|
|
79
|
+
}, resolve, resolve);
|
|
80
|
+
});
|
|
81
|
+
})).then((ret) => {
|
|
82
|
+
ctx.body = ret;
|
|
81
83
|
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
});
|
|
84
|
+
} catch (e) {
|
|
85
|
+
return errorHandler(e);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
89
|
for (const [tag, record] of metaMap) {
|
|
90
90
|
for (const func in record) {
|
|
91
91
|
const meta2 = metaMap.get(tag)[func];
|
|
92
|
-
const { data: { plugins
|
|
92
|
+
const { data: { plugins, http } } = meta2;
|
|
93
93
|
if (!http?.type)
|
|
94
94
|
continue;
|
|
95
|
-
router[http.type](http.prefix + http.route, ...Context.usePlugin(
|
|
95
|
+
router[http.type](http.prefix + http.route, ...Context.usePlugin(plugins, "koa"), async (ctx, next) => {
|
|
96
96
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
97
97
|
const contextData = {
|
|
98
98
|
type: "koa",
|
|
@@ -132,26 +132,14 @@ function bind(router, { moduleMap, meta }, opts = {}) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
__name(
|
|
136
|
-
detectAopDep(meta, {
|
|
137
|
-
plugins,
|
|
138
|
-
guards: globalGuards,
|
|
139
|
-
interceptors: globalInterceptors
|
|
140
|
-
});
|
|
141
|
-
handleMeta();
|
|
142
|
-
createRoute();
|
|
135
|
+
__name(registerRoute, "registerRoute");
|
|
143
136
|
HMR(async () => {
|
|
144
137
|
router.stack = originStack;
|
|
145
|
-
|
|
146
|
-
plugins,
|
|
147
|
-
guards: globalGuards,
|
|
148
|
-
interceptors: globalInterceptors
|
|
149
|
-
});
|
|
150
|
-
handleMeta();
|
|
151
|
-
createRoute();
|
|
138
|
+
registerRoute();
|
|
152
139
|
});
|
|
153
140
|
}
|
|
154
141
|
__name(bind, "bind");
|
|
155
142
|
export {
|
|
156
143
|
bind
|
|
157
144
|
};
|
|
145
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/koa/bind.ts"],"sourcesContent":["import type Router from '@koa/router'\r\nimport type { RouterParamContext } from '@koa/router'\r\nimport type { DefaultContext, DefaultState } from 'koa'\r\nimport Debug from 'debug'\r\nimport type { HttpContext, HttpOptions } from '../helper'\r\nimport { argToReq } from '../helper'\r\nimport type { Factory } from '../../core'\r\nimport { BadRequestException } from '../../exception'\r\nimport { Context } from '../../context'\r\n\r\nimport { HMR } from '../../hmr'\r\nimport { createControllerMetaMap, detectAopDep } from '../../helper'\r\n\r\nconst debug = Debug('phecda-server/koa')\r\nexport interface KoaCtx extends HttpContext {\r\n type: 'koa'\r\n ctx: DefaultContext & RouterParamContext<DefaultState, DefaultContext>\r\n next: Function\r\n app: Router\r\n}\r\n\r\nexport type Plugin = Router.Middleware\r\n\r\nexport function bind(router: Router, data: Awaited<ReturnType<typeof Factory>>, opts: HttpOptions = {}) {\r\n const { globalGuards, globalInterceptors, parallelRoute = '/__PHECDA_SERVER__', globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts\r\n\r\n const { moduleMap, meta } = data\r\n const originStack = router.stack.slice(0, router.stack.length)\r\n\r\n const metaMap = createControllerMetaMap(meta, (meta) => {\r\n const { controller, http, func, tag } = meta.data\r\n if (controller === 'http' && http?.type) {\r\n debug(`register method \"${func}\" in module \"${tag}\"`)\r\n return true\r\n }\r\n })\r\n detectAopDep(meta, {\r\n plugins: [...globalPlugins, ...parallelPlugins],\r\n guards: globalGuards,\r\n interceptors: globalInterceptors,\r\n })\r\n registerRoute()\r\n async function registerRoute() {\r\n Context.usePlugin<Plugin>(globalPlugins, 'koa').forEach(p => router.use(p))\r\n\r\n if (parallelRoute) {\r\n router.post(parallelRoute, ...Context.usePlugin<Plugin>(parallelPlugins, 'koa'), async (ctx, next) => {\r\n const { body } = ctx.request as any\r\n\r\n async function errorHandler(e: any) {\r\n const error = await Context.filterRecord.default(e)\r\n ctx.status = error.status\r\n ctx.body = error\r\n }\r\n\r\n if (!Array.isArray(body))\r\n return errorHandler(new BadRequestException('data format should be an array'))\r\n\r\n try {\r\n return Promise.all(body.map((item: any, i) => {\r\n // eslint-disable-next-line no-async-promise-executor\r\n return new Promise(async (resolve) => {\r\n const { tag, func } = item\r\n debug(`(parallel)invoke method \"${func}\" in module \"${tag}\"`)\r\n\r\n if (!metaMap.has(tag))\r\n return resolve(await Context.filterRecord.default(new BadRequestException(`module \"${tag}\" doesn't exist`)))\r\n\r\n const meta = metaMap.get(tag)![func]\r\n if (!meta)\r\n return resolve(await Context.filterRecord.default(new BadRequestException(`\"${func}\" in \"${tag}\" doesn't exist`)))\r\n\r\n const {\r\n data: {\r\n params,\r\n\r\n },\r\n } = meta\r\n\r\n const contextData = {\r\n type: 'koa' as const,\r\n index: i,\r\n ctx,\r\n meta,\r\n moduleMap,\r\n parallel: true,\r\n next,\r\n app: router,\r\n ...argToReq(params, item.args, ctx.headers),\r\n tag,\r\n func,\r\n }\r\n const context = new Context<KoaCtx>(contextData)\r\n context.run({\r\n globalGuards, globalInterceptors, globalFilter, globalPipe,\r\n }, resolve, resolve)\r\n })\r\n })).then((ret) => {\r\n ctx.body = ret\r\n })\r\n }\r\n catch (e) {\r\n return errorHandler(e)\r\n }\r\n })\r\n }\r\n\r\n for (const [tag, record] of metaMap) {\r\n for (const func in record) {\r\n const meta = metaMap.get(tag)![func]\r\n\r\n const {\r\n data: {\r\n plugins,\r\n http,\r\n },\r\n } = meta\r\n\r\n if (!http?.type)\r\n continue\r\n router[http.type](http.prefix + http.route, ...Context.usePlugin<Plugin>(plugins, 'koa'), async (ctx, next) => {\r\n debug(`invoke method \"${func}\" in module \"${tag}\"`)\r\n\r\n const contextData = {\r\n type: 'koa' as const,\r\n app: router,\r\n\r\n ctx,\r\n meta,\r\n moduleMap,\r\n tag,\r\n func,\r\n query: ctx.query,\r\n params: ctx.params,\r\n body: (ctx.request as any).body,\r\n headers: ctx.headers,\r\n next,\r\n }\r\n const context = new Context<KoaCtx>(contextData)\r\n if (http.headers) {\r\n for (const name in http.headers)\r\n ctx.set(name, http.headers[name])\r\n }\r\n await context.run({\r\n\r\n globalGuards, globalInterceptors, globalFilter, globalPipe,\r\n }, (\r\n returnData,\r\n ) => {\r\n if (ctx.res.writableEnded)\r\n return\r\n ctx.body = returnData\r\n }, (err) => {\r\n if (ctx.res.writableEnded)\r\n return\r\n ctx.status = err.status\r\n ctx.body = err\r\n })\r\n })\r\n }\r\n }\r\n }\r\n\r\n HMR(async () => {\r\n router.stack = originStack\r\n registerRoute()\r\n })\r\n}\r\n"],"mappings":";;;;;;;;;;;;;AAGA,OAAOA,WAAW;AAUlB,IAAMC,QAAQC,MAAM,mBAAA;AAUb,SAASC,KAAKC,QAAgBC,MAA2CC,OAAoB,CAAC,GAAG;AACtG,QAAM,EAAEC,cAAcC,oBAAoBC,gBAAgB,sBAAsBC,gBAAgB,CAAA,GAAIC,kBAAkB,CAAA,GA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c;YAClBlC,MAAM;YACNqC,KAAK3D;YAELkC;YACAvB,MAAAA;YACAD;YACAW;YACAD;YACAkD,OAAOpC,IAAIoC;YACXf,QAAQrB,IAAIqB;YACZnB,MAAOF,IAAIG,QAAgBD;YAC3B0B,SAAS5B,IAAI4B;YACb3B;UACF;AACA,gBAAM4B,UAAU,IAAInC,QAAgB4B,WAAAA;AACpC,cAAIrC,KAAK2C,SAAS;AAChB,uBAAWS,QAAQpD,KAAK2C;AACtB5B,kBAAIsC,IAAID,MAAMpD,KAAK2C,QAAQS,KAAK;UACpC;AACA,gBAAMR,QAAQC,IAAI;YAEhB7D;YAAcC;YAAoBI;YAAcC;UAClD,GAAG,CACDgE,eACG;AACH,gBAAIvC,IAAIwC,IAAIC;AACV;AACFzC,gBAAIE,OAAOqC;UACb,GAAG,CAACG,QAAQ;AACV,gBAAI1C,IAAIwC,IAAIC;AACV;AACFzC,gBAAIS,SAASiC,IAAIjC;AACjBT,gBAAIE,OAAOwC;UACb,CAAA;QACF,CAAA;MACF;IACF;EACF;AAvHejD;AAyHfkD,MAAI,YAAY;AACd7E,WAAOa,QAAQD;AACfe,kBAAAA;EACF,CAAA;AACF;AAhJgB5B;","names":["Debug","debug","Debug","bind","router","data","opts","globalGuards","globalInterceptors","parallelRoute","globalPlugins","parallelPlugins","globalFilter","globalPipe","moduleMap","meta","originStack","stack","slice","length","metaMap","createControllerMetaMap","controller","http","func","tag","type","detectAopDep","plugins","guards","interceptors","registerRoute","Context","usePlugin","forEach","p","use","post","ctx","next","body","request","errorHandler","e","error","filterRecord","default","status","Array","isArray","BadRequestException","Promise","all","map","item","i","resolve","has","get","params","contextData","index","parallel","app","argToReq","args","headers","context","run","then","ret","record","prefix","route","query","name","set","returnData","res","writableEnded","err","HMR"]}
|
package/dist/test.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as supertest from 'supertest';
|
|
|
2
2
|
import { Test } from 'supertest';
|
|
3
3
|
import { Server } from 'node:http';
|
|
4
4
|
import { Construct } from 'phecda-core';
|
|
5
|
-
import { F as Factory, P as PickFunc } from './core-
|
|
5
|
+
import { F as Factory, P as PickFunc } from './core-39f27fe8.js';
|
|
6
6
|
|
|
7
7
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
8
8
|
get<C extends T[number]>(Module: C): InstanceType<C>;
|
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 _chunk423JPSEBjs = require('./chunk-423JPSEB.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkXNTMYLK6js = require('./chunk-XNTMYLK6.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 _chunk423JPSEBjs.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
|
+
_chunkXNTMYLK6js.__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,12 +67,13 @@ async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
_chunkXNTMYLK6js.__name.call(void 0, module, "module");
|
|
71
71
|
Agent.module = module;
|
|
72
72
|
return Agent;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
_chunkXNTMYLK6js.__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.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/test.ts"],"names":["getTag","TestFactory","Modules","moduleMap","constructorMap","Factory","get","Module","tag","instance","Error","String","name","TestHttp","app","meta","isAgent","default","request","agent","Agent","module","Proxy","_target","p","data","find","func","args","ret","body","headers","query","http","type","url","prefix","route","params","forEach","item","replace","key","index","Object","keys","length","set","send"],"mappings":";;;;;;;;AAEA,SAAyBA,cAAc;AAKvC,eAAsBC,eAAsCC,SAAY;AACtE,QAAM,EAAEC,WAAWC,eAAc,IAAK,MAAMC,QAAQH,OAAAA;AAEpD,SAAO;IACLI,IAAyBC,QAA4B;AACnD,YAAMC,MAAMR,OAAOO,MAAAA;AACnB,YAAME,WAAWN,UAAUG,IAAIE,GAAAA;AAE/B,UAAI,CAACC;AACH,cAAM,IAAIC,MAAM,WAAWC,OAAOH,GAAAA,kBAAqB;AAEzD,UAAIJ,eAAeE,IAAIE,GAAAA,MAASD;AAC9B,cAAM,IAAIG,MAAM,WAAWH,OAAOK,cAAcD,OAAOH,GAAAA,uCAA0C;AAEnG,aAAOC;IACT;EACF;AACF;AAjBsBR;AAuBtB,eAAsBY,SAASC,KAAmB,EAAEX,WAAWY,KAAI,GAAyCC,UAAU,MAAM;AAC1H,QAAM,EAAEC,SAASC,SAASC,MAAK,IAAK,MAAM,OAAO;AACjD,QAAMC,QAAQD,MAAML,GAAAA;AAEpB,WAASO,OAA4Bd,QAAwD;AAC3F,UAAMC,MAAMR,OAAOO,MAAAA;AAEnB,UAAME,WAAWN,UAAUG,IAAIE,GAAAA;AAC/B,QAAI,CAACC;AACH,YAAM,IAAIC,MAAM,WAAWC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6B,KAAKnB,IAAIC,IAAI;AAE7B,iBAAOX;QACT;MACF;IACF,CAAA;EACF;AA5CSE;AA8CTD,QAAMC,SAASA;AAEf,SAAOD;AACT;AArDsBP","sourcesContent":["import type { Server } from 'node:http'\r\nimport type { SuperAgentTest, Test } from 'supertest'\r\nimport { type Construct, getTag } from 'phecda-core'\r\nimport { Factory } from './core'\r\n\r\nimport type { PickFunc } from './types'\r\nimport type { ControllerMeta } from './meta'\r\nexport async function TestFactory<T extends Construct[]>(...Modules: T) {\r\n const { moduleMap, constructorMap } = await Factory(Modules)\r\n\r\n return {\r\n get<C extends T[number]>(Module: C): InstanceType<C> {\r\n const tag = getTag(Module)\r\n const instance = moduleMap.get(tag)\r\n\r\n if (!instance)\r\n throw new Error(`module \"${String(tag)}\" doesn't exist`)\r\n\r\n if (constructorMap.get(tag) !== Module)\r\n throw new Error(`module \"${Module.name}\" and \"${String(tag)}\" in modulemap are different modules`)\r\n\r\n return instance\r\n },\r\n }\r\n}\r\n\r\nexport type SuperTestRequest<T> = {\r\n [K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;\r\n}\r\n\r\nexport async function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent = true) {\r\n const { default: request, agent } = await import('supertest')\r\n const Agent = agent(app) as SuperAgentTest & { module: typeof module }\r\n\r\n function module<T extends Construct>(Module: T): SuperTestRequest<PickFunc<InstanceType<T>>> {\r\n const tag = getTag(Module)\r\n\r\n const instance = moduleMap.get(tag)\r\n if (!instance)\r\n throw new Error(`module \"${String(tag)}\" doesn't exist`)\r\n\r\n return new Proxy({}, {\r\n get(_target, p) {\r\n const { data } = (meta as ControllerMeta[]).find(({ data }) => data.name === Module.name && data.func === p && data.tag === tag)!\r\n return (...args: any) => {\r\n const ret = { body: {}, headers: {}, query: {}, func: data.http!.type, url: data.http!.prefix + data.http!.route } as any\r\n\r\n data.params.forEach((item) => {\r\n if (item.type === 'params') {\r\n ret.url = ret.url.replace(`:${item.key}`, args[item.index])\r\n return\r\n }\r\n if (item.type === 'query') {\r\n ret.query[item.key] = args[item.index]\r\n return\r\n }\r\n\r\n // body\r\n if (item.key)\r\n ret[item.type][item.key] = args[item.index]\r\n else\r\n ret[item.type] = args[item.index]\r\n })\r\n // @ts-expect-error @todo miss type\r\n let agent = (isAgent ? Agent : request(app))[ret.func](ret.url)\r\n if (Object.keys(ret.query).length > 0)\r\n agent = agent.query(ret.query)\r\n\r\n if (Object.keys(ret.headers).length > 0)\r\n agent = agent.set(ret.headers)\r\n\r\n if (Object.keys(ret.body).length > 0)\r\n agent = agent.send(ret.body)\r\n\r\n return agent\r\n }\r\n },\r\n }) as any\r\n }\r\n\r\n Agent.module = module\r\n\r\n return Agent\r\n}\r\n"]}
|
package/dist/test.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Factory
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UCGRFVHC.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-H4N6SHNG.mjs";
|
|
7
7
|
|
|
8
8
|
// src/test.ts
|
|
9
9
|
import { getTag } from "phecda-core";
|
|
@@ -76,3 +76,4 @@ export {
|
|
|
76
76
|
TestFactory,
|
|
77
77
|
TestHttp
|
|
78
78
|
};
|
|
79
|
+
//# sourceMappingURL=test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/test.ts"],"sourcesContent":["import type { Server } from 'node:http'\r\nimport type { SuperAgentTest, Test } from 'supertest'\r\nimport { type Construct, getTag } from 'phecda-core'\r\nimport { Factory } from './core'\r\n\r\nimport type { PickFunc } from './types'\r\nimport type { ControllerMeta } from './meta'\r\nexport async function TestFactory<T extends Construct[]>(...Modules: T) {\r\n const { moduleMap, constructorMap } = await Factory(Modules)\r\n\r\n return {\r\n get<C extends T[number]>(Module: C): InstanceType<C> {\r\n const tag = getTag(Module)\r\n const instance = moduleMap.get(tag)\r\n\r\n if (!instance)\r\n throw new Error(`module \"${String(tag)}\" doesn't exist`)\r\n\r\n if (constructorMap.get(tag) !== Module)\r\n throw new Error(`module \"${Module.name}\" and \"${String(tag)}\" in modulemap are different modules`)\r\n\r\n return instance\r\n },\r\n }\r\n}\r\n\r\nexport type SuperTestRequest<T> = {\r\n [K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;\r\n}\r\n\r\nexport async function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent = true) {\r\n const { default: request, agent } = await import('supertest')\r\n const Agent = agent(app) as SuperAgentTest & { module: typeof module }\r\n\r\n function module<T extends Construct>(Module: T): SuperTestRequest<PickFunc<InstanceType<T>>> {\r\n const tag = getTag(Module)\r\n\r\n const instance = moduleMap.get(tag)\r\n if (!instance)\r\n throw new Error(`module \"${String(tag)}\" doesn't exist`)\r\n\r\n return new Proxy({}, {\r\n get(_target, p) {\r\n const { data } = (meta as ControllerMeta[]).find(({ data }) => data.name === Module.name && data.func === p && data.tag === tag)!\r\n return (...args: any) => {\r\n const ret = { body: {}, headers: {}, query: {}, func: data.http!.type, url: data.http!.prefix + data.http!.route } as any\r\n\r\n data.params.forEach((item) => {\r\n if (item.type === 'params') {\r\n ret.url = ret.url.replace(`:${item.key}`, args[item.index])\r\n return\r\n }\r\n if (item.type === 'query') {\r\n ret.query[item.key] = args[item.index]\r\n return\r\n }\r\n\r\n // body\r\n if (item.key)\r\n ret[item.type][item.key] = args[item.index]\r\n else\r\n ret[item.type] = args[item.index]\r\n })\r\n // @ts-expect-error @todo miss type\r\n let agent = (isAgent ? Agent : request(app))[ret.func](ret.url)\r\n if (Object.keys(ret.query).length > 0)\r\n agent = agent.query(ret.query)\r\n\r\n if (Object.keys(ret.headers).length > 0)\r\n agent = agent.set(ret.headers)\r\n\r\n if (Object.keys(ret.body).length > 0)\r\n agent = agent.send(ret.body)\r\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,KAAKQ,KAAMC;YAAMC,KAAKV,KAAKQ,KAAMG,SAASX,KAAKQ,KAAMI;UAAM;AAEjHZ,eAAKa,OAAOC,QAAQ,CAACC,SAAS;AAC5B,gBAAIA,KAAKN,SAAS,UAAU;AAC1BL,kBAAIM,MAAMN,IAAIM,IAAIM,QAAQ,IAAID,KAAKE,OAAOd,KAAKY,KAAKG,MAAM;AAC1D;YACF;AACA,gBAAIH,KAAKN,SAAS,SAAS;AACzBL,kBAAIG,MAAMQ,KAAKE,OAAOd,KAAKY,KAAKG;AAChC;YACF;AAGA,gBAAIH,KAAKE;AACPb,kBAAIW,KAAKN,MAAMM,KAAKE,OAAOd,KAAKY,KAAKG;;AAErCd,kBAAIW,KAAKN,QAAQN,KAAKY,KAAKG;UAC/B,CAAA;AAEA,cAAIxB,UAASH,UAAUI,QAAQF,QAAQJ,GAAAA,GAAMe,IAAIF,MAAME,IAAIM,GAAG;AAC9D,cAAIS,OAAOC,KAAKhB,IAAIG,KAAK,EAAEc,SAAS;AAClC3B,YAAAA,SAAQA,OAAMa,MAAMH,IAAIG,KAAK;AAE/B,cAAIY,OAAOC,KAAKhB,IAAIE,OAAO,EAAEe,SAAS;AACpC3B,YAAAA,SAAQA,OAAM4B,IAAIlB,IAAIE,OAAO;AAE/B,cAAIa,OAAOC,KAAKhB,IAAIC,IAAI,EAAEgB,SAAS;AACjC3B,YAAAA,SAAQA,OAAM6B,KAAKnB,IAAIC,IAAI;AAE7B,iBAAOX;QACT;MACF;IACF,CAAA;EACF;AA5CSE;AA8CTD,QAAMC,SAASA;AAEf,SAAOD;AACT;AArDsBP;","names":["getTag","TestFactory","Modules","moduleMap","constructorMap","Factory","get","Module","tag","getTag","instance","Error","String","name","TestHttp","app","meta","isAgent","default","request","agent","Agent","module","Proxy","_target","p","data","find","func","args","ret","body","headers","query","http","type","url","prefix","route","params","forEach","item","replace","key","index","Object","keys","length","set","send"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "5.0
|
|
4
|
-
"description": "server framework that provide IOC/type-reuse/http&rpc-adaptor
|
|
3
|
+
"version": "5.1.0",
|
|
4
|
+
"description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -117,11 +117,12 @@
|
|
|
117
117
|
},
|
|
118
118
|
"keywords": [
|
|
119
119
|
"server",
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
120
|
+
"IOC",
|
|
121
|
+
"rpc",
|
|
122
|
+
"types-share"
|
|
123
123
|
],
|
|
124
|
-
"author": "",
|
|
124
|
+
"author": "fgsreally",
|
|
125
|
+
"repository": "https://github.com/fgsreally/phecda/tree/main/packages/server",
|
|
125
126
|
"files": [
|
|
126
127
|
"dist",
|
|
127
128
|
"register",
|
|
@@ -143,7 +144,7 @@
|
|
|
143
144
|
"elysia": "^1.0.17",
|
|
144
145
|
"express": "^4.18.2",
|
|
145
146
|
"fastify": "^4.25.1",
|
|
146
|
-
"h3": "^1.
|
|
147
|
+
"h3": "^1.11.1",
|
|
147
148
|
"hono": "^4.3.4",
|
|
148
149
|
"hyper-express": "^6.15.2",
|
|
149
150
|
"ioredis": "^5.3.2",
|