phecda-server 7.0.0-alpha.8 → 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/dist/{chunk-VSGYTGHY.js → chunk-5RBTN33A.js} +22 -2
- package/dist/{chunk-B45BN7LY.mjs → chunk-7ZGYJ5OW.mjs} +88 -54
- package/dist/{chunk-SGMQZRP6.mjs → chunk-CVPZWDXU.mjs} +2 -23
- package/dist/{chunk-7EMAZGYO.js → chunk-FX3LDQII.js} +59 -80
- package/dist/{chunk-YKP4ODZA.mjs → chunk-FXTJ3BJ6.mjs} +23 -3
- package/dist/{chunk-QJIAXSLZ.js → chunk-KJUD2BKE.js} +103 -69
- package/dist/{chunk-7NWDKK7D.mjs → chunk-ODVWOXVB.mjs} +1 -1
- package/dist/{chunk-BBNJVYVX.js → chunk-V5EYXVJT.js} +24 -24
- package/dist/{core-BcKywWLd.d.mts → core-BDkhrEyf.d.mts} +4 -3
- package/dist/{core-BGEsBtTG.d.ts → core-D_cz0tKa.d.ts} +4 -3
- package/dist/helper.d.mts +6 -5
- package/dist/helper.d.ts +6 -5
- package/dist/helper.js +6 -3
- package/dist/helper.mjs +8 -5
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +41 -45
- package/dist/http/elysia/index.mjs +4 -8
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +38 -42
- package/dist/http/express/index.mjs +4 -8
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +39 -43
- package/dist/http/fastify/index.mjs +4 -8
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +39 -43
- package/dist/http/h3/index.mjs +3 -7
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +35 -39
- package/dist/http/hono/index.mjs +3 -7
- 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 +36 -40
- package/dist/http/hyper-express/index.mjs +3 -7
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +38 -42
- package/dist/http/koa/index.mjs +4 -8
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +40 -42
- package/dist/index.mjs +4 -6
- package/dist/{meta-B_HW7cWh.d.mts → meta-BX5jhe4Z.d.mts} +1 -2
- package/dist/{meta-B_HW7cWh.d.ts → meta-BX5jhe4Z.d.ts} +1 -2
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +3 -3
- 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 +2 -2
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +13 -13
- package/dist/rpc/nats/index.mjs +3 -3
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +15 -15
- package/dist/rpc/rabbitmq/index.mjs +3 -3
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- 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-DEQb_e59.d.mts → types-B-rUM9Fm.d.mts} +1 -1
- package/dist/{types-PFPIQWVF.d.ts → types-CMeuFoyd.d.ts} +1 -1
- package/dist/{types-C2SQ9U9V.d.mts → types-DKVhyZk_.d.mts} +1 -1
- package/dist/{types-CYF0vha6.d.ts → types-MxxtkZXw.d.ts} +1 -1
- package/package.json +1 -1
- package/register/index.mjs +20 -11
- package/register/loader.mjs +12 -27
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkV5EYXVJTjs = require('../../chunk-V5EYXVJT.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
var _chunkFX3LDQIIjs = require('../../chunk-FX3LDQII.js');
|
|
10
11
|
|
|
11
|
-
var _chunk7EMAZGYOjs = require('../../chunk-7EMAZGYO.js');
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
var _chunkVSGYTGHYjs = require('../../chunk-VSGYTGHY.js');
|
|
13
|
+
var _chunk5RBTN33Ajs = require('../../chunk-5RBTN33A.js');
|
|
15
14
|
|
|
16
15
|
// src/http/fastify/bind.ts
|
|
17
16
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -19,14 +18,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/fastify");
|
|
|
19
18
|
function bind(fastify, data, opts = {}) {
|
|
20
19
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, fastifyOpts, dynamic = false } = opts;
|
|
21
20
|
const { moduleMap, meta } = data;
|
|
22
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkFX3LDQIIjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
23
22
|
const { controller, http, func, tag } = meta2.data;
|
|
24
23
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _2 => _2.type])) {
|
|
25
24
|
debug(`register method "${func}" in module "${tag}"`);
|
|
26
25
|
return true;
|
|
27
26
|
}
|
|
28
27
|
});
|
|
29
|
-
|
|
28
|
+
_chunkFX3LDQIIjs.detectAopDep.call(void 0, meta, {
|
|
30
29
|
addons: [
|
|
31
30
|
...globalAddons,
|
|
32
31
|
...parallelAddons
|
|
@@ -34,28 +33,27 @@ function bind(fastify, data, opts = {}) {
|
|
|
34
33
|
guards: globalGuards
|
|
35
34
|
});
|
|
36
35
|
fastify.register(async (fastify2, _, done) => {
|
|
37
|
-
|
|
36
|
+
_chunkFX3LDQIIjs.Context.applyAddons(globalAddons, fastify2, "fastify");
|
|
38
37
|
if (parallelRoute) {
|
|
39
38
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
40
|
-
|
|
39
|
+
_chunkFX3LDQIIjs.Context.applyAddons(parallelAddons, fastify3, "fastify");
|
|
41
40
|
fastify3.post(parallelRoute, async (req, res) => {
|
|
42
41
|
const { body } = req;
|
|
43
42
|
async function errorHandler(e) {
|
|
44
|
-
const error = await
|
|
43
|
+
const error = await _chunkFX3LDQIIjs.Context.filterRecord.default(e);
|
|
45
44
|
return res.status(error.status).send(error);
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
46
|
+
_chunk5RBTN33Ajs.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkFX3LDQIIjs.BadRequestException)("data format should be an array"));
|
|
49
48
|
try {
|
|
50
49
|
return Promise.all(body.map((item, i) => {
|
|
51
50
|
return new Promise(async (resolve) => {
|
|
52
51
|
const { tag, func } = item;
|
|
53
52
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
54
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
53
|
+
if (!metaMap.has(tag)) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
55
54
|
const meta2 = metaMap.get(tag)[func];
|
|
56
|
-
if (!meta2) return resolve(await
|
|
57
|
-
const
|
|
58
|
-
const aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
55
|
+
if (!meta2) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
56
|
+
const aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
59
57
|
globalFilter,
|
|
60
58
|
globalGuards,
|
|
61
59
|
globalPipe
|
|
@@ -69,23 +67,21 @@ function bind(fastify, data, opts = {}) {
|
|
|
69
67
|
meta: meta2,
|
|
70
68
|
response: res,
|
|
71
69
|
moduleMap,
|
|
72
|
-
tag,
|
|
73
|
-
func,
|
|
74
70
|
app: fastify3,
|
|
75
|
-
...
|
|
71
|
+
...item,
|
|
76
72
|
// @ts-expect-error need @fastify/cookie
|
|
77
|
-
getCookie: /* @__PURE__ */
|
|
73
|
+
getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
78
74
|
// @ts-expect-error need @fastify/cookie
|
|
79
|
-
setCookie: /* @__PURE__ */
|
|
75
|
+
setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
80
76
|
// @ts-expect-error need @fastify/cookie
|
|
81
|
-
delCookie: /* @__PURE__ */
|
|
82
|
-
redirect: /* @__PURE__ */
|
|
83
|
-
setResHeaders: /* @__PURE__ */
|
|
84
|
-
setResStatus: /* @__PURE__ */
|
|
85
|
-
getRequest: /* @__PURE__ */
|
|
86
|
-
getResponse: /* @__PURE__ */
|
|
77
|
+
delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
78
|
+
redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
79
|
+
setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
80
|
+
setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
81
|
+
getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => req.raw, "getRequest"),
|
|
82
|
+
getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => res.raw, "getResponse")
|
|
87
83
|
};
|
|
88
|
-
const context = new (0,
|
|
84
|
+
const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
|
|
89
85
|
context.run(aop, resolve, resolve);
|
|
90
86
|
});
|
|
91
87
|
})).then((ret) => {
|
|
@@ -104,16 +100,16 @@ function bind(fastify, data, opts = {}) {
|
|
|
104
100
|
const { data: { addons, define, http } } = meta2;
|
|
105
101
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
|
|
106
102
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
107
|
-
|
|
103
|
+
_chunkFX3LDQIIjs.Context.applyAddons(addons, fastify3, "fastify");
|
|
108
104
|
let aop;
|
|
109
105
|
if (!dynamic) {
|
|
110
|
-
aop =
|
|
106
|
+
aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
111
107
|
globalFilter,
|
|
112
108
|
globalGuards,
|
|
113
109
|
globalPipe
|
|
114
110
|
});
|
|
115
111
|
}
|
|
116
|
-
fastify3[http.type](
|
|
112
|
+
fastify3[http.type](_chunkFX3LDQIIjs.joinUrl.call(void 0, http.prefix, http.route), _optionalChain([define, 'optionalAccess', _4 => _4.fastify]) || {}, async (req, res) => {
|
|
117
113
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
118
114
|
const contextData = {
|
|
119
115
|
type: "fastify",
|
|
@@ -130,23 +126,23 @@ function bind(fastify, data, opts = {}) {
|
|
|
130
126
|
headers: req.headers,
|
|
131
127
|
app: fastify3,
|
|
132
128
|
// @ts-expect-error need @fastify/cookie
|
|
133
|
-
getCookie: /* @__PURE__ */
|
|
129
|
+
getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
134
130
|
// @ts-expect-error need @fastify/cookie
|
|
135
|
-
setCookie: /* @__PURE__ */
|
|
131
|
+
setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
136
132
|
// @ts-expect-error need @fastify/cookie
|
|
137
|
-
delCookie: /* @__PURE__ */
|
|
133
|
+
delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => res.clearCookie(key, {
|
|
138
134
|
url: ""
|
|
139
135
|
}), "delCookie"),
|
|
140
|
-
redirect: /* @__PURE__ */
|
|
141
|
-
setResHeaders: /* @__PURE__ */
|
|
142
|
-
setResStatus: /* @__PURE__ */
|
|
143
|
-
getRequest: /* @__PURE__ */
|
|
144
|
-
getResponse: /* @__PURE__ */
|
|
136
|
+
redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
137
|
+
setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
138
|
+
setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
139
|
+
getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => req.raw, "getRequest"),
|
|
140
|
+
getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => res.raw, "getResponse")
|
|
145
141
|
};
|
|
146
|
-
const context = new (0,
|
|
142
|
+
const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
|
|
147
143
|
if (http.headers) res.headers(http.headers);
|
|
148
144
|
if (dynamic) {
|
|
149
|
-
aop =
|
|
145
|
+
aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
150
146
|
globalFilter,
|
|
151
147
|
globalGuards,
|
|
152
148
|
globalPipe
|
|
@@ -167,11 +163,11 @@ function bind(fastify, data, opts = {}) {
|
|
|
167
163
|
done();
|
|
168
164
|
}, fastifyOpts);
|
|
169
165
|
}
|
|
170
|
-
|
|
166
|
+
_chunk5RBTN33Ajs.__name.call(void 0, bind, "bind");
|
|
171
167
|
function Fastify(opts) {
|
|
172
|
-
return
|
|
168
|
+
return _chunkV5EYXVJTjs.Define.call(void 0, "fastify", opts);
|
|
173
169
|
}
|
|
174
|
-
|
|
170
|
+
_chunk5RBTN33Ajs.__name.call(void 0, Fastify, "Fastify");
|
|
175
171
|
|
|
176
172
|
|
|
177
173
|
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-ODVWOXVB.mjs";
|
|
4
4
|
import {
|
|
5
5
|
BadRequestException,
|
|
6
6
|
Context,
|
|
7
|
-
argToReq,
|
|
8
7
|
createControllerMetaMap,
|
|
9
8
|
detectAopDep,
|
|
10
9
|
joinUrl
|
|
11
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-CVPZWDXU.mjs";
|
|
12
11
|
import {
|
|
13
12
|
__name
|
|
14
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-FXTJ3BJ6.mjs";
|
|
15
14
|
|
|
16
15
|
// src/http/fastify/bind.ts
|
|
17
16
|
import Debug from "debug";
|
|
@@ -54,7 +53,6 @@ function bind(fastify, data, opts = {}) {
|
|
|
54
53
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
55
54
|
const meta2 = metaMap.get(tag)[func];
|
|
56
55
|
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
|
|
57
|
-
const { data: { params } } = meta2;
|
|
58
56
|
const aop = Context.getAop(meta2, {
|
|
59
57
|
globalFilter,
|
|
60
58
|
globalGuards,
|
|
@@ -69,10 +67,8 @@ function bind(fastify, data, opts = {}) {
|
|
|
69
67
|
meta: meta2,
|
|
70
68
|
response: res,
|
|
71
69
|
moduleMap,
|
|
72
|
-
tag,
|
|
73
|
-
func,
|
|
74
70
|
app: fastify3,
|
|
75
|
-
...
|
|
71
|
+
...item,
|
|
76
72
|
// @ts-expect-error need @fastify/cookie
|
|
77
73
|
getCookie: /* @__PURE__ */ __name((key) => req.cookies[key], "getCookie"),
|
|
78
74
|
// @ts-expect-error need @fastify/cookie
|
package/dist/http/h3/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { H3Event, Router, _RequestMiddleware } from 'h3';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-BDkhrEyf.mjs';
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-DKVhyZk_.mjs';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-BX5jhe4Z.mjs';
|
|
6
6
|
import 'node:http';
|
|
7
7
|
|
|
8
8
|
interface H3Ctx extends HttpCtx {
|
package/dist/http/h3/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { H3Event, Router, _RequestMiddleware } from 'h3';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-D_cz0tKa.js';
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-CMeuFoyd.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-BX5jhe4Z.js';
|
|
6
6
|
import 'node:http';
|
|
7
7
|
|
|
8
8
|
interface H3Ctx extends HttpCtx {
|
package/dist/http/h3/index.js
CHANGED
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
var _chunkFX3LDQIIjs = require('../../chunk-FX3LDQII.js');
|
|
7
8
|
|
|
8
|
-
var _chunk7EMAZGYOjs = require('../../chunk-7EMAZGYO.js');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
var _chunkVSGYTGHYjs = require('../../chunk-VSGYTGHY.js');
|
|
10
|
+
var _chunk5RBTN33Ajs = require('../../chunk-5RBTN33A.js');
|
|
12
11
|
|
|
13
12
|
// src/http/h3/bind.ts
|
|
14
13
|
var _h3 = require('h3');
|
|
@@ -17,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/h3");
|
|
|
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
|
|
@@ -33,32 +32,31 @@ function bind(router, data, opts = {}) {
|
|
|
33
32
|
});
|
|
34
33
|
registerRoute();
|
|
35
34
|
function registerRoute() {
|
|
36
|
-
|
|
35
|
+
_chunkFX3LDQIIjs.Context.applyAddons(globalAddons, router, "h3");
|
|
37
36
|
if (parallelRoute) {
|
|
38
37
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
39
|
-
|
|
38
|
+
_chunkFX3LDQIIjs.Context.applyAddons(parallelAddons, subRouter, "h3");
|
|
40
39
|
subRouter.post(parallelRoute, _h3.eventHandler.call(void 0, {
|
|
41
|
-
handler: /* @__PURE__ */
|
|
40
|
+
handler: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, async (event) => {
|
|
42
41
|
const body = await _h3.readBody.call(void 0, event, {
|
|
43
42
|
strict: true
|
|
44
43
|
});
|
|
45
44
|
async function errorHandler(e) {
|
|
46
|
-
const error = await
|
|
45
|
+
const error = await _chunkFX3LDQIIjs.Context.filterRecord.default(e);
|
|
47
46
|
_h3.setResponseStatus.call(void 0, event, error.status);
|
|
48
47
|
return error;
|
|
49
48
|
}
|
|
50
|
-
|
|
51
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
49
|
+
_chunk5RBTN33Ajs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkFX3LDQIIjs.BadRequestException)("data format should be an array"));
|
|
52
51
|
try {
|
|
53
52
|
return Promise.all(body.map((item, i) => {
|
|
54
53
|
return new Promise(async (resolve) => {
|
|
55
54
|
const { tag, func } = item;
|
|
56
55
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
57
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
56
|
+
if (!metaMap.has(tag)) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
58
57
|
const meta2 = metaMap.get(tag)[func];
|
|
59
|
-
if (!meta2) return resolve(await
|
|
60
|
-
const
|
|
61
|
-
const aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
58
|
+
if (!meta2) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
|
+
const aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
62
60
|
globalFilter,
|
|
63
61
|
globalGuards,
|
|
64
62
|
globalPipe
|
|
@@ -70,21 +68,19 @@ function bind(router, data, opts = {}) {
|
|
|
70
68
|
event,
|
|
71
69
|
meta: meta2,
|
|
72
70
|
moduleMap,
|
|
73
|
-
tag,
|
|
74
|
-
func,
|
|
75
71
|
parallel: true,
|
|
76
72
|
app: router,
|
|
77
|
-
...
|
|
78
|
-
getCookie: /* @__PURE__ */
|
|
79
|
-
setCookie: /* @__PURE__ */
|
|
80
|
-
delCookie: /* @__PURE__ */
|
|
81
|
-
redirect: /* @__PURE__ */
|
|
82
|
-
setResHeaders: /* @__PURE__ */
|
|
83
|
-
setResStatus: /* @__PURE__ */
|
|
84
|
-
getRequest: /* @__PURE__ */
|
|
85
|
-
getResponse: /* @__PURE__ */
|
|
73
|
+
...item,
|
|
74
|
+
getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
75
|
+
setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
76
|
+
delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
77
|
+
redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url, status) => _h3.sendRedirect.call(void 0, event, url, status), "redirect"),
|
|
78
|
+
setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
79
|
+
setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
80
|
+
getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
81
|
+
getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
86
82
|
};
|
|
87
|
-
const context = new (0,
|
|
83
|
+
const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
|
|
88
84
|
context.run(aop, resolve, resolve);
|
|
89
85
|
});
|
|
90
86
|
}));
|
|
@@ -103,15 +99,15 @@ function bind(router, data, opts = {}) {
|
|
|
103
99
|
const needBody = params.some((item) => item.type === "body");
|
|
104
100
|
let aop;
|
|
105
101
|
if (!dynamic) {
|
|
106
|
-
aop =
|
|
102
|
+
aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
107
103
|
globalFilter,
|
|
108
104
|
globalGuards,
|
|
109
105
|
globalPipe
|
|
110
106
|
});
|
|
111
107
|
}
|
|
112
108
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
113
|
-
|
|
114
|
-
subRouter[http.type](
|
|
109
|
+
_chunkFX3LDQIIjs.Context.applyAddons(addons, subRouter, "h3");
|
|
110
|
+
subRouter[http.type](_chunkFX3LDQIIjs.joinUrl.call(void 0, http.prefix, http.route), _h3.defineEventHandler.call(void 0, async (event) => {
|
|
115
111
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
116
112
|
const contextData = {
|
|
117
113
|
type: "h3",
|
|
@@ -128,19 +124,19 @@ function bind(router, data, opts = {}) {
|
|
|
128
124
|
body: needBody ? await _h3.readBody.call(void 0, event, {
|
|
129
125
|
strict: true
|
|
130
126
|
}) : void 0,
|
|
131
|
-
getCookie: /* @__PURE__ */
|
|
132
|
-
setCookie: /* @__PURE__ */
|
|
133
|
-
redirect: /* @__PURE__ */
|
|
134
|
-
setResHeaders: /* @__PURE__ */
|
|
135
|
-
setResStatus: /* @__PURE__ */
|
|
136
|
-
delCookie: /* @__PURE__ */
|
|
137
|
-
getRequest: /* @__PURE__ */
|
|
138
|
-
getResponse: /* @__PURE__ */
|
|
127
|
+
getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
128
|
+
setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
129
|
+
redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url) => _h3.sendRedirect.call(void 0, event, url), "redirect"),
|
|
130
|
+
setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
131
|
+
setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
132
|
+
delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
133
|
+
getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
134
|
+
getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
139
135
|
};
|
|
140
|
-
const context = new (0,
|
|
136
|
+
const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
|
|
141
137
|
_h3.setHeaders.call(void 0, event, http.headers || {});
|
|
142
138
|
if (dynamic) {
|
|
143
|
-
aop =
|
|
139
|
+
aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
144
140
|
globalFilter,
|
|
145
141
|
globalGuards,
|
|
146
142
|
globalPipe
|
|
@@ -151,13 +147,13 @@ function bind(router, data, opts = {}) {
|
|
|
151
147
|
return err;
|
|
152
148
|
});
|
|
153
149
|
}));
|
|
154
|
-
router.use(
|
|
150
|
+
router.use(_chunkFX3LDQIIjs.joinUrl.call(void 0, http.prefix, http.route), _h3.useBase.call(void 0, "", subRouter.handler));
|
|
155
151
|
}
|
|
156
152
|
}
|
|
157
153
|
}
|
|
158
|
-
|
|
154
|
+
_chunk5RBTN33Ajs.__name.call(void 0, registerRoute, "registerRoute");
|
|
159
155
|
}
|
|
160
|
-
|
|
156
|
+
_chunk5RBTN33Ajs.__name.call(void 0, bind, "bind");
|
|
161
157
|
|
|
162
158
|
|
|
163
159
|
exports.bind = bind;
|
package/dist/http/h3/index.mjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BadRequestException,
|
|
3
3
|
Context,
|
|
4
|
-
argToReq,
|
|
5
4
|
createControllerMetaMap,
|
|
6
5
|
detectAopDep,
|
|
7
6
|
joinUrl
|
|
8
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-CVPZWDXU.mjs";
|
|
9
8
|
import {
|
|
10
9
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-FXTJ3BJ6.mjs";
|
|
12
11
|
|
|
13
12
|
// src/http/h3/bind.ts
|
|
14
13
|
import { createRouter, defineEventHandler, deleteCookie, eventHandler, getCookie, getQuery, getRequestHeaders, getRouterParams, readBody, sendRedirect, setCookie, setHeaders, setResponseHeaders, setResponseStatus, useBase } from "h3";
|
|
@@ -57,7 +56,6 @@ function bind(router, data, opts = {}) {
|
|
|
57
56
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
58
57
|
const meta2 = metaMap.get(tag)[func];
|
|
59
58
|
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
|
|
60
|
-
const { data: { params } } = meta2;
|
|
61
59
|
const aop = Context.getAop(meta2, {
|
|
62
60
|
globalFilter,
|
|
63
61
|
globalGuards,
|
|
@@ -70,11 +68,9 @@ function bind(router, data, opts = {}) {
|
|
|
70
68
|
event,
|
|
71
69
|
meta: meta2,
|
|
72
70
|
moduleMap,
|
|
73
|
-
tag,
|
|
74
|
-
func,
|
|
75
71
|
parallel: true,
|
|
76
72
|
app: router,
|
|
77
|
-
...
|
|
73
|
+
...item,
|
|
78
74
|
getCookie: /* @__PURE__ */ __name((key) => getCookie(event, key), "getCookie"),
|
|
79
75
|
setCookie: /* @__PURE__ */ __name((key, value, opts2) => setCookie(event, key, value, opts2), "setCookie"),
|
|
80
76
|
delCookie: /* @__PURE__ */ __name((key) => deleteCookie(event, key), "delCookie"),
|
|
@@ -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-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
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-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
8
|
interface HonoCtx extends HttpCtx {
|