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