phecda-server 7.0.0-alpha.0 → 7.0.0-alpha.10
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/assets/ps.json +24 -24
- package/assets/schema.json +55 -55
- package/bin/cli.mjs +31 -18
- package/dist/chunk-4LLLQOMF.js +152 -0
- package/dist/{chunk-BGXSMOLX.js → chunk-6OQ2SB5W.js} +138 -70
- package/dist/{chunk-SW5IKE5H.js → chunk-G7JFKM2M.js} +136 -89
- package/dist/{chunk-MBCHNDAY.js → chunk-KCPBITYZ.js} +24 -24
- package/dist/{chunk-HMVLXNV3.mjs → chunk-MUI6MTUO.mjs} +1 -1
- package/dist/chunk-NQ55PA2X.mjs +152 -0
- package/dist/{chunk-5622RBNB.mjs → chunk-YCES6ABN.mjs} +125 -57
- package/dist/{chunk-P75VKZJY.mjs → chunk-Z7NAAE4M.mjs} +94 -47
- package/dist/{core-BIcUwV18.d.mts → core-CUTbX_IS.d.ts} +5 -3
- package/dist/{core-CYwEPfN4.d.ts → core-DIfgUKIU.d.mts} +5 -3
- package/dist/helper.d.mts +8 -6
- package/dist/helper.d.ts +8 -6
- package/dist/helper.js +8 -3
- package/dist/helper.mjs +10 -5
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +43 -44
- package/dist/http/elysia/index.mjs +9 -10
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +40 -41
- package/dist/http/express/index.mjs +9 -10
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +41 -42
- package/dist/http/fastify/index.mjs +9 -10
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +41 -42
- package/dist/http/h3/index.mjs +9 -10
- package/dist/http/hono/index.d.mts +4 -4
- package/dist/http/hono/index.d.ts +4 -4
- package/dist/http/hono/index.js +37 -39
- package/dist/http/hono/index.mjs +5 -7
- package/dist/http/hyper-express/index.d.mts +4 -4
- package/dist/http/hyper-express/index.d.ts +4 -4
- package/dist/http/hyper-express/index.js +38 -39
- package/dist/http/hyper-express/index.mjs +8 -9
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +40 -41
- package/dist/http/koa/index.mjs +9 -10
- package/dist/index.d.mts +46 -40
- package/dist/index.d.ts +46 -40
- package/dist/index.js +48 -42
- package/dist/index.mjs +21 -15
- package/dist/{meta-BXKLFTgG.d.mts → meta-CR-D39hQ.d.mts} +7 -5
- package/dist/{meta-BXKLFTgG.d.ts → meta-CR-D39hQ.d.ts} +7 -5
- package/dist/rpc/bullmq/index.d.mts +5 -5
- package/dist/rpc/bullmq/index.d.ts +5 -5
- package/dist/rpc/bullmq/index.js +15 -14
- package/dist/rpc/bullmq/index.mjs +4 -3
- package/dist/rpc/kafka/index.d.mts +4 -4
- package/dist/rpc/kafka/index.d.ts +4 -4
- package/dist/rpc/kafka/index.js +15 -14
- package/dist/rpc/kafka/index.mjs +3 -2
- package/dist/rpc/nats/index.d.mts +4 -4
- package/dist/rpc/nats/index.d.ts +4 -4
- package/dist/rpc/nats/index.js +14 -13
- package/dist/rpc/nats/index.mjs +4 -3
- package/dist/rpc/rabbitmq/index.d.mts +4 -4
- package/dist/rpc/rabbitmq/index.d.ts +4 -4
- package/dist/rpc/rabbitmq/index.js +16 -15
- package/dist/rpc/rabbitmq/index.mjs +4 -3
- package/dist/rpc/redis/index.d.mts +4 -4
- package/dist/rpc/redis/index.d.ts +4 -4
- package/dist/rpc/redis/index.js +14 -13
- package/dist/rpc/redis/index.mjs +4 -3
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types-h40T3cRG.d.mts → types-BF1TDbFV.d.ts} +4 -3
- package/dist/{types-BtbL49Zs.d.mts → types-DYRu0vic.d.ts} +4 -3
- package/dist/{types-VFzEM7LL.d.ts → types-DYviSl5B.d.mts} +4 -3
- package/dist/{types-m3IEDKjP.d.ts → types-DqH1qA-q.d.mts} +4 -3
- package/package.json +8 -5
- package/register/export.mjs +30 -0
- package/register/index.mjs +50 -40
- package/register/loader.mjs +384 -367
- package/register/utils.mjs +60 -56
- package/dist/chunk-J5CFUN4V.js +0 -73
- package/dist/chunk-WHJ5FALK.mjs +0 -73
package/dist/http/hono/index.js
CHANGED
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunkG7JFKM2Mjs = require('../../chunk-G7JFKM2M.js');
|
|
6
7
|
|
|
7
|
-
var _chunkSW5IKE5Hjs = require('../../chunk-SW5IKE5H.js');
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
|
|
9
|
+
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
11
10
|
|
|
12
11
|
// src/http/hono/bind.ts
|
|
13
12
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -17,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hono");
|
|
|
17
16
|
function bind(router, data, opts = {}) {
|
|
18
17
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
19
18
|
const { moduleMap, meta } = data;
|
|
20
|
-
const metaMap =
|
|
19
|
+
const metaMap = _chunkG7JFKM2Mjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
21
20
|
const { controller, http, func, tag } = meta2.data;
|
|
22
21
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
23
22
|
debug(`register method "${func}" in module "${tag}"`);
|
|
24
23
|
return true;
|
|
25
24
|
}
|
|
26
25
|
});
|
|
27
|
-
|
|
26
|
+
_chunkG7JFKM2Mjs.detectAopDep.call(void 0, meta, {
|
|
28
27
|
addons: [
|
|
29
28
|
...globalAddons,
|
|
30
29
|
...parallelAddons
|
|
@@ -35,26 +34,25 @@ function bind(router, data, opts = {}) {
|
|
|
35
34
|
function registerRoute() {
|
|
36
35
|
if (parallelRoute) {
|
|
37
36
|
const subApp = new (0, _hono.Hono)();
|
|
38
|
-
|
|
37
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(parallelAddons, subApp, "hono");
|
|
39
38
|
subApp.post("", async (c) => {
|
|
40
39
|
const body = await c.req.json();
|
|
41
40
|
async function errorHandler(e) {
|
|
42
|
-
const error = await
|
|
41
|
+
const error = await _chunkG7JFKM2Mjs.Context.filterRecord.default(e);
|
|
43
42
|
c.status(error.status);
|
|
44
43
|
return c.json(error);
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
45
|
+
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkG7JFKM2Mjs.BadRequestException)("data format should be an array"));
|
|
48
47
|
try {
|
|
49
48
|
return Promise.all(body.map((item, i) => {
|
|
50
49
|
return new Promise(async (resolve) => {
|
|
51
50
|
const { tag, func } = item;
|
|
52
51
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
53
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
52
|
+
if (!metaMap.has(tag)) return resolve(await _chunkG7JFKM2Mjs.Context.filterRecord.default(new (0, _chunkG7JFKM2Mjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
54
53
|
const meta2 = metaMap.get(tag)[func];
|
|
55
|
-
if (!meta2) return resolve(await
|
|
56
|
-
const
|
|
57
|
-
const aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
|
|
54
|
+
if (!meta2) return resolve(await _chunkG7JFKM2Mjs.Context.filterRecord.default(new (0, _chunkG7JFKM2Mjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
55
|
+
const aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
58
56
|
globalFilter,
|
|
59
57
|
globalGuards,
|
|
60
58
|
globalPipe
|
|
@@ -62,26 +60,25 @@ function bind(router, data, opts = {}) {
|
|
|
62
60
|
const contextData = {
|
|
63
61
|
type: "hono",
|
|
64
62
|
parallel: true,
|
|
63
|
+
category: "http",
|
|
65
64
|
context: c,
|
|
66
65
|
index: i,
|
|
67
66
|
meta: meta2,
|
|
68
67
|
moduleMap,
|
|
69
|
-
tag,
|
|
70
|
-
func,
|
|
71
68
|
app: router,
|
|
72
|
-
...
|
|
73
|
-
getCookie: /* @__PURE__ */
|
|
74
|
-
delCookie: /* @__PURE__ */
|
|
75
|
-
setCookie: /* @__PURE__ */
|
|
76
|
-
redirect: /* @__PURE__ */
|
|
77
|
-
setResHeaders: /* @__PURE__ */
|
|
69
|
+
...item,
|
|
70
|
+
getCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
71
|
+
delCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
72
|
+
setCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
73
|
+
redirect: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
74
|
+
setResHeaders: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (headers) => {
|
|
78
75
|
for (const name in headers) c.header(name, headers[name]);
|
|
79
76
|
}, "setResHeaders"),
|
|
80
|
-
setResStatus: /* @__PURE__ */
|
|
81
|
-
getRequest: /* @__PURE__ */
|
|
82
|
-
getResponse: /* @__PURE__ */
|
|
77
|
+
setResStatus: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
78
|
+
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
79
|
+
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => c.res, "getResponse")
|
|
83
80
|
};
|
|
84
|
-
const context = new (0,
|
|
81
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)(contextData);
|
|
85
82
|
context.run(aop, resolve, resolve);
|
|
86
83
|
});
|
|
87
84
|
})).then((ret) => {
|
|
@@ -101,18 +98,19 @@ function bind(router, data, opts = {}) {
|
|
|
101
98
|
const needBody = params.some((item) => item.type === "body");
|
|
102
99
|
let aop;
|
|
103
100
|
if (!dynamic) {
|
|
104
|
-
aop =
|
|
101
|
+
aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
105
102
|
globalFilter,
|
|
106
103
|
globalGuards,
|
|
107
104
|
globalPipe
|
|
108
105
|
});
|
|
109
106
|
}
|
|
110
107
|
const subApp = new (0, _hono.Hono)();
|
|
111
|
-
|
|
108
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(addons, subApp, "hono");
|
|
112
109
|
subApp[http.type](http.route, async (c) => {
|
|
113
110
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
114
111
|
const contextData = {
|
|
115
112
|
type: "hono",
|
|
113
|
+
category: "http",
|
|
116
114
|
context: c,
|
|
117
115
|
meta: meta2,
|
|
118
116
|
moduleMap,
|
|
@@ -123,23 +121,23 @@ function bind(router, data, opts = {}) {
|
|
|
123
121
|
params: c.req.param(),
|
|
124
122
|
headers: c.req.header(),
|
|
125
123
|
app: router,
|
|
126
|
-
getCookie: /* @__PURE__ */
|
|
127
|
-
delCookie: /* @__PURE__ */
|
|
128
|
-
setCookie: /* @__PURE__ */
|
|
129
|
-
redirect: /* @__PURE__ */
|
|
130
|
-
setResHeaders: /* @__PURE__ */
|
|
124
|
+
getCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
125
|
+
delCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
126
|
+
setCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
127
|
+
redirect: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
128
|
+
setResHeaders: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (headers) => {
|
|
131
129
|
for (const name in headers) c.header(name, headers[name]);
|
|
132
130
|
}, "setResHeaders"),
|
|
133
|
-
setResStatus: /* @__PURE__ */
|
|
134
|
-
getRequest: /* @__PURE__ */
|
|
135
|
-
getResponse: /* @__PURE__ */
|
|
131
|
+
setResStatus: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
132
|
+
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
133
|
+
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => c.res, "getResponse")
|
|
136
134
|
};
|
|
137
|
-
const context = new (0,
|
|
135
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)(contextData);
|
|
138
136
|
if (http.headers) {
|
|
139
137
|
for (const name in http.headers) c.header(name, http.headers[name]);
|
|
140
138
|
}
|
|
141
139
|
if (dynamic) {
|
|
142
|
-
aop =
|
|
140
|
+
aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
143
141
|
globalFilter,
|
|
144
142
|
globalGuards,
|
|
145
143
|
globalPipe
|
|
@@ -158,9 +156,9 @@ function bind(router, data, opts = {}) {
|
|
|
158
156
|
}
|
|
159
157
|
}
|
|
160
158
|
}
|
|
161
|
-
|
|
159
|
+
_chunk4LLLQOMFjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
162
160
|
}
|
|
163
|
-
|
|
161
|
+
_chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
|
|
164
162
|
|
|
165
163
|
|
|
166
164
|
exports.bind = bind;
|
package/dist/http/hono/index.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BadRequestException,
|
|
3
3
|
Context,
|
|
4
|
-
argToReq,
|
|
5
4
|
createControllerMetaMap,
|
|
6
5
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-Z7NAAE4M.mjs";
|
|
8
7
|
import {
|
|
9
8
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-NQ55PA2X.mjs";
|
|
11
10
|
|
|
12
11
|
// src/http/hono/bind.ts
|
|
13
12
|
import Debug from "debug";
|
|
@@ -53,7 +52,6 @@ function bind(router, data, opts = {}) {
|
|
|
53
52
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
54
53
|
const meta2 = metaMap.get(tag)[func];
|
|
55
54
|
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
|
|
56
|
-
const { data: { params } } = meta2;
|
|
57
55
|
const aop = Context.getAop(meta2, {
|
|
58
56
|
globalFilter,
|
|
59
57
|
globalGuards,
|
|
@@ -62,14 +60,13 @@ function bind(router, data, opts = {}) {
|
|
|
62
60
|
const contextData = {
|
|
63
61
|
type: "hono",
|
|
64
62
|
parallel: true,
|
|
63
|
+
category: "http",
|
|
65
64
|
context: c,
|
|
66
65
|
index: i,
|
|
67
66
|
meta: meta2,
|
|
68
67
|
moduleMap,
|
|
69
|
-
tag,
|
|
70
|
-
func,
|
|
71
68
|
app: router,
|
|
72
|
-
...
|
|
69
|
+
...item,
|
|
73
70
|
getCookie: /* @__PURE__ */ __name((key) => getCookie(c, key), "getCookie"),
|
|
74
71
|
delCookie: /* @__PURE__ */ __name((key) => deleteCookie(c, key), "delCookie"),
|
|
75
72
|
setCookie: /* @__PURE__ */ __name((key, value, opts2) => setCookie(c, key, value, opts2), "setCookie"),
|
|
@@ -113,6 +110,7 @@ function bind(router, data, opts = {}) {
|
|
|
113
110
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
114
111
|
const contextData = {
|
|
115
112
|
type: "hono",
|
|
113
|
+
category: "http",
|
|
116
114
|
context: c,
|
|
117
115
|
meta: meta2,
|
|
118
116
|
moduleMap,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { H as
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-DYviSl5B.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-DIfgUKIU.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-CR-D39hQ.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
|
-
interface HyperExpressCtx extends
|
|
8
|
+
interface HyperExpressCtx extends HttpCtx {
|
|
9
9
|
type: 'hyper-express';
|
|
10
10
|
request: Request;
|
|
11
11
|
response: Response;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { H as
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-BF1TDbFV.js';
|
|
3
|
+
import { F as Factory } from '../../core-CUTbX_IS.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-CR-D39hQ.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
|
-
interface HyperExpressCtx extends
|
|
8
|
+
interface HyperExpressCtx extends HttpCtx {
|
|
9
9
|
type: 'hyper-express';
|
|
10
10
|
request: Request;
|
|
11
11
|
response: Response;
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkG7JFKM2Mjs = require('../../chunk-G7JFKM2M.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
11
11
|
|
|
12
12
|
// src/http/hyper-express/bind.ts
|
|
13
13
|
var _hyperexpress = require('hyper-express');
|
|
@@ -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 = _chunkG7JFKM2Mjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
20
20
|
const { controller, http, func, tag } = meta2.data;
|
|
21
21
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
22
22
|
debug(`register method "${func}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
_chunkG7JFKM2Mjs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
addons: [
|
|
28
28
|
...globalAddons,
|
|
29
29
|
...parallelAddons
|
|
@@ -32,54 +32,52 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
async function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunkG7JFKM2Mjs.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 _chunkG7JFKM2Mjs.Context.filterRecord.default(e);
|
|
42
42
|
return res.status(error.status).json(error);
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
44
|
+
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
45
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkG7JFKM2Mjs.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
|
const { tag, func } = item;
|
|
50
50
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
51
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
51
|
+
if (!metaMap.has(tag)) return resolve(await _chunkG7JFKM2Mjs.Context.filterRecord.default(new (0, _chunkG7JFKM2Mjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
52
52
|
const meta2 = metaMap.get(tag)[func];
|
|
53
|
-
if (!meta2) return resolve(await
|
|
54
|
-
const
|
|
55
|
-
const aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
|
|
53
|
+
if (!meta2) return resolve(await _chunkG7JFKM2Mjs.Context.filterRecord.default(new (0, _chunkG7JFKM2Mjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
54
|
+
const aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
56
55
|
globalFilter,
|
|
57
56
|
globalGuards,
|
|
58
57
|
globalPipe
|
|
59
58
|
});
|
|
60
59
|
const contextData = {
|
|
61
60
|
type: "hyper-express",
|
|
61
|
+
category: "http",
|
|
62
62
|
parallel: true,
|
|
63
63
|
request: req,
|
|
64
64
|
index: i,
|
|
65
65
|
meta: meta2,
|
|
66
66
|
response: res,
|
|
67
67
|
moduleMap,
|
|
68
|
-
tag,
|
|
69
|
-
func,
|
|
70
68
|
app: router,
|
|
71
|
-
...
|
|
69
|
+
...item,
|
|
72
70
|
next,
|
|
73
|
-
getCookie: /* @__PURE__ */
|
|
74
|
-
setCookie: /* @__PURE__ */
|
|
75
|
-
delCookie: /* @__PURE__ */
|
|
76
|
-
redirect: /* @__PURE__ */
|
|
77
|
-
setResHeaders: /* @__PURE__ */
|
|
78
|
-
setResStatus: /* @__PURE__ */
|
|
79
|
-
getRequest: /* @__PURE__ */
|
|
80
|
-
getResponse: /* @__PURE__ */
|
|
71
|
+
getCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
72
|
+
setCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _2 => _2.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
|
|
73
|
+
delCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
74
|
+
redirect: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
75
|
+
setResHeaders: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
76
|
+
setResStatus: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
77
|
+
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req, "getRequest"),
|
|
78
|
+
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res, "getResponse")
|
|
81
79
|
};
|
|
82
|
-
const context = new (0,
|
|
80
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)(contextData);
|
|
83
81
|
context.run(aop, resolve, resolve);
|
|
84
82
|
});
|
|
85
83
|
})).then((ret) => {
|
|
@@ -99,18 +97,19 @@ function bind(router, data, opts = {}) {
|
|
|
99
97
|
const needBody = params.some((item) => item.type === "body");
|
|
100
98
|
let aop;
|
|
101
99
|
if (!dynamic) {
|
|
102
|
-
aop =
|
|
100
|
+
aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
103
101
|
globalFilter,
|
|
104
102
|
globalGuards,
|
|
105
103
|
globalPipe
|
|
106
104
|
});
|
|
107
105
|
}
|
|
108
106
|
const subRouter = new (0, _hyperexpress.Router)();
|
|
109
|
-
|
|
110
|
-
subRouter[http.type](http.prefix
|
|
107
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(addons, subRouter, "hyper-express");
|
|
108
|
+
subRouter[http.type](_chunkG7JFKM2Mjs.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
|
|
111
109
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
112
110
|
const contextData = {
|
|
113
111
|
type: "hyper-express",
|
|
112
|
+
category: "http",
|
|
114
113
|
request: req,
|
|
115
114
|
meta: meta2,
|
|
116
115
|
response: res,
|
|
@@ -123,21 +122,21 @@ function bind(router, data, opts = {}) {
|
|
|
123
122
|
params: req.path_parameters,
|
|
124
123
|
headers: req.headers,
|
|
125
124
|
next,
|
|
126
|
-
getCookie: /* @__PURE__ */
|
|
127
|
-
setCookie: /* @__PURE__ */
|
|
128
|
-
delCookie: /* @__PURE__ */
|
|
129
|
-
redirect: /* @__PURE__ */
|
|
130
|
-
setResHeaders: /* @__PURE__ */
|
|
131
|
-
setResStatus: /* @__PURE__ */
|
|
132
|
-
getRequest: /* @__PURE__ */
|
|
133
|
-
getResponse: /* @__PURE__ */
|
|
125
|
+
getCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
126
|
+
setCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _4 => _4.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
|
|
127
|
+
delCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
128
|
+
redirect: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
129
|
+
setResHeaders: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
130
|
+
setResStatus: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
131
|
+
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req, "getRequest"),
|
|
132
|
+
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res, "getResponse")
|
|
134
133
|
};
|
|
135
|
-
const context = new (0,
|
|
134
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)(contextData);
|
|
136
135
|
if (http.headers) {
|
|
137
136
|
for (const name in http.headers) res.set(name, http.headers[name]);
|
|
138
137
|
}
|
|
139
138
|
if (dynamic) {
|
|
140
|
-
aop =
|
|
139
|
+
aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
141
140
|
globalFilter,
|
|
142
141
|
globalGuards,
|
|
143
142
|
globalPipe
|
|
@@ -156,9 +155,9 @@ function bind(router, data, opts = {}) {
|
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
|
-
|
|
158
|
+
_chunk4LLLQOMFjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
160
159
|
}
|
|
161
|
-
|
|
160
|
+
_chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
|
|
162
161
|
|
|
163
162
|
|
|
164
163
|
exports.bind = bind;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BadRequestException,
|
|
3
3
|
Context,
|
|
4
|
-
argToReq,
|
|
5
4
|
createControllerMetaMap,
|
|
6
|
-
detectAopDep
|
|
7
|
-
|
|
5
|
+
detectAopDep,
|
|
6
|
+
joinUrl
|
|
7
|
+
} from "../../chunk-Z7NAAE4M.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-NQ55PA2X.mjs";
|
|
11
11
|
|
|
12
12
|
// src/http/hyper-express/bind.ts
|
|
13
13
|
import { Router } from "hyper-express";
|
|
@@ -51,7 +51,6 @@ function bind(router, data, opts = {}) {
|
|
|
51
51
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
52
52
|
const meta2 = metaMap.get(tag)[func];
|
|
53
53
|
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
|
|
54
|
-
const { data: { params } } = meta2;
|
|
55
54
|
const aop = Context.getAop(meta2, {
|
|
56
55
|
globalFilter,
|
|
57
56
|
globalGuards,
|
|
@@ -59,16 +58,15 @@ function bind(router, data, opts = {}) {
|
|
|
59
58
|
});
|
|
60
59
|
const contextData = {
|
|
61
60
|
type: "hyper-express",
|
|
61
|
+
category: "http",
|
|
62
62
|
parallel: true,
|
|
63
63
|
request: req,
|
|
64
64
|
index: i,
|
|
65
65
|
meta: meta2,
|
|
66
66
|
response: res,
|
|
67
67
|
moduleMap,
|
|
68
|
-
tag,
|
|
69
|
-
func,
|
|
70
68
|
app: router,
|
|
71
|
-
...
|
|
69
|
+
...item,
|
|
72
70
|
next,
|
|
73
71
|
getCookie: /* @__PURE__ */ __name((key) => req.cookies[key], "getCookie"),
|
|
74
72
|
setCookie: /* @__PURE__ */ __name((key, value, opts2) => res.cookie(key, value, opts2?.expires && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
|
|
@@ -107,10 +105,11 @@ function bind(router, data, opts = {}) {
|
|
|
107
105
|
}
|
|
108
106
|
const subRouter = new Router();
|
|
109
107
|
Context.applyAddons(addons, subRouter, "hyper-express");
|
|
110
|
-
subRouter[http.type](http.prefix
|
|
108
|
+
subRouter[http.type](joinUrl(http.prefix, http.route), async (req, res, next) => {
|
|
111
109
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
112
110
|
const contextData = {
|
|
113
111
|
type: "hyper-express",
|
|
112
|
+
category: "http",
|
|
114
113
|
request: req,
|
|
115
114
|
meta: meta2,
|
|
116
115
|
response: res,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
|
-
import { H as
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-DYviSl5B.mjs';
|
|
4
|
+
import { F as Factory } from '../../core-DIfgUKIU.mjs';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-CR-D39hQ.mjs';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
|
-
interface KoaCtx extends
|
|
9
|
+
interface KoaCtx extends HttpCtx {
|
|
10
10
|
type: 'koa';
|
|
11
11
|
ctx: DefaultContext & RouterParamContext<DefaultState, DefaultContext>;
|
|
12
12
|
next: Function;
|
package/dist/http/koa/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
|
-
import { H as
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-BF1TDbFV.js';
|
|
4
|
+
import { F as Factory } from '../../core-CUTbX_IS.js';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-CR-D39hQ.js';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
|
-
interface KoaCtx extends
|
|
9
|
+
interface KoaCtx extends HttpCtx {
|
|
10
10
|
type: 'koa';
|
|
11
11
|
ctx: DefaultContext & RouterParamContext<DefaultState, DefaultContext>;
|
|
12
12
|
next: Function;
|