phecda-server 7.0.0-alpha.7 → 7.0.0-alpha.9
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/bin/cli.mjs +10 -1
- package/dist/{chunk-M5HGFUCV.js → chunk-5RBTN33A.js} +23 -3
- package/dist/{chunk-RGSKKTHD.mjs → chunk-7ZGYJ5OW.mjs} +88 -54
- package/dist/{chunk-IRXNF6ZE.mjs → chunk-CVPZWDXU.mjs} +39 -30
- package/dist/{chunk-MENRZSGW.js → chunk-FX3LDQII.js} +88 -79
- package/dist/{chunk-C5BVKEGW.mjs → chunk-FXTJ3BJ6.mjs} +25 -5
- package/dist/{chunk-XSMUJ77A.js → chunk-KJUD2BKE.js} +103 -69
- package/dist/{chunk-JPSXNDXP.mjs → chunk-ODVWOXVB.mjs} +1 -1
- package/dist/{chunk-VYMSCWXC.js → chunk-V5EYXVJT.js} +24 -24
- package/dist/{core-DU7gQKSk.d.mts → core-BDkhrEyf.d.mts} +4 -3
- package/dist/{core-CzElxZoF.d.ts → core-D_cz0tKa.d.ts} +4 -3
- package/dist/helper.d.mts +7 -5
- package/dist/helper.d.ts +7 -5
- 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 +41 -44
- package/dist/http/elysia/index.mjs +7 -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 +38 -41
- package/dist/http/express/index.mjs +7 -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 +39 -42
- package/dist/http/fastify/index.mjs +7 -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 +39 -42
- package/dist/http/h3/index.mjs +7 -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 +35 -39
- package/dist/http/hono/index.mjs +3 -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 +36 -39
- package/dist/http/hyper-express/index.mjs +6 -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 +38 -41
- package/dist/http/koa/index.mjs +7 -10
- package/dist/index.d.mts +35 -33
- package/dist/index.d.ts +35 -33
- package/dist/index.js +42 -43
- package/dist/index.mjs +15 -16
- package/dist/{meta-BTnLXuCa.d.ts → meta-BX5jhe4Z.d.mts} +3 -4
- package/dist/{meta-BTnLXuCa.d.mts → meta-BX5jhe4Z.d.ts} +3 -4
- package/dist/rpc/bullmq/index.d.mts +4 -4
- package/dist/rpc/bullmq/index.d.ts +4 -4
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +3 -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 +14 -14
- package/dist/rpc/kafka/index.mjs +2 -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 +13 -13
- package/dist/rpc/nats/index.mjs +3 -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 +15 -15
- package/dist/rpc/rabbitmq/index.mjs +3 -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 +13 -13
- package/dist/rpc/redis/index.mjs +3 -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-CbfaGkPA.d.ts → types-B-rUM9Fm.d.mts} +3 -3
- package/dist/{types--E-OCZhC.d.ts → types-CMeuFoyd.d.ts} +3 -3
- package/dist/{types-BxlzVoRv.d.mts → types-DKVhyZk_.d.mts} +3 -3
- package/dist/{types-BYqBeqrs.d.mts → types-MxxtkZXw.d.ts} +3 -3
- package/package.json +3 -2
- package/register/index.mjs +20 -11
- package/register/loader.mjs +13 -28
package/dist/http/hono/index.js
CHANGED
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunkFX3LDQIIjs = require('../../chunk-FX3LDQII.js');
|
|
6
7
|
|
|
7
|
-
var _chunkMENRZSGWjs = require('../../chunk-MENRZSGW.js');
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
var _chunkM5HGFUCVjs = require('../../chunk-M5HGFUCV.js');
|
|
9
|
+
var _chunk5RBTN33Ajs = require('../../chunk-5RBTN33A.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 = _chunkFX3LDQIIjs.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
|
+
_chunkFX3LDQIIjs.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
|
+
_chunkFX3LDQIIjs.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 _chunkFX3LDQIIjs.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
|
+
_chunk5RBTN33Ajs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkFX3LDQIIjs.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 _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.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 = _chunkMENRZSGWjs.Context.getAop(meta2, {
|
|
54
|
+
if (!meta2) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
55
|
+
const aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
58
56
|
globalFilter,
|
|
59
57
|
globalGuards,
|
|
60
58
|
globalPipe
|
|
@@ -67,22 +65,20 @@ function bind(router, data, opts = {}) {
|
|
|
67
65
|
index: i,
|
|
68
66
|
meta: meta2,
|
|
69
67
|
moduleMap,
|
|
70
|
-
tag,
|
|
71
|
-
func,
|
|
72
68
|
app: router,
|
|
73
|
-
...
|
|
74
|
-
getCookie: /* @__PURE__ */
|
|
75
|
-
delCookie: /* @__PURE__ */
|
|
76
|
-
setCookie: /* @__PURE__ */
|
|
77
|
-
redirect: /* @__PURE__ */
|
|
78
|
-
setResHeaders: /* @__PURE__ */
|
|
69
|
+
...item,
|
|
70
|
+
getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
71
|
+
delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
72
|
+
setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
73
|
+
redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
74
|
+
setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => {
|
|
79
75
|
for (const name in headers) c.header(name, headers[name]);
|
|
80
76
|
}, "setResHeaders"),
|
|
81
|
-
setResStatus: /* @__PURE__ */
|
|
82
|
-
getRequest: /* @__PURE__ */
|
|
83
|
-
getResponse: /* @__PURE__ */
|
|
77
|
+
setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
78
|
+
getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
79
|
+
getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => c.res, "getResponse")
|
|
84
80
|
};
|
|
85
|
-
const context = new (0,
|
|
81
|
+
const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
|
|
86
82
|
context.run(aop, resolve, resolve);
|
|
87
83
|
});
|
|
88
84
|
})).then((ret) => {
|
|
@@ -102,14 +98,14 @@ function bind(router, data, opts = {}) {
|
|
|
102
98
|
const needBody = params.some((item) => item.type === "body");
|
|
103
99
|
let aop;
|
|
104
100
|
if (!dynamic) {
|
|
105
|
-
aop =
|
|
101
|
+
aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
106
102
|
globalFilter,
|
|
107
103
|
globalGuards,
|
|
108
104
|
globalPipe
|
|
109
105
|
});
|
|
110
106
|
}
|
|
111
107
|
const subApp = new (0, _hono.Hono)();
|
|
112
|
-
|
|
108
|
+
_chunkFX3LDQIIjs.Context.applyAddons(addons, subApp, "hono");
|
|
113
109
|
subApp[http.type](http.route, async (c) => {
|
|
114
110
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
115
111
|
const contextData = {
|
|
@@ -125,23 +121,23 @@ function bind(router, data, opts = {}) {
|
|
|
125
121
|
params: c.req.param(),
|
|
126
122
|
headers: c.req.header(),
|
|
127
123
|
app: router,
|
|
128
|
-
getCookie: /* @__PURE__ */
|
|
129
|
-
delCookie: /* @__PURE__ */
|
|
130
|
-
setCookie: /* @__PURE__ */
|
|
131
|
-
redirect: /* @__PURE__ */
|
|
132
|
-
setResHeaders: /* @__PURE__ */
|
|
124
|
+
getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
125
|
+
delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
126
|
+
setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
127
|
+
redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
128
|
+
setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => {
|
|
133
129
|
for (const name in headers) c.header(name, headers[name]);
|
|
134
130
|
}, "setResHeaders"),
|
|
135
|
-
setResStatus: /* @__PURE__ */
|
|
136
|
-
getRequest: /* @__PURE__ */
|
|
137
|
-
getResponse: /* @__PURE__ */
|
|
131
|
+
setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
132
|
+
getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
133
|
+
getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => c.res, "getResponse")
|
|
138
134
|
};
|
|
139
|
-
const context = new (0,
|
|
135
|
+
const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
|
|
140
136
|
if (http.headers) {
|
|
141
137
|
for (const name in http.headers) c.header(name, http.headers[name]);
|
|
142
138
|
}
|
|
143
139
|
if (dynamic) {
|
|
144
|
-
aop =
|
|
140
|
+
aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
145
141
|
globalFilter,
|
|
146
142
|
globalGuards,
|
|
147
143
|
globalPipe
|
|
@@ -160,9 +156,9 @@ function bind(router, data, opts = {}) {
|
|
|
160
156
|
}
|
|
161
157
|
}
|
|
162
158
|
}
|
|
163
|
-
|
|
159
|
+
_chunk5RBTN33Ajs.__name.call(void 0, registerRoute, "registerRoute");
|
|
164
160
|
}
|
|
165
|
-
|
|
161
|
+
_chunk5RBTN33Ajs.__name.call(void 0, bind, "bind");
|
|
166
162
|
|
|
167
163
|
|
|
168
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-CVPZWDXU.mjs";
|
|
8
7
|
import {
|
|
9
8
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-FXTJ3BJ6.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,
|
|
@@ -67,10 +65,8 @@ function bind(router, data, opts = {}) {
|
|
|
67
65
|
index: i,
|
|
68
66
|
meta: meta2,
|
|
69
67
|
moduleMap,
|
|
70
|
-
tag,
|
|
71
|
-
func,
|
|
72
68
|
app: router,
|
|
73
|
-
...
|
|
69
|
+
...item,
|
|
74
70
|
getCookie: /* @__PURE__ */ __name((key) => getCookie(c, key), "getCookie"),
|
|
75
71
|
delCookie: /* @__PURE__ */ __name((key) => deleteCookie(c, key), "delCookie"),
|
|
76
72
|
setCookie: /* @__PURE__ */ __name((key, value, opts2) => setCookie(c, key, value, opts2), "setCookie"),
|
|
@@ -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-DKVhyZk_.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-BDkhrEyf.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-BX5jhe4Z.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-CMeuFoyd.js';
|
|
3
|
+
import { F as Factory } from '../../core-D_cz0tKa.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-BX5jhe4Z.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 _chunkFX3LDQIIjs = require('../../chunk-FX3LDQII.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk5RBTN33Ajs = require('../../chunk-5RBTN33A.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 = _chunkFX3LDQIIjs.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
|
+
_chunkFX3LDQIIjs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
addons: [
|
|
28
28
|
...globalAddons,
|
|
29
29
|
...parallelAddons
|
|
@@ -32,27 +32,26 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
async function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunkFX3LDQIIjs.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 _chunkFX3LDQIIjs.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
|
+
_chunk5RBTN33Ajs.__name.call(void 0, errorHandler, "errorHandler");
|
|
45
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkFX3LDQIIjs.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 _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.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 = _chunkMENRZSGWjs.Context.getAop(meta2, {
|
|
53
|
+
if (!meta2) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
54
|
+
const aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
56
55
|
globalFilter,
|
|
57
56
|
globalGuards,
|
|
58
57
|
globalPipe
|
|
@@ -66,21 +65,19 @@ function bind(router, data, opts = {}) {
|
|
|
66
65
|
meta: meta2,
|
|
67
66
|
response: res,
|
|
68
67
|
moduleMap,
|
|
69
|
-
tag,
|
|
70
|
-
func,
|
|
71
68
|
app: router,
|
|
72
|
-
...
|
|
69
|
+
...item,
|
|
73
70
|
next,
|
|
74
|
-
getCookie: /* @__PURE__ */
|
|
75
|
-
setCookie: /* @__PURE__ */
|
|
76
|
-
delCookie: /* @__PURE__ */
|
|
77
|
-
redirect: /* @__PURE__ */
|
|
78
|
-
setResHeaders: /* @__PURE__ */
|
|
79
|
-
setResStatus: /* @__PURE__ */
|
|
80
|
-
getRequest: /* @__PURE__ */
|
|
81
|
-
getResponse: /* @__PURE__ */
|
|
71
|
+
getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
72
|
+
setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__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__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
74
|
+
redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
75
|
+
setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
76
|
+
setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
77
|
+
getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => req, "getRequest"),
|
|
78
|
+
getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => res, "getResponse")
|
|
82
79
|
};
|
|
83
|
-
const context = new (0,
|
|
80
|
+
const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
|
|
84
81
|
context.run(aop, resolve, resolve);
|
|
85
82
|
});
|
|
86
83
|
})).then((ret) => {
|
|
@@ -100,15 +97,15 @@ function bind(router, data, opts = {}) {
|
|
|
100
97
|
const needBody = params.some((item) => item.type === "body");
|
|
101
98
|
let aop;
|
|
102
99
|
if (!dynamic) {
|
|
103
|
-
aop =
|
|
100
|
+
aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
104
101
|
globalFilter,
|
|
105
102
|
globalGuards,
|
|
106
103
|
globalPipe
|
|
107
104
|
});
|
|
108
105
|
}
|
|
109
106
|
const subRouter = new (0, _hyperexpress.Router)();
|
|
110
|
-
|
|
111
|
-
subRouter[http.type](http.prefix
|
|
107
|
+
_chunkFX3LDQIIjs.Context.applyAddons(addons, subRouter, "hyper-express");
|
|
108
|
+
subRouter[http.type](_chunkFX3LDQIIjs.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
|
|
112
109
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
113
110
|
const contextData = {
|
|
114
111
|
type: "hyper-express",
|
|
@@ -125,21 +122,21 @@ function bind(router, data, opts = {}) {
|
|
|
125
122
|
params: req.path_parameters,
|
|
126
123
|
headers: req.headers,
|
|
127
124
|
next,
|
|
128
|
-
getCookie: /* @__PURE__ */
|
|
129
|
-
setCookie: /* @__PURE__ */
|
|
130
|
-
delCookie: /* @__PURE__ */
|
|
131
|
-
redirect: /* @__PURE__ */
|
|
132
|
-
setResHeaders: /* @__PURE__ */
|
|
133
|
-
setResStatus: /* @__PURE__ */
|
|
134
|
-
getRequest: /* @__PURE__ */
|
|
135
|
-
getResponse: /* @__PURE__ */
|
|
125
|
+
getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
126
|
+
setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__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__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
128
|
+
redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
129
|
+
setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
130
|
+
setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
131
|
+
getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => req, "getRequest"),
|
|
132
|
+
getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => res, "getResponse")
|
|
136
133
|
};
|
|
137
|
-
const context = new (0,
|
|
134
|
+
const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
|
|
138
135
|
if (http.headers) {
|
|
139
136
|
for (const name in http.headers) res.set(name, http.headers[name]);
|
|
140
137
|
}
|
|
141
138
|
if (dynamic) {
|
|
142
|
-
aop =
|
|
139
|
+
aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
143
140
|
globalFilter,
|
|
144
141
|
globalGuards,
|
|
145
142
|
globalPipe
|
|
@@ -158,9 +155,9 @@ function bind(router, data, opts = {}) {
|
|
|
158
155
|
}
|
|
159
156
|
}
|
|
160
157
|
}
|
|
161
|
-
|
|
158
|
+
_chunk5RBTN33Ajs.__name.call(void 0, registerRoute, "registerRoute");
|
|
162
159
|
}
|
|
163
|
-
|
|
160
|
+
_chunk5RBTN33Ajs.__name.call(void 0, bind, "bind");
|
|
164
161
|
|
|
165
162
|
|
|
166
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-CVPZWDXU.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-FXTJ3BJ6.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,
|
|
@@ -66,10 +65,8 @@ function bind(router, data, opts = {}) {
|
|
|
66
65
|
meta: meta2,
|
|
67
66
|
response: res,
|
|
68
67
|
moduleMap,
|
|
69
|
-
tag,
|
|
70
|
-
func,
|
|
71
68
|
app: router,
|
|
72
|
-
...
|
|
69
|
+
...item,
|
|
73
70
|
next,
|
|
74
71
|
getCookie: /* @__PURE__ */ __name((key) => req.cookies[key], "getCookie"),
|
|
75
72
|
setCookie: /* @__PURE__ */ __name((key, value, opts2) => res.cookie(key, value, opts2?.expires && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
|
|
@@ -108,7 +105,7 @@ function bind(router, data, opts = {}) {
|
|
|
108
105
|
}
|
|
109
106
|
const subRouter = new Router();
|
|
110
107
|
Context.applyAddons(addons, subRouter, "hyper-express");
|
|
111
|
-
subRouter[http.type](http.prefix
|
|
108
|
+
subRouter[http.type](joinUrl(http.prefix, http.route), async (req, res, next) => {
|
|
112
109
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
113
110
|
const contextData = {
|
|
114
111
|
type: "hyper-express",
|
|
@@ -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-DKVhyZk_.mjs';
|
|
4
|
+
import { F as Factory } from '../../core-BDkhrEyf.mjs';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-BX5jhe4Z.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-CMeuFoyd.js';
|
|
4
|
+
import { F as Factory } from '../../core-D_cz0tKa.js';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-BX5jhe4Z.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;
|