phecda-server 7.1.4 → 8.0.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-MKRHYZCL.mjs → chunk-FI5756JX.mjs} +2 -2
- package/dist/{chunk-YRS4ECPT.js → chunk-OLNN4U3O.js} +12 -8
- package/dist/{chunk-5MAGRSEM.mjs → chunk-PFPOEZHH.mjs} +12 -8
- package/dist/{chunk-DPPDWBYO.js → chunk-UYZSUBX4.js} +2 -2
- package/dist/{chunk-P3CS65OP.mjs → chunk-VAHCYYCB.mjs} +32 -17
- package/dist/{chunk-OV3UJLGP.js → chunk-YJ3QHGTC.js} +32 -17
- package/dist/{core-B5yKYkMJ.d.mts → core-BTSHIAyB.d.ts} +2 -1
- package/dist/{core-BRuvL6hY.d.ts → core-D1YYphEn.d.mts} +2 -1
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +2 -2
- package/dist/helper.mjs +1 -1
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +30 -30
- package/dist/http/elysia/index.mjs +15 -15
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +27 -27
- package/dist/http/express/index.mjs +14 -14
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +29 -29
- package/dist/http/fastify/index.mjs +15 -15
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +28 -28
- package/dist/http/h3/index.mjs +14 -14
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +26 -26
- package/dist/http/hono/index.mjs +14 -14
- package/dist/http/hyper-express/index.d.mts +3 -3
- package/dist/http/hyper-express/index.d.ts +3 -3
- package/dist/http/hyper-express/index.js +26 -26
- package/dist/http/hyper-express/index.mjs +14 -14
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +27 -27
- package/dist/http/koa/index.mjs +14 -14
- package/dist/index.d.mts +20 -13
- package/dist/index.d.ts +20 -13
- package/dist/index.js +112 -71
- package/dist/index.mjs +69 -28
- package/dist/{meta-C_eDyXnK.d.ts → meta-DNF6Fl27.d.mts} +11 -9
- package/dist/{meta-C_eDyXnK.d.mts → meta-DNF6Fl27.d.ts} +11 -9
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +16 -16
- package/dist/rpc/bullmq/index.mjs +11 -11
- package/dist/rpc/electron/index.d.mts +3 -3
- package/dist/rpc/electron/index.d.ts +3 -3
- package/dist/rpc/electron/index.js +11 -11
- package/dist/rpc/electron/index.mjs +7 -7
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +9 -9
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +14 -14
- package/dist/rpc/nats/index.mjs +9 -9
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +14 -14
- package/dist/rpc/rabbitmq/index.mjs +9 -9
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +14 -14
- package/dist/rpc/redis/index.mjs +9 -9
- package/dist/rpc/ws/index.d.mts +3 -3
- package/dist/rpc/ws/index.d.ts +3 -3
- package/dist/rpc/ws/index.js +10 -10
- package/dist/rpc/ws/index.mjs +6 -6
- package/dist/test.d.mts +2 -2
- package/dist/test.d.ts +2 -2
- package/dist/test.js +5 -5
- package/dist/test.mjs +4 -4
- package/dist/{types-7-m2wEkP.d.mts → types-BOZ8yE2L.d.mts} +1 -1
- package/dist/{types-BuvMT1ta.d.ts → types-Cosv4nol.d.ts} +1 -1
- package/dist/{types-BKHBmSQN.d.mts → types-DtiHAXQB.d.mts} +1 -1
- package/dist/{types-B6aU8oT-.d.ts → types-YJ55P7A_.d.ts} +1 -1
- package/package.json +3 -4
- package/register/export.mjs +5 -1
package/dist/http/h3/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkYJ3QHGTCjs = require('../../chunk-YJ3QHGTC.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.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 =
|
|
20
|
-
const { controller, http,
|
|
21
|
-
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.
|
|
22
|
-
debug(`register method "${
|
|
19
|
+
const metaMap = _chunkYJ3QHGTCjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
20
|
+
const { controller, http, method, tag } = meta2.data;
|
|
21
|
+
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
22
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
_chunkYJ3QHGTCjs.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
|
+
_chunkYJ3QHGTCjs.Context.applyAddons(globalAddons, router, "h3");
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
38
|
-
|
|
38
|
+
_chunkYJ3QHGTCjs.Context.applyAddons(parallelAddons, subRouter, "h3");
|
|
39
39
|
subRouter.post(parallelRoute, _h3.eventHandler.call(void 0, {
|
|
40
40
|
handler: /* @__PURE__ */ _chunk4LLLQOMFjs.__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 _chunkYJ3QHGTCjs.Context.filterRecord.default(e);
|
|
46
46
|
_h3.setResponseStatus.call(void 0, event, error.status);
|
|
47
47
|
return error;
|
|
48
48
|
}
|
|
49
49
|
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkYJ3QHGTCjs.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
|
-
const { tag,
|
|
56
|
-
debug(`(parallel)invoke method "${
|
|
57
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
58
|
-
const meta2 = metaMap.get(tag)[
|
|
59
|
-
if (!meta2) return resolve(await
|
|
60
|
-
const aop =
|
|
55
|
+
const { tag, method } = item;
|
|
56
|
+
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
57
|
+
if (!metaMap.has(tag)) return resolve(await _chunkYJ3QHGTCjs.Context.filterRecord.default(new (0, _chunkYJ3QHGTCjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
58
|
+
const meta2 = metaMap.get(tag)[method];
|
|
59
|
+
if (!meta2) return resolve(await _chunkYJ3QHGTCjs.Context.filterRecord.default(new (0, _chunkYJ3QHGTCjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
60
|
+
const aop = _chunkYJ3QHGTCjs.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__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
82
82
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
83
83
|
};
|
|
84
|
-
const context = new (0,
|
|
84
|
+
const context = new (0, _chunkYJ3QHGTCjs.Context)(contextData);
|
|
85
85
|
context.run(aop, resolve, resolve);
|
|
86
86
|
});
|
|
87
87
|
}));
|
|
@@ -93,23 +93,23 @@ function bind(router, data, opts = {}) {
|
|
|
93
93
|
router.use(parallelRoute, _h3.useBase.call(void 0, "", subRouter.handler));
|
|
94
94
|
}
|
|
95
95
|
for (const [tag, record] of metaMap) {
|
|
96
|
-
for (const
|
|
97
|
-
const meta2 = metaMap.get(tag)[
|
|
96
|
+
for (const method in record) {
|
|
97
|
+
const meta2 = metaMap.get(tag)[method];
|
|
98
98
|
const { data: { http, params, addons } } = meta2;
|
|
99
|
-
if (!_optionalChain([http, 'optionalAccess', _2 => _2.
|
|
99
|
+
if (!_optionalChain([http, 'optionalAccess', _2 => _2.method])) continue;
|
|
100
100
|
const needBody = params.some((item) => item.type === "body");
|
|
101
101
|
let aop;
|
|
102
102
|
if (!dynamic) {
|
|
103
|
-
aop =
|
|
103
|
+
aop = _chunkYJ3QHGTCjs.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.
|
|
112
|
-
debug(`invoke method "${
|
|
110
|
+
_chunkYJ3QHGTCjs.Context.applyAddons(addons, subRouter, "h3");
|
|
111
|
+
subRouter[http.method](_chunkYJ3QHGTCjs.joinUrl.call(void 0, http.prefix, http.route), _h3.defineEventHandler.call(void 0, async (event) => {
|
|
112
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
113
113
|
const contextData = {
|
|
114
114
|
type: "h3",
|
|
115
115
|
category: "http",
|
|
@@ -117,7 +117,7 @@ function bind(router, data, opts = {}) {
|
|
|
117
117
|
event,
|
|
118
118
|
moduleMap,
|
|
119
119
|
tag,
|
|
120
|
-
|
|
120
|
+
method,
|
|
121
121
|
headers: _h3.getRequestHeaders.call(void 0, event),
|
|
122
122
|
params: _h3.getRouterParams.call(void 0, event),
|
|
123
123
|
query: _h3.getQuery.call(void 0, event),
|
|
@@ -134,10 +134,10 @@ function bind(router, data, opts = {}) {
|
|
|
134
134
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
135
135
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
136
136
|
};
|
|
137
|
-
const context = new (0,
|
|
137
|
+
const context = new (0, _chunkYJ3QHGTCjs.Context)(contextData);
|
|
138
138
|
_h3.setHeaders.call(void 0, event, http.headers || {});
|
|
139
139
|
if (dynamic) {
|
|
140
|
-
aop =
|
|
140
|
+
aop = _chunkYJ3QHGTCjs.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(_chunkYJ3QHGTCjs.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
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
joinUrl
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-VAHCYYCB.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
10
|
} from "../../chunk-NQ55PA2X.mjs";
|
|
@@ -17,9 +17,9 @@ 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
19
|
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
20
|
-
const { controller, http,
|
|
21
|
-
if (controller === "http" && http?.
|
|
22
|
-
debug(`register method "${
|
|
20
|
+
const { controller, http, method, tag } = meta2.data;
|
|
21
|
+
if (controller === "http" && http?.method) {
|
|
22
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
@@ -52,11 +52,11 @@ function bind(router, data, opts = {}) {
|
|
|
52
52
|
return Promise.all(body.map((item, i) => {
|
|
53
53
|
return new Promise(async (resolve) => {
|
|
54
54
|
if (!item) return resolve(null);
|
|
55
|
-
const { tag,
|
|
56
|
-
debug(`(parallel)invoke method "${
|
|
55
|
+
const { tag, method } = item;
|
|
56
|
+
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
57
57
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
58
|
-
const meta2 = metaMap.get(tag)[
|
|
59
|
-
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${
|
|
58
|
+
const meta2 = metaMap.get(tag)[method];
|
|
59
|
+
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${method}" in "${tag}" doesn't exist`)));
|
|
60
60
|
const aop = Context.getAop(meta2, {
|
|
61
61
|
globalFilter,
|
|
62
62
|
globalGuards,
|
|
@@ -93,10 +93,10 @@ function bind(router, data, opts = {}) {
|
|
|
93
93
|
router.use(parallelRoute, useBase("", subRouter.handler));
|
|
94
94
|
}
|
|
95
95
|
for (const [tag, record] of metaMap) {
|
|
96
|
-
for (const
|
|
97
|
-
const meta2 = metaMap.get(tag)[
|
|
96
|
+
for (const method in record) {
|
|
97
|
+
const meta2 = metaMap.get(tag)[method];
|
|
98
98
|
const { data: { http, params, addons } } = meta2;
|
|
99
|
-
if (!http?.
|
|
99
|
+
if (!http?.method) continue;
|
|
100
100
|
const needBody = params.some((item) => item.type === "body");
|
|
101
101
|
let aop;
|
|
102
102
|
if (!dynamic) {
|
|
@@ -108,8 +108,8 @@ function bind(router, data, opts = {}) {
|
|
|
108
108
|
}
|
|
109
109
|
const subRouter = createRouter();
|
|
110
110
|
Context.applyAddons(addons, subRouter, "h3");
|
|
111
|
-
subRouter[http.
|
|
112
|
-
debug(`invoke method "${
|
|
111
|
+
subRouter[http.method](joinUrl(http.prefix, http.route), defineEventHandler(async (event) => {
|
|
112
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
113
113
|
const contextData = {
|
|
114
114
|
type: "h3",
|
|
115
115
|
category: "http",
|
|
@@ -117,7 +117,7 @@ function bind(router, data, opts = {}) {
|
|
|
117
117
|
event,
|
|
118
118
|
moduleMap,
|
|
119
119
|
tag,
|
|
120
|
-
|
|
120
|
+
method,
|
|
121
121
|
headers: getRequestHeaders(event),
|
|
122
122
|
params: getRouterParams(event),
|
|
123
123
|
query: getQuery(event),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context, Hono, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-DtiHAXQB.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-D1YYphEn.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HonoCtx extends HttpCtx {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context, Hono, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-Cosv4nol.js';
|
|
3
|
+
import { F as Factory } from '../../core-BTSHIAyB.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HonoCtx extends HttpCtx {
|
package/dist/http/hono/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkYJ3QHGTCjs = require('../../chunk-YJ3QHGTC.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.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 =
|
|
20
|
-
const { controller, http,
|
|
21
|
-
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.
|
|
22
|
-
debug(`register method "${
|
|
19
|
+
const metaMap = _chunkYJ3QHGTCjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
20
|
+
const { controller, http, method, tag } = meta2.data;
|
|
21
|
+
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
22
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
_chunkYJ3QHGTCjs.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
|
+
_chunkYJ3QHGTCjs.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 _chunkYJ3QHGTCjs.Context.filterRecord.default(e);
|
|
42
42
|
c.status(error.status);
|
|
43
43
|
return c.json(error);
|
|
44
44
|
}
|
|
45
45
|
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkYJ3QHGTCjs.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
|
-
const { tag,
|
|
52
|
-
debug(`(parallel)invoke method "${
|
|
53
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
54
|
-
const meta2 = metaMap.get(tag)[
|
|
55
|
-
if (!meta2) return resolve(await
|
|
56
|
-
const aop =
|
|
51
|
+
const { tag, method } = item;
|
|
52
|
+
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
53
|
+
if (!metaMap.has(tag)) return resolve(await _chunkYJ3QHGTCjs.Context.filterRecord.default(new (0, _chunkYJ3QHGTCjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
54
|
+
const meta2 = metaMap.get(tag)[method];
|
|
55
|
+
if (!meta2) return resolve(await _chunkYJ3QHGTCjs.Context.filterRecord.default(new (0, _chunkYJ3QHGTCjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
56
|
+
const aop = _chunkYJ3QHGTCjs.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__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
80
80
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => c.res, "getResponse")
|
|
81
81
|
};
|
|
82
|
-
const context = new (0,
|
|
82
|
+
const context = new (0, _chunkYJ3QHGTCjs.Context)(contextData);
|
|
83
83
|
context.run(aop, resolve, resolve);
|
|
84
84
|
});
|
|
85
85
|
})).then((ret) => {
|
|
@@ -92,23 +92,23 @@ function bind(router, data, opts = {}) {
|
|
|
92
92
|
router.route(parallelRoute, subApp);
|
|
93
93
|
}
|
|
94
94
|
for (const [tag, record] of metaMap) {
|
|
95
|
-
for (const
|
|
96
|
-
const meta2 = metaMap.get(tag)[
|
|
95
|
+
for (const method in record) {
|
|
96
|
+
const meta2 = metaMap.get(tag)[method];
|
|
97
97
|
const { data: { params, addons, http } } = meta2;
|
|
98
|
-
if (!_optionalChain([http, 'optionalAccess', _2 => _2.
|
|
98
|
+
if (!_optionalChain([http, 'optionalAccess', _2 => _2.method])) continue;
|
|
99
99
|
const needBody = params.some((item) => item.type === "body");
|
|
100
100
|
let aop;
|
|
101
101
|
if (!dynamic) {
|
|
102
|
-
aop =
|
|
102
|
+
aop = _chunkYJ3QHGTCjs.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
|
-
|
|
110
|
-
subApp[http.
|
|
111
|
-
debug(`invoke method "${
|
|
109
|
+
_chunkYJ3QHGTCjs.Context.applyAddons(addons, subApp, "hono");
|
|
110
|
+
subApp[http.method](http.route, async (c) => {
|
|
111
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
112
112
|
const contextData = {
|
|
113
113
|
type: "hono",
|
|
114
114
|
category: "http",
|
|
@@ -116,7 +116,7 @@ function bind(router, data, opts = {}) {
|
|
|
116
116
|
meta: meta2,
|
|
117
117
|
moduleMap,
|
|
118
118
|
tag,
|
|
119
|
-
|
|
119
|
+
method,
|
|
120
120
|
query: c.req.query(),
|
|
121
121
|
body: needBody ? await c.req.json() : void 0,
|
|
122
122
|
params: c.req.param(),
|
|
@@ -133,12 +133,12 @@ function bind(router, data, opts = {}) {
|
|
|
133
133
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
134
134
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => c.res, "getResponse")
|
|
135
135
|
};
|
|
136
|
-
const context = new (0,
|
|
136
|
+
const context = new (0, _chunkYJ3QHGTCjs.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 = _chunkYJ3QHGTCjs.Context.getAop(meta2, {
|
|
142
142
|
globalFilter,
|
|
143
143
|
globalGuards,
|
|
144
144
|
globalPipe
|
package/dist/http/hono/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Context,
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-VAHCYYCB.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
9
|
} from "../../chunk-NQ55PA2X.mjs";
|
|
@@ -17,9 +17,9 @@ 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
19
|
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
20
|
-
const { controller, http,
|
|
21
|
-
if (controller === "http" && http?.
|
|
22
|
-
debug(`register method "${
|
|
20
|
+
const { controller, http, method, tag } = meta2.data;
|
|
21
|
+
if (controller === "http" && http?.method) {
|
|
22
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
@@ -48,11 +48,11 @@ function bind(router, data, opts = {}) {
|
|
|
48
48
|
return Promise.all(body.map((item, i) => {
|
|
49
49
|
return new Promise(async (resolve) => {
|
|
50
50
|
if (!item) return resolve(null);
|
|
51
|
-
const { tag,
|
|
52
|
-
debug(`(parallel)invoke method "${
|
|
51
|
+
const { tag, method } = item;
|
|
52
|
+
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
53
53
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
54
|
-
const meta2 = metaMap.get(tag)[
|
|
55
|
-
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${
|
|
54
|
+
const meta2 = metaMap.get(tag)[method];
|
|
55
|
+
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${method}" in "${tag}" doesn't exist`)));
|
|
56
56
|
const aop = Context.getAop(meta2, {
|
|
57
57
|
globalFilter,
|
|
58
58
|
globalGuards,
|
|
@@ -92,10 +92,10 @@ function bind(router, data, opts = {}) {
|
|
|
92
92
|
router.route(parallelRoute, subApp);
|
|
93
93
|
}
|
|
94
94
|
for (const [tag, record] of metaMap) {
|
|
95
|
-
for (const
|
|
96
|
-
const meta2 = metaMap.get(tag)[
|
|
95
|
+
for (const method in record) {
|
|
96
|
+
const meta2 = metaMap.get(tag)[method];
|
|
97
97
|
const { data: { params, addons, http } } = meta2;
|
|
98
|
-
if (!http?.
|
|
98
|
+
if (!http?.method) continue;
|
|
99
99
|
const needBody = params.some((item) => item.type === "body");
|
|
100
100
|
let aop;
|
|
101
101
|
if (!dynamic) {
|
|
@@ -107,8 +107,8 @@ function bind(router, data, opts = {}) {
|
|
|
107
107
|
}
|
|
108
108
|
const subApp = new Hono();
|
|
109
109
|
Context.applyAddons(addons, subApp, "hono");
|
|
110
|
-
subApp[http.
|
|
111
|
-
debug(`invoke method "${
|
|
110
|
+
subApp[http.method](http.route, async (c) => {
|
|
111
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
112
112
|
const contextData = {
|
|
113
113
|
type: "hono",
|
|
114
114
|
category: "http",
|
|
@@ -116,7 +116,7 @@ function bind(router, data, opts = {}) {
|
|
|
116
116
|
meta: meta2,
|
|
117
117
|
moduleMap,
|
|
118
118
|
tag,
|
|
119
|
-
|
|
119
|
+
method,
|
|
120
120
|
query: c.req.query(),
|
|
121
121
|
body: needBody ? await c.req.json() : void 0,
|
|
122
122
|
params: c.req.param(),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-DtiHAXQB.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-D1YYphEn.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HyperExpressCtx extends HttpCtx {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-Cosv4nol.js';
|
|
3
|
+
import { F as Factory } from '../../core-BTSHIAyB.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HyperExpressCtx extends HttpCtx {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkYJ3QHGTCjs = require('../../chunk-YJ3QHGTC.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.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 =
|
|
20
|
-
const { controller, http,
|
|
21
|
-
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.
|
|
22
|
-
debug(`register method "${
|
|
19
|
+
const metaMap = _chunkYJ3QHGTCjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
20
|
+
const { controller, http, method, tag } = meta2.data;
|
|
21
|
+
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
22
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
_chunkYJ3QHGTCjs.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
|
+
_chunkYJ3QHGTCjs.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 _chunkYJ3QHGTCjs.Context.filterRecord.default(e);
|
|
42
42
|
return res.status(error.status).json(error);
|
|
43
43
|
}
|
|
44
44
|
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
45
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
45
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkYJ3QHGTCjs.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
|
-
const { tag,
|
|
51
|
-
debug(`(parallel)invoke method "${
|
|
52
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
53
|
-
const meta2 = metaMap.get(tag)[
|
|
54
|
-
if (!meta2) return resolve(await
|
|
55
|
-
const aop =
|
|
50
|
+
const { tag, method } = item;
|
|
51
|
+
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
52
|
+
if (!metaMap.has(tag)) return resolve(await _chunkYJ3QHGTCjs.Context.filterRecord.default(new (0, _chunkYJ3QHGTCjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
53
|
+
const meta2 = metaMap.get(tag)[method];
|
|
54
|
+
if (!meta2) return resolve(await _chunkYJ3QHGTCjs.Context.filterRecord.default(new (0, _chunkYJ3QHGTCjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
55
|
+
const aop = _chunkYJ3QHGTCjs.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__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req, "getRequest"),
|
|
79
79
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res, "getResponse")
|
|
80
80
|
};
|
|
81
|
-
const context = new (0,
|
|
81
|
+
const context = new (0, _chunkYJ3QHGTCjs.Context)(contextData);
|
|
82
82
|
context.run(aop, resolve, resolve);
|
|
83
83
|
});
|
|
84
84
|
})).then((ret) => {
|
|
@@ -91,23 +91,23 @@ function bind(router, data, opts = {}) {
|
|
|
91
91
|
router.use(subRouter);
|
|
92
92
|
}
|
|
93
93
|
for (const [tag, record] of metaMap) {
|
|
94
|
-
for (const
|
|
95
|
-
const meta2 = metaMap.get(tag)[
|
|
94
|
+
for (const method in record) {
|
|
95
|
+
const meta2 = metaMap.get(tag)[method];
|
|
96
96
|
const { data: { params, addons, http } } = meta2;
|
|
97
|
-
if (!_optionalChain([http, 'optionalAccess', _3 => _3.
|
|
97
|
+
if (!_optionalChain([http, 'optionalAccess', _3 => _3.method])) continue;
|
|
98
98
|
const needBody = params.some((item) => item.type === "body");
|
|
99
99
|
let aop;
|
|
100
100
|
if (!dynamic) {
|
|
101
|
-
aop =
|
|
101
|
+
aop = _chunkYJ3QHGTCjs.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.
|
|
110
|
-
debug(`invoke method "${
|
|
108
|
+
_chunkYJ3QHGTCjs.Context.applyAddons(addons, subRouter, "hyper-express");
|
|
109
|
+
subRouter[http.method](_chunkYJ3QHGTCjs.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
|
|
110
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
111
111
|
const contextData = {
|
|
112
112
|
type: "hyper-express",
|
|
113
113
|
category: "http",
|
|
@@ -116,7 +116,7 @@ function bind(router, data, opts = {}) {
|
|
|
116
116
|
response: res,
|
|
117
117
|
moduleMap,
|
|
118
118
|
tag,
|
|
119
|
-
|
|
119
|
+
method,
|
|
120
120
|
query: req.query_parameters,
|
|
121
121
|
body: needBody ? await req.json({}) : void 0,
|
|
122
122
|
app: router,
|
|
@@ -132,12 +132,12 @@ function bind(router, data, opts = {}) {
|
|
|
132
132
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req, "getRequest"),
|
|
133
133
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res, "getResponse")
|
|
134
134
|
};
|
|
135
|
-
const context = new (0,
|
|
135
|
+
const context = new (0, _chunkYJ3QHGTCjs.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 = _chunkYJ3QHGTCjs.Context.getAop(meta2, {
|
|
141
141
|
globalFilter,
|
|
142
142
|
globalGuards,
|
|
143
143
|
globalPipe
|