phecda-server 7.0.0-alpha.1 → 7.0.0-alpha.11
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 +1 -1
- package/assets/schema.json +55 -55
- package/bin/cli.mjs +33 -25
- package/dist/chunk-4LLLQOMF.js +152 -0
- package/dist/{chunk-7YQ57BQS.js → chunk-6OQ2SB5W.js} +137 -69
- package/dist/{chunk-GSPBHZBH.js → chunk-G7JFKM2M.js} +96 -80
- 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-XYVMNY2X.mjs → chunk-YCES6ABN.mjs} +124 -56
- package/dist/{chunk-V7EI76QQ.mjs → chunk-Z7NAAE4M.mjs} +48 -32
- 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 +44 -38
- package/dist/index.d.ts +44 -38
- 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 -6
- package/register/export.mjs +30 -0
- package/register/index.mjs +50 -40
- package/register/loader.mjs +110 -74
- package/register/utils.mjs +86 -56
- package/dist/chunk-J5CFUN4V.js +0 -73
- package/dist/chunk-WHJ5FALK.mjs +0 -73
|
@@ -1,16 +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 _chunkKCPBITYZjs = require('../../chunk-KCPBITYZ.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkG7JFKM2Mjs = require('../../chunk-G7JFKM2M.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
14
14
|
|
|
15
15
|
// src/http/fastify/bind.ts
|
|
16
16
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -18,14 +18,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/fastify");
|
|
|
18
18
|
function bind(fastify, data, opts = {}) {
|
|
19
19
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, fastifyOpts, dynamic = false } = opts;
|
|
20
20
|
const { moduleMap, meta } = data;
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkG7JFKM2Mjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
22
|
const { controller, http, func, tag } = meta2.data;
|
|
23
23
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _2 => _2.type])) {
|
|
24
24
|
debug(`register method "${func}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunkG7JFKM2Mjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -33,57 +33,55 @@ function bind(fastify, data, opts = {}) {
|
|
|
33
33
|
guards: globalGuards
|
|
34
34
|
});
|
|
35
35
|
fastify.register(async (fastify2, _, done) => {
|
|
36
|
-
|
|
36
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(globalAddons, fastify2, "fastify");
|
|
37
37
|
if (parallelRoute) {
|
|
38
38
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
39
|
-
|
|
39
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(parallelAddons, fastify3, "fastify");
|
|
40
40
|
fastify3.post(parallelRoute, async (req, res) => {
|
|
41
41
|
const { body } = req;
|
|
42
42
|
async function errorHandler(e) {
|
|
43
|
-
const error = await
|
|
43
|
+
const error = await _chunkG7JFKM2Mjs.Context.filterRecord.default(e);
|
|
44
44
|
return res.status(error.status).send(error);
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
46
|
+
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkG7JFKM2Mjs.BadRequestException)("data format should be an array"));
|
|
48
48
|
try {
|
|
49
49
|
return Promise.all(body.map((item, i) => {
|
|
50
50
|
return new Promise(async (resolve) => {
|
|
51
51
|
const { tag, func } = item;
|
|
52
52
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
53
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
53
|
+
if (!metaMap.has(tag)) return resolve(await _chunkG7JFKM2Mjs.Context.filterRecord.default(new (0, _chunkG7JFKM2Mjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
54
54
|
const meta2 = metaMap.get(tag)[func];
|
|
55
|
-
if (!meta2) return resolve(await
|
|
56
|
-
const
|
|
57
|
-
const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
|
|
55
|
+
if (!meta2) return resolve(await _chunkG7JFKM2Mjs.Context.filterRecord.default(new (0, _chunkG7JFKM2Mjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
56
|
+
const aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
58
57
|
globalFilter,
|
|
59
58
|
globalGuards,
|
|
60
59
|
globalPipe
|
|
61
60
|
});
|
|
62
61
|
const contextData = {
|
|
63
62
|
type: "fastify",
|
|
63
|
+
category: "http",
|
|
64
64
|
parallel: true,
|
|
65
65
|
request: req,
|
|
66
66
|
index: i,
|
|
67
67
|
meta: meta2,
|
|
68
68
|
response: res,
|
|
69
69
|
moduleMap,
|
|
70
|
-
tag,
|
|
71
|
-
func,
|
|
72
70
|
app: fastify3,
|
|
73
|
-
...
|
|
71
|
+
...item,
|
|
74
72
|
// @ts-expect-error need @fastify/cookie
|
|
75
|
-
getCookie: /* @__PURE__ */
|
|
73
|
+
getCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
76
74
|
// @ts-expect-error need @fastify/cookie
|
|
77
|
-
setCookie: /* @__PURE__ */
|
|
75
|
+
setCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
78
76
|
// @ts-expect-error need @fastify/cookie
|
|
79
|
-
delCookie: /* @__PURE__ */
|
|
80
|
-
redirect: /* @__PURE__ */
|
|
81
|
-
setResHeaders: /* @__PURE__ */
|
|
82
|
-
setResStatus: /* @__PURE__ */
|
|
83
|
-
getRequest: /* @__PURE__ */
|
|
84
|
-
getResponse: /* @__PURE__ */
|
|
77
|
+
delCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
78
|
+
redirect: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
79
|
+
setResHeaders: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
80
|
+
setResStatus: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
81
|
+
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req.raw, "getRequest"),
|
|
82
|
+
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res.raw, "getResponse")
|
|
85
83
|
};
|
|
86
|
-
const context = new (0,
|
|
84
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)(contextData);
|
|
87
85
|
context.run(aop, resolve, resolve);
|
|
88
86
|
});
|
|
89
87
|
})).then((ret) => {
|
|
@@ -102,19 +100,20 @@ function bind(fastify, data, opts = {}) {
|
|
|
102
100
|
const { data: { addons, define, http } } = meta2;
|
|
103
101
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
|
|
104
102
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
105
|
-
|
|
103
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(addons, fastify3, "fastify");
|
|
106
104
|
let aop;
|
|
107
105
|
if (!dynamic) {
|
|
108
|
-
aop =
|
|
106
|
+
aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
109
107
|
globalFilter,
|
|
110
108
|
globalGuards,
|
|
111
109
|
globalPipe
|
|
112
110
|
});
|
|
113
111
|
}
|
|
114
|
-
fastify3[http.type](http.prefix
|
|
112
|
+
fastify3[http.type](_chunkG7JFKM2Mjs.joinUrl.call(void 0, http.prefix, http.route), _optionalChain([define, 'optionalAccess', _4 => _4.fastify]) || {}, async (req, res) => {
|
|
115
113
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
116
114
|
const contextData = {
|
|
117
115
|
type: "fastify",
|
|
116
|
+
category: "http",
|
|
118
117
|
request: req,
|
|
119
118
|
meta: meta2,
|
|
120
119
|
response: res,
|
|
@@ -127,23 +126,23 @@ function bind(fastify, data, opts = {}) {
|
|
|
127
126
|
headers: req.headers,
|
|
128
127
|
app: fastify3,
|
|
129
128
|
// @ts-expect-error need @fastify/cookie
|
|
130
|
-
getCookie: /* @__PURE__ */
|
|
129
|
+
getCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
131
130
|
// @ts-expect-error need @fastify/cookie
|
|
132
|
-
setCookie: /* @__PURE__ */
|
|
131
|
+
setCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
133
132
|
// @ts-expect-error need @fastify/cookie
|
|
134
|
-
delCookie: /* @__PURE__ */
|
|
133
|
+
delCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => res.clearCookie(key, {
|
|
135
134
|
url: ""
|
|
136
135
|
}), "delCookie"),
|
|
137
|
-
redirect: /* @__PURE__ */
|
|
138
|
-
setResHeaders: /* @__PURE__ */
|
|
139
|
-
setResStatus: /* @__PURE__ */
|
|
140
|
-
getRequest: /* @__PURE__ */
|
|
141
|
-
getResponse: /* @__PURE__ */
|
|
136
|
+
redirect: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
137
|
+
setResHeaders: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
138
|
+
setResStatus: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
139
|
+
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req.raw, "getRequest"),
|
|
140
|
+
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res.raw, "getResponse")
|
|
142
141
|
};
|
|
143
|
-
const context = new (0,
|
|
142
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)(contextData);
|
|
144
143
|
if (http.headers) res.headers(http.headers);
|
|
145
144
|
if (dynamic) {
|
|
146
|
-
aop =
|
|
145
|
+
aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
147
146
|
globalFilter,
|
|
148
147
|
globalGuards,
|
|
149
148
|
globalPipe
|
|
@@ -164,11 +163,11 @@ function bind(fastify, data, opts = {}) {
|
|
|
164
163
|
done();
|
|
165
164
|
}, fastifyOpts);
|
|
166
165
|
}
|
|
167
|
-
|
|
166
|
+
_chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
|
|
168
167
|
function Fastify(opts) {
|
|
169
|
-
return
|
|
168
|
+
return _chunkKCPBITYZjs.Define.call(void 0, "fastify", opts);
|
|
170
169
|
}
|
|
171
|
-
|
|
170
|
+
_chunk4LLLQOMFjs.__name.call(void 0, Fastify, "Fastify");
|
|
172
171
|
|
|
173
172
|
|
|
174
173
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-MUI6MTUO.mjs";
|
|
4
4
|
import {
|
|
5
5
|
BadRequestException,
|
|
6
6
|
Context,
|
|
7
|
-
argToReq,
|
|
8
7
|
createControllerMetaMap,
|
|
9
|
-
detectAopDep
|
|
10
|
-
|
|
8
|
+
detectAopDep,
|
|
9
|
+
joinUrl
|
|
10
|
+
} from "../../chunk-Z7NAAE4M.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-NQ55PA2X.mjs";
|
|
14
14
|
|
|
15
15
|
// src/http/fastify/bind.ts
|
|
16
16
|
import Debug from "debug";
|
|
@@ -53,7 +53,6 @@ function bind(fastify, data, opts = {}) {
|
|
|
53
53
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
54
54
|
const meta2 = metaMap.get(tag)[func];
|
|
55
55
|
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
|
|
56
|
-
const { data: { params } } = meta2;
|
|
57
56
|
const aop = Context.getAop(meta2, {
|
|
58
57
|
globalFilter,
|
|
59
58
|
globalGuards,
|
|
@@ -61,16 +60,15 @@ function bind(fastify, data, opts = {}) {
|
|
|
61
60
|
});
|
|
62
61
|
const contextData = {
|
|
63
62
|
type: "fastify",
|
|
63
|
+
category: "http",
|
|
64
64
|
parallel: true,
|
|
65
65
|
request: req,
|
|
66
66
|
index: i,
|
|
67
67
|
meta: meta2,
|
|
68
68
|
response: res,
|
|
69
69
|
moduleMap,
|
|
70
|
-
tag,
|
|
71
|
-
func,
|
|
72
70
|
app: fastify3,
|
|
73
|
-
...
|
|
71
|
+
...item,
|
|
74
72
|
// @ts-expect-error need @fastify/cookie
|
|
75
73
|
getCookie: /* @__PURE__ */ __name((key) => req.cookies[key], "getCookie"),
|
|
76
74
|
// @ts-expect-error need @fastify/cookie
|
|
@@ -111,10 +109,11 @@ function bind(fastify, data, opts = {}) {
|
|
|
111
109
|
globalPipe
|
|
112
110
|
});
|
|
113
111
|
}
|
|
114
|
-
fastify3[http.type](http.prefix
|
|
112
|
+
fastify3[http.type](joinUrl(http.prefix, http.route), define?.fastify || {}, async (req, res) => {
|
|
115
113
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
116
114
|
const contextData = {
|
|
117
115
|
type: "fastify",
|
|
116
|
+
category: "http",
|
|
118
117
|
request: req,
|
|
119
118
|
meta: meta2,
|
|
120
119
|
response: res,
|
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-DIfgUKIU.mjs';
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-DYviSl5B.mjs';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-CR-D39hQ.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-CUTbX_IS.js';
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-BF1TDbFV.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-CR-D39hQ.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,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/h3/bind.ts
|
|
13
13
|
var _h3 = require('h3');
|
|
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/h3");
|
|
|
16
16
|
function bind(router, data, opts = {}) {
|
|
17
17
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
|
-
const metaMap =
|
|
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,57 +32,55 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(globalAddons, router, "h3");
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
38
|
-
|
|
38
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(parallelAddons, subRouter, "h3");
|
|
39
39
|
subRouter.post(parallelRoute, _h3.eventHandler.call(void 0, {
|
|
40
|
-
handler: /* @__PURE__ */
|
|
40
|
+
handler: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, async (event) => {
|
|
41
41
|
const body = await _h3.readBody.call(void 0, event, {
|
|
42
42
|
strict: true
|
|
43
43
|
});
|
|
44
44
|
async function errorHandler(e) {
|
|
45
|
-
const error = await
|
|
45
|
+
const error = await _chunkG7JFKM2Mjs.Context.filterRecord.default(e);
|
|
46
46
|
_h3.setResponseStatus.call(void 0, event, error.status);
|
|
47
47
|
return error;
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
49
|
+
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkG7JFKM2Mjs.BadRequestException)("data format should be an array"));
|
|
51
51
|
try {
|
|
52
52
|
return Promise.all(body.map((item, i) => {
|
|
53
53
|
return new Promise(async (resolve) => {
|
|
54
54
|
const { tag, func } = item;
|
|
55
55
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
56
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
56
|
+
if (!metaMap.has(tag)) return resolve(await _chunkG7JFKM2Mjs.Context.filterRecord.default(new (0, _chunkG7JFKM2Mjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
57
57
|
const meta2 = metaMap.get(tag)[func];
|
|
58
|
-
if (!meta2) return resolve(await
|
|
59
|
-
const
|
|
60
|
-
const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
|
|
58
|
+
if (!meta2) return resolve(await _chunkG7JFKM2Mjs.Context.filterRecord.default(new (0, _chunkG7JFKM2Mjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
|
+
const aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
61
60
|
globalFilter,
|
|
62
61
|
globalGuards,
|
|
63
62
|
globalPipe
|
|
64
63
|
});
|
|
65
64
|
const contextData = {
|
|
66
65
|
type: "h3",
|
|
66
|
+
category: "http",
|
|
67
67
|
index: i,
|
|
68
68
|
event,
|
|
69
69
|
meta: meta2,
|
|
70
70
|
moduleMap,
|
|
71
|
-
tag,
|
|
72
|
-
func,
|
|
73
71
|
parallel: true,
|
|
74
72
|
app: router,
|
|
75
|
-
...
|
|
76
|
-
getCookie: /* @__PURE__ */
|
|
77
|
-
setCookie: /* @__PURE__ */
|
|
78
|
-
delCookie: /* @__PURE__ */
|
|
79
|
-
redirect: /* @__PURE__ */
|
|
80
|
-
setResHeaders: /* @__PURE__ */
|
|
81
|
-
setResStatus: /* @__PURE__ */
|
|
82
|
-
getRequest: /* @__PURE__ */
|
|
83
|
-
getResponse: /* @__PURE__ */
|
|
73
|
+
...item,
|
|
74
|
+
getCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
75
|
+
setCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
76
|
+
delCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
77
|
+
redirect: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (url, status) => _h3.sendRedirect.call(void 0, event, url, status), "redirect"),
|
|
78
|
+
setResHeaders: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
79
|
+
setResStatus: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
80
|
+
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
81
|
+
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
84
82
|
};
|
|
85
|
-
const context = new (0,
|
|
83
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)(contextData);
|
|
86
84
|
context.run(aop, resolve, resolve);
|
|
87
85
|
});
|
|
88
86
|
}));
|
|
@@ -101,18 +99,19 @@ function bind(router, data, opts = {}) {
|
|
|
101
99
|
const needBody = params.some((item) => item.type === "body");
|
|
102
100
|
let aop;
|
|
103
101
|
if (!dynamic) {
|
|
104
|
-
aop =
|
|
102
|
+
aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
105
103
|
globalFilter,
|
|
106
104
|
globalGuards,
|
|
107
105
|
globalPipe
|
|
108
106
|
});
|
|
109
107
|
}
|
|
110
108
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
111
|
-
|
|
112
|
-
subRouter[http.type](http.prefix
|
|
109
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(addons, subRouter, "h3");
|
|
110
|
+
subRouter[http.type](_chunkG7JFKM2Mjs.joinUrl.call(void 0, http.prefix, http.route), _h3.defineEventHandler.call(void 0, async (event) => {
|
|
113
111
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
114
112
|
const contextData = {
|
|
115
113
|
type: "h3",
|
|
114
|
+
category: "http",
|
|
116
115
|
meta: meta2,
|
|
117
116
|
event,
|
|
118
117
|
moduleMap,
|
|
@@ -125,19 +124,19 @@ function bind(router, data, opts = {}) {
|
|
|
125
124
|
body: needBody ? await _h3.readBody.call(void 0, event, {
|
|
126
125
|
strict: true
|
|
127
126
|
}) : void 0,
|
|
128
|
-
getCookie: /* @__PURE__ */
|
|
129
|
-
setCookie: /* @__PURE__ */
|
|
130
|
-
redirect: /* @__PURE__ */
|
|
131
|
-
setResHeaders: /* @__PURE__ */
|
|
132
|
-
setResStatus: /* @__PURE__ */
|
|
133
|
-
delCookie: /* @__PURE__ */
|
|
134
|
-
getRequest: /* @__PURE__ */
|
|
135
|
-
getResponse: /* @__PURE__ */
|
|
127
|
+
getCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
128
|
+
setCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
129
|
+
redirect: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (url) => _h3.sendRedirect.call(void 0, event, url), "redirect"),
|
|
130
|
+
setResHeaders: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
131
|
+
setResStatus: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
132
|
+
delCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
133
|
+
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
134
|
+
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
136
135
|
};
|
|
137
|
-
const context = new (0,
|
|
136
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)(contextData);
|
|
138
137
|
_h3.setHeaders.call(void 0, event, http.headers || {});
|
|
139
138
|
if (dynamic) {
|
|
140
|
-
aop =
|
|
139
|
+
aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
141
140
|
globalFilter,
|
|
142
141
|
globalGuards,
|
|
143
142
|
globalPipe
|
|
@@ -148,13 +147,13 @@ function bind(router, data, opts = {}) {
|
|
|
148
147
|
return err;
|
|
149
148
|
});
|
|
150
149
|
}));
|
|
151
|
-
router.use(http.prefix
|
|
150
|
+
router.use(_chunkG7JFKM2Mjs.joinUrl.call(void 0, http.prefix, http.route), _h3.useBase.call(void 0, "", subRouter.handler));
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
153
|
}
|
|
155
|
-
|
|
154
|
+
_chunk4LLLQOMFjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
156
155
|
}
|
|
157
|
-
|
|
156
|
+
_chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
|
|
158
157
|
|
|
159
158
|
|
|
160
159
|
exports.bind = bind;
|
package/dist/http/h3/index.mjs
CHANGED
|
@@ -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/h3/bind.ts
|
|
13
13
|
import { createRouter, defineEventHandler, deleteCookie, eventHandler, getCookie, getQuery, getRequestHeaders, getRouterParams, readBody, sendRedirect, setCookie, setHeaders, setResponseHeaders, setResponseStatus, useBase } from "h3";
|
|
@@ -56,7 +56,6 @@ function bind(router, data, opts = {}) {
|
|
|
56
56
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
57
57
|
const meta2 = metaMap.get(tag)[func];
|
|
58
58
|
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
|
-
const { data: { params } } = meta2;
|
|
60
59
|
const aop = Context.getAop(meta2, {
|
|
61
60
|
globalFilter,
|
|
62
61
|
globalGuards,
|
|
@@ -64,15 +63,14 @@ function bind(router, data, opts = {}) {
|
|
|
64
63
|
});
|
|
65
64
|
const contextData = {
|
|
66
65
|
type: "h3",
|
|
66
|
+
category: "http",
|
|
67
67
|
index: i,
|
|
68
68
|
event,
|
|
69
69
|
meta: meta2,
|
|
70
70
|
moduleMap,
|
|
71
|
-
tag,
|
|
72
|
-
func,
|
|
73
71
|
parallel: true,
|
|
74
72
|
app: router,
|
|
75
|
-
...
|
|
73
|
+
...item,
|
|
76
74
|
getCookie: /* @__PURE__ */ __name((key) => getCookie(event, key), "getCookie"),
|
|
77
75
|
setCookie: /* @__PURE__ */ __name((key, value, opts2) => setCookie(event, key, value, opts2), "setCookie"),
|
|
78
76
|
delCookie: /* @__PURE__ */ __name((key) => deleteCookie(event, key), "delCookie"),
|
|
@@ -109,10 +107,11 @@ function bind(router, data, opts = {}) {
|
|
|
109
107
|
}
|
|
110
108
|
const subRouter = createRouter();
|
|
111
109
|
Context.applyAddons(addons, subRouter, "h3");
|
|
112
|
-
subRouter[http.type](http.prefix
|
|
110
|
+
subRouter[http.type](joinUrl(http.prefix, http.route), defineEventHandler(async (event) => {
|
|
113
111
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
114
112
|
const contextData = {
|
|
115
113
|
type: "h3",
|
|
114
|
+
category: "http",
|
|
116
115
|
meta: meta2,
|
|
117
116
|
event,
|
|
118
117
|
moduleMap,
|
|
@@ -148,7 +147,7 @@ function bind(router, data, opts = {}) {
|
|
|
148
147
|
return err;
|
|
149
148
|
});
|
|
150
149
|
}));
|
|
151
|
-
router.use(http.prefix
|
|
150
|
+
router.use(joinUrl(http.prefix, http.route), useBase("", subRouter.handler));
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
153
|
}
|
|
@@ -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-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 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-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 HonoCtx extends
|
|
8
|
+
interface HonoCtx extends HttpCtx {
|
|
9
9
|
type: 'hono';
|
|
10
10
|
context: Context;
|
|
11
11
|
app: Hono;
|