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
|
@@ -4,96 +4,99 @@
|
|
|
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/express/bind.ts
|
|
13
14
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
14
15
|
var debug = _debug2.default.call(void 0, "phecda-server/express");
|
|
15
16
|
function bind(router, data, opts = {}) {
|
|
16
|
-
const { globalGuards, globalInterceptors,
|
|
17
|
-
route: "/__PHECDA_SERVER__",
|
|
18
|
-
plugins: [],
|
|
19
|
-
...opts
|
|
20
|
-
};
|
|
17
|
+
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
21
18
|
const { moduleMap, meta } = data;
|
|
22
19
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
23
|
-
const metaMap =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
for (const item of meta) {
|
|
27
|
-
const { tag, func, controller, http } = item.data;
|
|
28
|
-
if (controller !== "http" || !_optionalChain([http, 'optionalAccess', _ => _.type]))
|
|
29
|
-
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])) {
|
|
30
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
31
|
-
|
|
32
|
-
metaMap.get(tag)[func] = item;
|
|
33
|
-
else
|
|
34
|
-
metaMap.set(tag, {
|
|
35
|
-
[func]: item
|
|
36
|
-
});
|
|
24
|
+
return true;
|
|
37
25
|
}
|
|
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
|
-
tag
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
+
_chunkQG4X6H5Yjs.HMR.call(void 0, async () => {
|
|
37
|
+
router.stack = originStack;
|
|
38
|
+
registerRoute();
|
|
39
|
+
});
|
|
40
|
+
async function registerRoute() {
|
|
41
|
+
_chunkQG4X6H5Yjs.Context.usePlugin(globalPlugins, "express").forEach((p) => router.use(p));
|
|
42
|
+
if (parallelRoute) {
|
|
43
|
+
router.post(parallelRoute, ..._chunkQG4X6H5Yjs.Context.usePlugin(parallelPlugins, "express"), async (req, res, next) => {
|
|
44
|
+
const { body } = req;
|
|
45
|
+
async function errorHandler(e) {
|
|
46
|
+
const error = await _chunkQG4X6H5Yjs.Context.filterRecord.default(e);
|
|
47
|
+
return res.status(error.status).json(error);
|
|
48
|
+
}
|
|
49
|
+
_chunkXNTMYLK6js.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
+
if (!Array.isArray(body))
|
|
51
|
+
return errorHandler(new (0, _chunkQG4X6H5Yjs.BadRequestException)("data format should be an array"));
|
|
52
|
+
try {
|
|
53
|
+
return Promise.all(body.map((item, i) => {
|
|
54
|
+
return new Promise(async (resolve) => {
|
|
55
|
+
const { tag, func } = item;
|
|
56
|
+
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
57
|
+
if (!metaMap.has(tag))
|
|
58
|
+
return resolve(await _chunkQG4X6H5Yjs.Context.filterRecord.default(new (0, _chunkQG4X6H5Yjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
59
|
+
const meta2 = metaMap.get(tag)[func];
|
|
60
|
+
if (!meta2)
|
|
61
|
+
return resolve(await _chunkQG4X6H5Yjs.Context.filterRecord.default(new (0, _chunkQG4X6H5Yjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
62
|
+
const { data: { params } } = meta2;
|
|
63
|
+
const contextData = {
|
|
64
|
+
type: "express",
|
|
65
|
+
parallel: true,
|
|
66
|
+
request: req,
|
|
67
|
+
index: i,
|
|
68
|
+
meta: meta2,
|
|
69
|
+
response: res,
|
|
70
|
+
moduleMap,
|
|
71
|
+
tag,
|
|
72
|
+
func,
|
|
73
|
+
next,
|
|
74
|
+
app: router,
|
|
75
|
+
..._chunkQG4X6H5Yjs.argToReq.call(void 0, params, item.args, req.headers)
|
|
76
|
+
};
|
|
77
|
+
const context = new (0, _chunkQG4X6H5Yjs.Context)(contextData);
|
|
78
|
+
context.run({
|
|
79
|
+
globalGuards,
|
|
80
|
+
globalInterceptors,
|
|
81
|
+
globalFilter,
|
|
82
|
+
globalPipe
|
|
83
|
+
}, resolve, resolve);
|
|
84
|
+
});
|
|
85
|
+
})).then((ret) => {
|
|
86
|
+
res.json(ret);
|
|
82
87
|
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
});
|
|
88
|
+
} catch (e) {
|
|
89
|
+
return errorHandler(e);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
90
93
|
for (const [tag, record] of metaMap) {
|
|
91
94
|
for (const func in record) {
|
|
92
95
|
const meta2 = metaMap.get(tag)[func];
|
|
93
|
-
const { data: { plugins
|
|
96
|
+
const { data: { plugins, http } } = meta2;
|
|
94
97
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
|
|
95
98
|
continue;
|
|
96
|
-
router[http.type](http.prefix + http.route, ...
|
|
99
|
+
router[http.type](http.prefix + http.route, ..._chunkQG4X6H5Yjs.Context.usePlugin(plugins, "express"), async (req, res, next) => {
|
|
97
100
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
98
101
|
const contextData = {
|
|
99
102
|
type: "express",
|
|
@@ -110,7 +113,7 @@ function bind(router, data, opts = {}) {
|
|
|
110
113
|
app: router,
|
|
111
114
|
next
|
|
112
115
|
};
|
|
113
|
-
const context = new (0,
|
|
116
|
+
const context = new (0, _chunkQG4X6H5Yjs.Context)(contextData);
|
|
114
117
|
if (http.headers) {
|
|
115
118
|
for (const name in http.headers)
|
|
116
119
|
res.set(name, http.headers[name]);
|
|
@@ -136,26 +139,10 @@ function bind(router, data, opts = {}) {
|
|
|
136
139
|
}
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
|
-
|
|
140
|
-
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
141
|
-
plugins,
|
|
142
|
-
guards: globalGuards,
|
|
143
|
-
interceptors: globalInterceptors
|
|
144
|
-
});
|
|
145
|
-
handleMeta();
|
|
146
|
-
createRoute();
|
|
147
|
-
_chunkYERBWZCSjs.HMR.call(void 0, async () => {
|
|
148
|
-
router.stack = originStack;
|
|
149
|
-
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
150
|
-
plugins,
|
|
151
|
-
guards: globalGuards,
|
|
152
|
-
interceptors: globalInterceptors
|
|
153
|
-
});
|
|
154
|
-
handleMeta();
|
|
155
|
-
createRoute();
|
|
156
|
-
});
|
|
142
|
+
_chunkXNTMYLK6js.__name.call(void 0, registerRoute, "registerRoute");
|
|
157
143
|
}
|
|
158
|
-
|
|
144
|
+
_chunkXNTMYLK6js.__name.call(void 0, bind, "bind");
|
|
159
145
|
|
|
160
146
|
|
|
161
147
|
exports.bind = bind;
|
|
148
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/express/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","HMR","Context","usePlugin","forEach","p","use","post","req","res","next","body","errorHandler","e","error","filterRecord","default","status","json","Array","isArray","BadRequestException","Promise","all","map","item","i","resolve","has","get","params","contextData","parallel","request","index","response","app","argToReq","args","headers","context","run","then","ret","record","prefix","route","query","name","set","returnData","writableEnded","send","err"],"mappings":";;;;;;;;;;;;;AACA,OAAOA,WAAW;AASlB,IAAMC,QA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A,EAAMD;AAE/B,cAAM,EACJnB,MAAM,EAEJuB,SACAL,KAAI,EACL,IACCR;AAEJ,YAAI,CAACQ,MAAMG;AACT;AAEDtB,eAAmBmB,KAAKG,MAAMH,KAAKqD,SAASrD,KAAKsD,OAAK,GAAK5C,QAAQC,UAAkBN,SAAS,SAAA,GAAY,OAAOW,KAAKC,KAAKC,SAAS;AACnIvC,gBAAM,kBAAkBsB,oBAAoBC,MAAM;AAElD,gBAAMqC,cAAc;YAClBpC,MAAM;YACNsC,SAASzB;YACTxB,MAAAA;YACAmD,UAAU1B;YACV1B;YACAW;YACAD;YACAsD,OAAOvC,IAAIuC;YACXpC,MAAMH,IAAIG;YACVmB,QAAQtB,IAAIsB;YACZS,SAAS/B,IAAI+B;YACbH,KAAK/D;YACLqC;UACF;AAEA,gBAAM8B,UAAU,IAAItC,QAAoB6B,WAAAA;AACxC,cAAIvC,KAAK+C,SAAS;AAChB,uBAAWS,QAAQxD,KAAK+C;AACtB9B,kBAAIwC,IAAID,MAAMxD,KAAK+C,QAAQS,KAAK;UACpC;AAEA,gBAAMR,QAAQC,IAAI;YAChBjE;YAAcC;YAAoBI;YAAcC;UAClD,GAAG,CAACoE,eAAe;AACjB,gBAAIzC,IAAI0C;AACN;AACF,gBAAI,OAAOD,eAAe;AACxBzC,kBAAI2C,KAAKF,UAAAA;;AAGTzC,kBAAIS,KAAKgC,UAAAA;UACb,GAAG,CAACG,QAAQ;AACV,gBAAI5C,IAAI0C;AACN;AACF1C,gBAAIQ,OAAOoC,IAAIpC,MAAM,EAAEC,KAAKmC,GAAAA;UAC9B,CAAA;QACF,CAAA;MACF;IACF;EACF;AA7HerD;AA8HjB;AAxJgB5B","sourcesContent":["import type { Express, Request, RequestHandler, Response, Router } from 'express'\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\nimport { createControllerMetaMap, detectAopDep } from '../../helper'\r\nimport { HMR } from '../../hmr'\r\n\r\nconst debug = Debug('phecda-server/express')\r\nexport interface ExpressCtx extends HttpContext {\r\n type: 'express'\r\n request: Request\r\n response: Response\r\n next: Function\r\n app: Router\r\n\r\n}\r\n\r\nexport type Plugin = RequestHandler\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 const { moduleMap, meta } = data\r\n\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\r\n registerRoute()\r\n\r\n HMR(async () => {\r\n router.stack = originStack// router.stack.slice(0, 1)\r\n registerRoute()\r\n })\r\n\r\n async function registerRoute() {\r\n Context.usePlugin<Plugin>(globalPlugins, 'express').forEach(p => router.use(p))\r\n\r\n if (parallelRoute) {\r\n (router as Express).post(parallelRoute, ...Context.usePlugin<Plugin>(parallelPlugins, 'express'), async (req, res, next) => {\r\n const { body } = req\r\n\r\n async function errorHandler(e: any) {\r\n const error = await Context.filterRecord.default(e)\r\n return res.status(error.status).json(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\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\r\n data: {\r\n params,\r\n\r\n },\r\n } = meta\r\n\r\n const contextData = {\r\n type: 'express' as const,\r\n parallel: true,\r\n request: req,\r\n index: i,\r\n meta,\r\n response: res,\r\n moduleMap,\r\n tag,\r\n func,\r\n next,\r\n app: router,\r\n ...argToReq(params, item.args, req.headers),\r\n }\r\n const context = new Context<ExpressCtx>(contextData)\r\n\r\n context.run({\r\n globalGuards, globalInterceptors, globalFilter, globalPipe,\r\n }, resolve, resolve)\r\n })\r\n })).then((ret) => {\r\n res.json(ret)\r\n })\r\n }\r\n catch (e) {\r\n return errorHandler(e)\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\r\n plugins,\r\n http,\r\n },\r\n } = meta\r\n\r\n if (!http?.type)\r\n continue\r\n\r\n (router as Express)[http.type](http.prefix + http.route, ...Context.usePlugin<Plugin>(plugins, 'express'), async (req, res, next) => {\r\n debug(`invoke method \"${func}\" in module \"${tag}\"`)\r\n\r\n const contextData = {\r\n type: 'express' as const,\r\n request: req,\r\n meta,\r\n response: res,\r\n moduleMap,\r\n tag,\r\n func,\r\n query: req.query,\r\n body: req.body,\r\n params: req.params,\r\n headers: req.headers,\r\n app: router,\r\n next,\r\n }\r\n\r\n const context = new Context<ExpressCtx>(contextData)\r\n if (http.headers) {\r\n for (const name in http.headers)\r\n res.set(name, http.headers[name])\r\n }\r\n\r\n await context.run({\r\n globalGuards, globalInterceptors, globalFilter, globalPipe,\r\n }, (returnData) => {\r\n if (res.writableEnded)\r\n return\r\n if (typeof returnData === 'string')\r\n res.send(returnData)\r\n\r\n else\r\n res.json(returnData)\r\n }, (err) => {\r\n if (res.writableEnded)\r\n return\r\n res.status(err.status).json(err)\r\n })\r\n })\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -3,97 +3,100 @@ 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/express/bind.ts
|
|
13
14
|
import Debug from "debug";
|
|
14
15
|
var debug = Debug("phecda-server/express");
|
|
15
16
|
function bind(router, data, opts = {}) {
|
|
16
|
-
const { globalGuards, globalInterceptors,
|
|
17
|
-
route: "/__PHECDA_SERVER__",
|
|
18
|
-
plugins: [],
|
|
19
|
-
...opts
|
|
20
|
-
};
|
|
17
|
+
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
21
18
|
const { moduleMap, meta } = data;
|
|
22
19
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
23
|
-
const metaMap =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
for (const item of meta) {
|
|
27
|
-
const { tag, func, controller, http } = item.data;
|
|
28
|
-
if (controller !== "http" || !http?.type)
|
|
29
|
-
continue;
|
|
20
|
+
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
21
|
+
const { controller, http, func, tag } = meta2.data;
|
|
22
|
+
if (controller === "http" && http?.type) {
|
|
30
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
31
|
-
|
|
32
|
-
metaMap.get(tag)[func] = item;
|
|
33
|
-
else
|
|
34
|
-
metaMap.set(tag, {
|
|
35
|
-
[func]: item
|
|
36
|
-
});
|
|
24
|
+
return true;
|
|
37
25
|
}
|
|
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
|
-
tag
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
26
|
+
});
|
|
27
|
+
detectAopDep(meta, {
|
|
28
|
+
plugins: [
|
|
29
|
+
...globalPlugins,
|
|
30
|
+
...parallelPlugins
|
|
31
|
+
],
|
|
32
|
+
guards: globalGuards,
|
|
33
|
+
interceptors: globalInterceptors
|
|
34
|
+
});
|
|
35
|
+
registerRoute();
|
|
36
|
+
HMR(async () => {
|
|
37
|
+
router.stack = originStack;
|
|
38
|
+
registerRoute();
|
|
39
|
+
});
|
|
40
|
+
async function registerRoute() {
|
|
41
|
+
Context.usePlugin(globalPlugins, "express").forEach((p) => router.use(p));
|
|
42
|
+
if (parallelRoute) {
|
|
43
|
+
router.post(parallelRoute, ...Context.usePlugin(parallelPlugins, "express"), async (req, res, next) => {
|
|
44
|
+
const { body } = req;
|
|
45
|
+
async function errorHandler(e) {
|
|
46
|
+
const error = await Context.filterRecord.default(e);
|
|
47
|
+
return res.status(error.status).json(error);
|
|
48
|
+
}
|
|
49
|
+
__name(errorHandler, "errorHandler");
|
|
50
|
+
if (!Array.isArray(body))
|
|
51
|
+
return errorHandler(new BadRequestException("data format should be an array"));
|
|
52
|
+
try {
|
|
53
|
+
return Promise.all(body.map((item, i) => {
|
|
54
|
+
return new Promise(async (resolve) => {
|
|
55
|
+
const { tag, func } = item;
|
|
56
|
+
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
57
|
+
if (!metaMap.has(tag))
|
|
58
|
+
return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
59
|
+
const meta2 = metaMap.get(tag)[func];
|
|
60
|
+
if (!meta2)
|
|
61
|
+
return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
|
|
62
|
+
const { data: { params } } = meta2;
|
|
63
|
+
const contextData = {
|
|
64
|
+
type: "express",
|
|
65
|
+
parallel: true,
|
|
66
|
+
request: req,
|
|
67
|
+
index: i,
|
|
68
|
+
meta: meta2,
|
|
69
|
+
response: res,
|
|
70
|
+
moduleMap,
|
|
71
|
+
tag,
|
|
72
|
+
func,
|
|
73
|
+
next,
|
|
74
|
+
app: router,
|
|
75
|
+
...argToReq(params, item.args, req.headers)
|
|
76
|
+
};
|
|
77
|
+
const context = new Context(contextData);
|
|
78
|
+
context.run({
|
|
79
|
+
globalGuards,
|
|
80
|
+
globalInterceptors,
|
|
81
|
+
globalFilter,
|
|
82
|
+
globalPipe
|
|
83
|
+
}, resolve, resolve);
|
|
84
|
+
});
|
|
85
|
+
})).then((ret) => {
|
|
86
|
+
res.json(ret);
|
|
82
87
|
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
});
|
|
88
|
+
} catch (e) {
|
|
89
|
+
return errorHandler(e);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
90
93
|
for (const [tag, record] of metaMap) {
|
|
91
94
|
for (const func in record) {
|
|
92
95
|
const meta2 = metaMap.get(tag)[func];
|
|
93
|
-
const { data: { plugins
|
|
96
|
+
const { data: { plugins, http } } = meta2;
|
|
94
97
|
if (!http?.type)
|
|
95
98
|
continue;
|
|
96
|
-
router[http.type](http.prefix + http.route, ...Context.usePlugin(
|
|
99
|
+
router[http.type](http.prefix + http.route, ...Context.usePlugin(plugins, "express"), async (req, res, next) => {
|
|
97
100
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
98
101
|
const contextData = {
|
|
99
102
|
type: "express",
|
|
@@ -136,26 +139,10 @@ function bind(router, data, opts = {}) {
|
|
|
136
139
|
}
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
|
-
__name(
|
|
140
|
-
detectAopDep(meta, {
|
|
141
|
-
plugins,
|
|
142
|
-
guards: globalGuards,
|
|
143
|
-
interceptors: globalInterceptors
|
|
144
|
-
});
|
|
145
|
-
handleMeta();
|
|
146
|
-
createRoute();
|
|
147
|
-
HMR(async () => {
|
|
148
|
-
router.stack = originStack;
|
|
149
|
-
detectAopDep(meta, {
|
|
150
|
-
plugins,
|
|
151
|
-
guards: globalGuards,
|
|
152
|
-
interceptors: globalInterceptors
|
|
153
|
-
});
|
|
154
|
-
handleMeta();
|
|
155
|
-
createRoute();
|
|
156
|
-
});
|
|
142
|
+
__name(registerRoute, "registerRoute");
|
|
157
143
|
}
|
|
158
144
|
__name(bind, "bind");
|
|
159
145
|
export {
|
|
160
146
|
bind
|
|
161
147
|
};
|
|
148
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/express/bind.ts"],"sourcesContent":["import type { Express, Request, RequestHandler, Response, Router } from 'express'\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\nimport { createControllerMetaMap, detectAopDep } from '../../helper'\r\nimport { HMR } from '../../hmr'\r\n\r\nconst debug = Debug('phecda-server/express')\r\nexport interface ExpressCtx extends HttpContext {\r\n type: 'express'\r\n request: Request\r\n response: Response\r\n next: Function\r\n app: Router\r\n\r\n}\r\n\r\nexport type Plugin = RequestHandler\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 const { moduleMap, meta } = data\r\n\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\r\n registerRoute()\r\n\r\n HMR(async () => {\r\n router.stack = originStack// router.stack.slice(0, 1)\r\n registerRoute()\r\n })\r\n\r\n async function registerRoute() {\r\n Context.usePlugin<Plugin>(globalPlugins, 'express').forEach(p => router.use(p))\r\n\r\n if (parallelRoute) {\r\n (router as Express).post(parallelRoute, ...Context.usePlugin<Plugin>(parallelPlugins, 'express'), async (req, res, next) => {\r\n const { body } = req\r\n\r\n async function errorHandler(e: any) {\r\n const error = await Context.filterRecord.default(e)\r\n return res.status(error.status).json(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\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\r\n data: {\r\n params,\r\n\r\n },\r\n } = meta\r\n\r\n const contextData = {\r\n type: 'express' as const,\r\n parallel: true,\r\n request: req,\r\n index: i,\r\n meta,\r\n response: res,\r\n moduleMap,\r\n tag,\r\n func,\r\n next,\r\n app: router,\r\n ...argToReq(params, item.args, req.headers),\r\n }\r\n const context = new Context<ExpressCtx>(contextData)\r\n\r\n context.run({\r\n globalGuards, globalInterceptors, globalFilter, globalPipe,\r\n }, resolve, resolve)\r\n })\r\n })).then((ret) => {\r\n res.json(ret)\r\n })\r\n }\r\n catch (e) {\r\n return errorHandler(e)\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\r\n plugins,\r\n http,\r\n },\r\n } = meta\r\n\r\n if (!http?.type)\r\n continue\r\n\r\n (router as Express)[http.type](http.prefix + http.route, ...Context.usePlugin<Plugin>(plugins, 'express'), async (req, res, next) => {\r\n debug(`invoke method \"${func}\" in module \"${tag}\"`)\r\n\r\n const contextData = {\r\n type: 'express' as const,\r\n request: req,\r\n meta,\r\n response: res,\r\n moduleMap,\r\n tag,\r\n func,\r\n query: req.query,\r\n body: req.body,\r\n params: req.params,\r\n headers: req.headers,\r\n app: router,\r\n next,\r\n }\r\n\r\n const context = new Context<ExpressCtx>(contextData)\r\n if (http.headers) {\r\n for (const name in http.headers)\r\n res.set(name, http.headers[name])\r\n }\r\n\r\n await context.run({\r\n globalGuards, globalInterceptors, globalFilter, globalPipe,\r\n }, (returnData) => {\r\n if (res.writableEnded)\r\n return\r\n if (typeof returnData === 'string')\r\n res.send(returnData)\r\n\r\n else\r\n res.json(returnData)\r\n }, (err) => {\r\n if (res.writableEnded)\r\n return\r\n res.status(err.status).json(err)\r\n })\r\n })\r\n }\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;AACA,O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QAAOK,QAAQwC,IAAInC,GAAAA,EAAMD;AAE/B,cAAM,EACJnB,MAAM,EAEJuB,SACAL,KAAI,EACL,IACCR;AAEJ,YAAI,CAACQ,MAAMG;AACT;AAEDtB,eAAmBmB,KAAKG,MAAMH,KAAKqD,SAASrD,KAAKsD,OAAK,GAAK5C,QAAQC,UAAkBN,SAAS,SAAA,GAAY,OAAOW,KAAKC,KAAKC,SAAS;AACnIxC,gBAAM,kBAAkBuB,oBAAoBC,MAAM;AAElD,gBAAMqC,cAAc;YAClBpC,MAAM;YACNsC,SAASzB;YACTxB,MAAAA;YACAmD,UAAU1B;YACV1B;YACAW;YACAD;YACAsD,OAAOvC,IAAIuC;YACXpC,MAAMH,IAAIG;YACVmB,QAAQtB,IAAIsB;YACZS,SAAS/B,IAAI+B;YACbH,KAAK/D;YACLqC;UACF;AAEA,gBAAM8B,UAAU,IAAItC,QAAoB6B,WAAAA;AACxC,cAAIvC,KAAK+C,SAAS;AAChB,uBAAWS,QAAQxD,KAAK+C;AACtB9B,kBAAIwC,IAAID,MAAMxD,KAAK+C,QAAQS,KAAK;UACpC;AAEA,gBAAMR,QAAQC,IAAI;YAChBjE;YAAcC;YAAoBI;YAAcC;UAClD,GAAG,CAACoE,eAAe;AACjB,gBAAIzC,IAAI0C;AACN;AACF,gBAAI,OAAOD,eAAe;AACxBzC,kBAAI2C,KAAKF,UAAAA;;AAGTzC,kBAAIS,KAAKgC,UAAAA;UACb,GAAG,CAACG,QAAQ;AACV,gBAAI5C,IAAI0C;AACN;AACF1C,gBAAIQ,OAAOoC,IAAIpC,MAAM,EAAEC,KAAKmC,GAAAA;UAC9B,CAAA;QACF,CAAA;MACF;IACF;EACF;AA7HerD;AA8HjB;AAxJgB5B;","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","HMR","Context","usePlugin","forEach","p","use","post","req","res","next","body","errorHandler","e","error","filterRecord","default","status","json","Array","isArray","BadRequestException","Promise","all","map","item","i","resolve","has","get","params","contextData","parallel","request","index","response","app","argToReq","args","headers","context","run","then","ret","record","prefix","route","query","name","set","returnData","writableEnded","send","err"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, RouteShorthandOptions } from 'fastify';
|
|
2
|
-
import { a as HttpContext, H as HttpOptions } from '../../helper-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
1
|
+
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
|
+
import { a as HttpContext, H as HttpOptions } from '../../helper-fcbf6aa8.js';
|
|
3
|
+
import { F as Factory } from '../../core-39f27fe8.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
@@ -10,7 +10,10 @@ interface FastifyCtx extends HttpContext {
|
|
|
10
10
|
response: FastifyReply;
|
|
11
11
|
app: FastifyInstance;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
type Plugin = FastifyPluginCallback;
|
|
14
|
+
declare function bind(fastify: FastifyInstance, data: Awaited<ReturnType<typeof Factory>>, opts?: HttpOptions & {
|
|
15
|
+
fastifyOpts?: FastifyRegisterOptions<FastifyPluginOptions>;
|
|
16
|
+
}): void;
|
|
14
17
|
declare function Fastify(opts: RouteShorthandOptions): any;
|
|
15
18
|
|
|
16
|
-
export { Fastify, FastifyCtx, bind };
|
|
19
|
+
export { Fastify, FastifyCtx, Plugin, bind };
|