phecda-server 8.2.0 → 8.3.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/dist/{chunk-MPKVT4SQ.js → chunk-R73A7HS3.js} +35 -34
- package/dist/{chunk-2P2UICBC.mjs → chunk-US2DTB3Z.mjs} +35 -34
- package/dist/helper.js +2 -2
- package/dist/helper.mjs +1 -1
- package/dist/http/elysia/index.js +17 -17
- package/dist/http/elysia/index.mjs +1 -1
- package/dist/http/express/index.js +16 -16
- package/dist/http/express/index.mjs +1 -1
- package/dist/http/fastify/index.js +16 -16
- package/dist/http/fastify/index.mjs +1 -1
- package/dist/http/h3/index.js +17 -17
- package/dist/http/h3/index.mjs +1 -1
- package/dist/http/hono/index.js +14 -14
- package/dist/http/hono/index.mjs +1 -1
- package/dist/http/hyper-express/index.js +15 -15
- package/dist/http/hyper-express/index.mjs +1 -1
- package/dist/http/koa/index.js +16 -16
- package/dist/http/koa/index.mjs +1 -1
- package/dist/index.d.mts +18 -17
- package/dist/index.d.ts +18 -17
- package/dist/index.js +20 -20
- package/dist/index.mjs +1 -1
- package/dist/rpc/bullmq/index.js +6 -6
- package/dist/rpc/bullmq/index.mjs +1 -1
- package/dist/rpc/electron/index.js +5 -5
- package/dist/rpc/electron/index.mjs +1 -1
- package/dist/rpc/kafka/index.js +6 -6
- package/dist/rpc/kafka/index.mjs +1 -1
- package/dist/rpc/nats/index.js +6 -6
- package/dist/rpc/nats/index.mjs +1 -1
- package/dist/rpc/rabbitmq/index.js +6 -6
- package/dist/rpc/rabbitmq/index.mjs +1 -1
- package/dist/rpc/redis/index.js +6 -6
- package/dist/rpc/redis/index.mjs +1 -1
- package/dist/rpc/ws/index.js +5 -5
- package/dist/rpc/ws/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ var _chunkC424F7TVjs = require('../../chunk-C424F7TV.js');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkR73A7HS3js = require('../../chunk-R73A7HS3.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkOUQM7GZHjs = require('../../chunk-OUQM7GZH.js');
|
|
@@ -18,14 +18,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/fastify");
|
|
|
18
18
|
function bind(fastify, data, opts = {}) {
|
|
19
19
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, fastifyOpts, dynamic = false } = opts;
|
|
20
20
|
const { moduleMap, meta } = data;
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkR73A7HS3js.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
22
|
const { controller, http, method, tag } = meta2.data;
|
|
23
23
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _2 => _2.method])) {
|
|
24
24
|
debug(`register method "${method}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunkR73A7HS3js.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -33,28 +33,28 @@ function bind(fastify, data, opts = {}) {
|
|
|
33
33
|
guards: globalGuards
|
|
34
34
|
});
|
|
35
35
|
fastify.register(async (fastify2, _, done) => {
|
|
36
|
-
|
|
36
|
+
_chunkR73A7HS3js.Context.applyAddons(globalAddons, fastify2, "fastify");
|
|
37
37
|
if (parallelRoute) {
|
|
38
38
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
39
|
-
|
|
39
|
+
_chunkR73A7HS3js.Context.applyAddons(parallelAddons, fastify3, "fastify");
|
|
40
40
|
fastify3.post(parallelRoute, async (req, res) => {
|
|
41
41
|
const { body } = req;
|
|
42
42
|
async function errorHandler(e) {
|
|
43
|
-
const error = await
|
|
43
|
+
const error = await _chunkR73A7HS3js.Context.filterRecord.default(e);
|
|
44
44
|
return res.status(error.status).send(error);
|
|
45
45
|
}
|
|
46
46
|
_chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
47
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkR73A7HS3js.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
|
if (!item) return resolve(null);
|
|
52
52
|
const { tag, method } = item;
|
|
53
53
|
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
54
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
54
|
+
if (!metaMap.has(tag)) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
55
55
|
const meta2 = metaMap.get(tag)[method];
|
|
56
|
-
if (!meta2) return resolve(await
|
|
57
|
-
const aop =
|
|
56
|
+
if (!meta2) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
57
|
+
const aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
58
58
|
globalFilter,
|
|
59
59
|
globalGuards,
|
|
60
60
|
globalPipe
|
|
@@ -82,7 +82,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
82
82
|
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => req.raw, "getRequest"),
|
|
83
83
|
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => res.raw, "getResponse")
|
|
84
84
|
};
|
|
85
|
-
const context = new (0,
|
|
85
|
+
const context = new (0, _chunkR73A7HS3js.Context)(contextData);
|
|
86
86
|
context.run(aop, resolve, resolve);
|
|
87
87
|
});
|
|
88
88
|
})).then((ret) => {
|
|
@@ -101,16 +101,16 @@ function bind(fastify, data, opts = {}) {
|
|
|
101
101
|
const { data: { addons, define, http } } = meta2;
|
|
102
102
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.method])) continue;
|
|
103
103
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
104
|
-
|
|
104
|
+
_chunkR73A7HS3js.Context.applyAddons(addons, fastify3, "fastify");
|
|
105
105
|
let aop;
|
|
106
106
|
if (!dynamic) {
|
|
107
|
-
aop =
|
|
107
|
+
aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
108
108
|
globalFilter,
|
|
109
109
|
globalGuards,
|
|
110
110
|
globalPipe
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
fastify3[http.method](
|
|
113
|
+
fastify3[http.method](_chunkR73A7HS3js.joinUrl.call(void 0, http.prefix, http.route), _optionalChain([define, 'optionalAccess', _4 => _4.fastify]) || {}, async (req, res) => {
|
|
114
114
|
debug(`invoke method "${method}" in module "${tag}"`);
|
|
115
115
|
const contextData = {
|
|
116
116
|
type: "fastify",
|
|
@@ -140,10 +140,10 @@ function bind(fastify, data, opts = {}) {
|
|
|
140
140
|
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => req.raw, "getRequest"),
|
|
141
141
|
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => res.raw, "getResponse")
|
|
142
142
|
};
|
|
143
|
-
const context = new (0,
|
|
143
|
+
const context = new (0, _chunkR73A7HS3js.Context)(contextData);
|
|
144
144
|
if (http.headers) res.headers(http.headers);
|
|
145
145
|
if (dynamic) {
|
|
146
|
-
aop =
|
|
146
|
+
aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
147
147
|
globalFilter,
|
|
148
148
|
globalGuards,
|
|
149
149
|
globalPipe
|
package/dist/http/h3/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkR73A7HS3js = require('../../chunk-R73A7HS3.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkOUQM7GZHjs = require('../../chunk-OUQM7GZH.js');
|
|
@@ -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, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
|
-
const metaMap =
|
|
19
|
+
const metaMap = _chunkR73A7HS3js.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
20
20
|
const { controller, http, method, tag } = meta2.data;
|
|
21
21
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
22
22
|
debug(`register method "${method}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
_chunkR73A7HS3js.detectAopDep.call(void 0, meta, {
|
|
27
27
|
addons: [
|
|
28
28
|
...globalAddons,
|
|
29
29
|
...parallelAddons
|
|
@@ -32,32 +32,32 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunkR73A7HS3js.Context.applyAddons(globalAddons, router, "h3");
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
38
|
-
|
|
38
|
+
_chunkR73A7HS3js.Context.applyAddons(parallelAddons, subRouter, "h3");
|
|
39
39
|
subRouter.post(parallelRoute, _h3.eventHandler.call(void 0, {
|
|
40
40
|
handler: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, async (event) => {
|
|
41
41
|
const body = await _h3.readBody.call(void 0, event, {
|
|
42
42
|
strict: true
|
|
43
43
|
});
|
|
44
44
|
async function errorHandler(e) {
|
|
45
|
-
const error = await
|
|
45
|
+
const error = await _chunkR73A7HS3js.Context.filterRecord.default(e);
|
|
46
46
|
_h3.setResponseStatus.call(void 0, event, error.status);
|
|
47
47
|
return error;
|
|
48
48
|
}
|
|
49
49
|
_chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkR73A7HS3js.BadRequestException)("data format should be an array"));
|
|
51
51
|
try {
|
|
52
52
|
return Promise.all(body.map((item, i) => {
|
|
53
53
|
return new Promise(async (resolve) => {
|
|
54
54
|
if (!item) return resolve(null);
|
|
55
55
|
const { tag, method } = item;
|
|
56
56
|
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
57
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
57
|
+
if (!metaMap.has(tag)) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
58
58
|
const meta2 = metaMap.get(tag)[method];
|
|
59
|
-
if (!meta2) return resolve(await
|
|
60
|
-
const aop =
|
|
59
|
+
if (!meta2) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
60
|
+
const aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
61
61
|
globalFilter,
|
|
62
62
|
globalGuards,
|
|
63
63
|
globalPipe
|
|
@@ -81,7 +81,7 @@ function bind(router, data, opts = {}) {
|
|
|
81
81
|
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
82
82
|
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
83
83
|
};
|
|
84
|
-
const context = new (0,
|
|
84
|
+
const context = new (0, _chunkR73A7HS3js.Context)(contextData);
|
|
85
85
|
context.run(aop, resolve, resolve);
|
|
86
86
|
});
|
|
87
87
|
}));
|
|
@@ -100,15 +100,15 @@ function bind(router, data, opts = {}) {
|
|
|
100
100
|
const needBody = params.some((item) => item.type === "body");
|
|
101
101
|
let aop;
|
|
102
102
|
if (!dynamic) {
|
|
103
|
-
aop =
|
|
103
|
+
aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
104
104
|
globalFilter,
|
|
105
105
|
globalGuards,
|
|
106
106
|
globalPipe
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
110
|
-
|
|
111
|
-
subRouter[http.method](
|
|
110
|
+
_chunkR73A7HS3js.Context.applyAddons(addons, subRouter, "h3");
|
|
111
|
+
subRouter[http.method](_chunkR73A7HS3js.joinUrl.call(void 0, http.prefix, http.route), _h3.defineEventHandler.call(void 0, async (event) => {
|
|
112
112
|
debug(`invoke method "${method}" in module "${tag}"`);
|
|
113
113
|
const contextData = {
|
|
114
114
|
type: "h3",
|
|
@@ -134,10 +134,10 @@ function bind(router, data, opts = {}) {
|
|
|
134
134
|
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
135
135
|
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
136
136
|
};
|
|
137
|
-
const context = new (0,
|
|
137
|
+
const context = new (0, _chunkR73A7HS3js.Context)(contextData);
|
|
138
138
|
_h3.setHeaders.call(void 0, event, http.headers || {});
|
|
139
139
|
if (dynamic) {
|
|
140
|
-
aop =
|
|
140
|
+
aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
141
141
|
globalFilter,
|
|
142
142
|
globalGuards,
|
|
143
143
|
globalPipe
|
|
@@ -148,7 +148,7 @@ function bind(router, data, opts = {}) {
|
|
|
148
148
|
return err;
|
|
149
149
|
});
|
|
150
150
|
}));
|
|
151
|
-
router.use(
|
|
151
|
+
router.use(_chunkR73A7HS3js.joinUrl.call(void 0, http.prefix, http.route), _h3.useBase.call(void 0, "", subRouter.handler));
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}
|
package/dist/http/h3/index.mjs
CHANGED
package/dist/http/hono/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkR73A7HS3js = require('../../chunk-R73A7HS3.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkOUQM7GZHjs = require('../../chunk-OUQM7GZH.js');
|
|
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hono");
|
|
|
16
16
|
function bind(router, data, opts = {}) {
|
|
17
17
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
|
-
const metaMap =
|
|
19
|
+
const metaMap = _chunkR73A7HS3js.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
20
20
|
const { controller, http, method, tag } = meta2.data;
|
|
21
21
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
22
22
|
debug(`register method "${method}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
_chunkR73A7HS3js.detectAopDep.call(void 0, meta, {
|
|
27
27
|
addons: [
|
|
28
28
|
...globalAddons,
|
|
29
29
|
...parallelAddons
|
|
@@ -34,26 +34,26 @@ function bind(router, data, opts = {}) {
|
|
|
34
34
|
function registerRoute() {
|
|
35
35
|
if (parallelRoute) {
|
|
36
36
|
const subApp = new (0, _hono.Hono)();
|
|
37
|
-
|
|
37
|
+
_chunkR73A7HS3js.Context.applyAddons(parallelAddons, subApp, "hono");
|
|
38
38
|
subApp.post("", async (c) => {
|
|
39
39
|
const body = await c.req.json();
|
|
40
40
|
async function errorHandler(e) {
|
|
41
|
-
const error = await
|
|
41
|
+
const error = await _chunkR73A7HS3js.Context.filterRecord.default(e);
|
|
42
42
|
c.status(error.status);
|
|
43
43
|
return c.json(error);
|
|
44
44
|
}
|
|
45
45
|
_chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkR73A7HS3js.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
|
if (!item) return resolve(null);
|
|
51
51
|
const { tag, method } = item;
|
|
52
52
|
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
53
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
53
|
+
if (!metaMap.has(tag)) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
54
54
|
const meta2 = metaMap.get(tag)[method];
|
|
55
|
-
if (!meta2) return resolve(await
|
|
56
|
-
const aop =
|
|
55
|
+
if (!meta2) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
56
|
+
const aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
57
57
|
globalFilter,
|
|
58
58
|
globalGuards,
|
|
59
59
|
globalPipe
|
|
@@ -79,7 +79,7 @@ function bind(router, data, opts = {}) {
|
|
|
79
79
|
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
80
80
|
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => c.res, "getResponse")
|
|
81
81
|
};
|
|
82
|
-
const context = new (0,
|
|
82
|
+
const context = new (0, _chunkR73A7HS3js.Context)(contextData);
|
|
83
83
|
context.run(aop, resolve, resolve);
|
|
84
84
|
});
|
|
85
85
|
})).then((ret) => {
|
|
@@ -99,14 +99,14 @@ function bind(router, data, opts = {}) {
|
|
|
99
99
|
const needBody = params.some((item) => item.type === "body");
|
|
100
100
|
let aop;
|
|
101
101
|
if (!dynamic) {
|
|
102
|
-
aop =
|
|
102
|
+
aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
103
103
|
globalFilter,
|
|
104
104
|
globalGuards,
|
|
105
105
|
globalPipe
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
const subApp = new (0, _hono.Hono)();
|
|
109
|
-
|
|
109
|
+
_chunkR73A7HS3js.Context.applyAddons(addons, subApp, "hono");
|
|
110
110
|
subApp[http.method](http.route, async (c) => {
|
|
111
111
|
debug(`invoke method "${method}" in module "${tag}"`);
|
|
112
112
|
const contextData = {
|
|
@@ -133,12 +133,12 @@ function bind(router, data, opts = {}) {
|
|
|
133
133
|
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
134
134
|
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => c.res, "getResponse")
|
|
135
135
|
};
|
|
136
|
-
const context = new (0,
|
|
136
|
+
const context = new (0, _chunkR73A7HS3js.Context)(contextData);
|
|
137
137
|
if (http.headers) {
|
|
138
138
|
for (const name in http.headers) c.header(name, http.headers[name]);
|
|
139
139
|
}
|
|
140
140
|
if (dynamic) {
|
|
141
|
-
aop =
|
|
141
|
+
aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
142
142
|
globalFilter,
|
|
143
143
|
globalGuards,
|
|
144
144
|
globalPipe
|
package/dist/http/hono/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkR73A7HS3js = require('../../chunk-R73A7HS3.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkOUQM7GZHjs = require('../../chunk-OUQM7GZH.js');
|
|
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hyper-express");
|
|
|
16
16
|
function bind(router, data, opts = {}) {
|
|
17
17
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
|
-
const metaMap =
|
|
19
|
+
const metaMap = _chunkR73A7HS3js.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
20
20
|
const { controller, http, method, tag } = meta2.data;
|
|
21
21
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
22
22
|
debug(`register method "${method}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
_chunkR73A7HS3js.detectAopDep.call(void 0, meta, {
|
|
27
27
|
addons: [
|
|
28
28
|
...globalAddons,
|
|
29
29
|
...parallelAddons
|
|
@@ -32,27 +32,27 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
async function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunkR73A7HS3js.Context.applyAddons(globalAddons, router, "hyper-express");
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
const subRouter = new (0, _hyperexpress.Router)();
|
|
38
38
|
subRouter.post(parallelRoute, async (req, res, next) => {
|
|
39
39
|
const body = await req.json();
|
|
40
40
|
async function errorHandler(e) {
|
|
41
|
-
const error = await
|
|
41
|
+
const error = await _chunkR73A7HS3js.Context.filterRecord.default(e);
|
|
42
42
|
return res.status(error.status).json(error);
|
|
43
43
|
}
|
|
44
44
|
_chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
45
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
45
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkR73A7HS3js.BadRequestException)("data format should be an array"));
|
|
46
46
|
try {
|
|
47
47
|
return Promise.all(body.map((item, i) => {
|
|
48
48
|
return new Promise(async (resolve) => {
|
|
49
49
|
if (!item) return resolve(null);
|
|
50
50
|
const { tag, method } = item;
|
|
51
51
|
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
52
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
52
|
+
if (!metaMap.has(tag)) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
53
53
|
const meta2 = metaMap.get(tag)[method];
|
|
54
|
-
if (!meta2) return resolve(await
|
|
55
|
-
const aop =
|
|
54
|
+
if (!meta2) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
55
|
+
const aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
56
56
|
globalFilter,
|
|
57
57
|
globalGuards,
|
|
58
58
|
globalPipe
|
|
@@ -78,7 +78,7 @@ function bind(router, data, opts = {}) {
|
|
|
78
78
|
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => req, "getRequest"),
|
|
79
79
|
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => res, "getResponse")
|
|
80
80
|
};
|
|
81
|
-
const context = new (0,
|
|
81
|
+
const context = new (0, _chunkR73A7HS3js.Context)(contextData);
|
|
82
82
|
context.run(aop, resolve, resolve);
|
|
83
83
|
});
|
|
84
84
|
})).then((ret) => {
|
|
@@ -98,15 +98,15 @@ function bind(router, data, opts = {}) {
|
|
|
98
98
|
const needBody = params.some((item) => item.type === "body");
|
|
99
99
|
let aop;
|
|
100
100
|
if (!dynamic) {
|
|
101
|
-
aop =
|
|
101
|
+
aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
102
102
|
globalFilter,
|
|
103
103
|
globalGuards,
|
|
104
104
|
globalPipe
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
const subRouter = new (0, _hyperexpress.Router)();
|
|
108
|
-
|
|
109
|
-
subRouter[http.method](
|
|
108
|
+
_chunkR73A7HS3js.Context.applyAddons(addons, subRouter, "hyper-express");
|
|
109
|
+
subRouter[http.method](_chunkR73A7HS3js.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
|
|
110
110
|
debug(`invoke method "${method}" in module "${tag}"`);
|
|
111
111
|
const contextData = {
|
|
112
112
|
type: "hyper-express",
|
|
@@ -132,12 +132,12 @@ function bind(router, data, opts = {}) {
|
|
|
132
132
|
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => req, "getRequest"),
|
|
133
133
|
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => res, "getResponse")
|
|
134
134
|
};
|
|
135
|
-
const context = new (0,
|
|
135
|
+
const context = new (0, _chunkR73A7HS3js.Context)(contextData);
|
|
136
136
|
if (http.headers) {
|
|
137
137
|
for (const name in http.headers) res.set(name, http.headers[name]);
|
|
138
138
|
}
|
|
139
139
|
if (dynamic) {
|
|
140
|
-
aop =
|
|
140
|
+
aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
141
141
|
globalFilter,
|
|
142
142
|
globalGuards,
|
|
143
143
|
globalPipe
|
package/dist/http/koa/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkR73A7HS3js = require('../../chunk-R73A7HS3.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -18,14 +18,14 @@ function bind(router, data, opts = {}) {
|
|
|
18
18
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
19
19
|
const { moduleMap, meta } = data;
|
|
20
20
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkR73A7HS3js.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
22
|
const { controller, http, method, tag } = meta2.data;
|
|
23
23
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
24
24
|
debug(`register method "${method}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunkR73A7HS3js.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -34,29 +34,29 @@ function bind(router, data, opts = {}) {
|
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
36
|
function registerRoute() {
|
|
37
|
-
|
|
37
|
+
_chunkR73A7HS3js.Context.applyAddons(globalAddons, router, "koa");
|
|
38
38
|
if (parallelRoute) {
|
|
39
39
|
const subRouter = new (0, _router2.default)();
|
|
40
|
-
|
|
40
|
+
_chunkR73A7HS3js.Context.applyAddons(parallelAddons, subRouter, "koa");
|
|
41
41
|
subRouter.post(parallelRoute, async (ctx, next) => {
|
|
42
42
|
const { body } = ctx.request;
|
|
43
43
|
async function errorHandler(e) {
|
|
44
|
-
const error = await
|
|
44
|
+
const error = await _chunkR73A7HS3js.Context.filterRecord.default(e);
|
|
45
45
|
ctx.status = error.status;
|
|
46
46
|
ctx.body = error;
|
|
47
47
|
}
|
|
48
48
|
_chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
49
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
49
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkR73A7HS3js.BadRequestException)("data format should be an array"));
|
|
50
50
|
try {
|
|
51
51
|
return Promise.all(body.map((item, i) => {
|
|
52
52
|
return new Promise(async (resolve) => {
|
|
53
53
|
if (!item) return resolve(null);
|
|
54
54
|
const { tag, method } = item;
|
|
55
55
|
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
56
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
56
|
+
if (!metaMap.has(tag)) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
57
57
|
const meta2 = metaMap.get(tag)[method];
|
|
58
|
-
if (!meta2) return resolve(await
|
|
59
|
-
const aop =
|
|
58
|
+
if (!meta2) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
59
|
+
const aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
60
60
|
globalGuards,
|
|
61
61
|
globalFilter,
|
|
62
62
|
globalPipe
|
|
@@ -83,7 +83,7 @@ function bind(router, data, opts = {}) {
|
|
|
83
83
|
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
84
84
|
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
85
85
|
};
|
|
86
|
-
const context = new (0,
|
|
86
|
+
const context = new (0, _chunkR73A7HS3js.Context)(contextData);
|
|
87
87
|
context.run(aop, resolve, resolve);
|
|
88
88
|
});
|
|
89
89
|
})).then((ret) => {
|
|
@@ -102,15 +102,15 @@ function bind(router, data, opts = {}) {
|
|
|
102
102
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.method])) continue;
|
|
103
103
|
let aop;
|
|
104
104
|
if (!dynamic) {
|
|
105
|
-
aop =
|
|
105
|
+
aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
106
106
|
globalFilter,
|
|
107
107
|
globalGuards,
|
|
108
108
|
globalPipe
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
const subRouter = new (0, _router2.default)();
|
|
112
|
-
|
|
113
|
-
router[http.method](
|
|
112
|
+
_chunkR73A7HS3js.Context.applyAddons(addons, subRouter, "koa");
|
|
113
|
+
router[http.method](_chunkR73A7HS3js.joinUrl.call(void 0, http.prefix, http.route), async (ctx, next) => {
|
|
114
114
|
debug(`invoke method "${method}" in module "${tag}"`);
|
|
115
115
|
const contextData = {
|
|
116
116
|
type: "koa",
|
|
@@ -137,10 +137,10 @@ function bind(router, data, opts = {}) {
|
|
|
137
137
|
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
138
138
|
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
139
139
|
};
|
|
140
|
-
const context = new (0,
|
|
140
|
+
const context = new (0, _chunkR73A7HS3js.Context)(contextData);
|
|
141
141
|
if (http.headers) ctx.set(http.headers);
|
|
142
142
|
if (dynamic) {
|
|
143
|
-
aop =
|
|
143
|
+
aop = _chunkR73A7HS3js.Context.getAop(meta2, {
|
|
144
144
|
globalFilter,
|
|
145
145
|
globalGuards,
|
|
146
146
|
globalPipe
|