phecda-server 5.3.1 → 5.3.3
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-ODUYOCDF.js → chunk-2HVTWYS2.js} +37 -37
- package/dist/{chunk-N4ULJDEQ.js → chunk-3D7AROG2.js} +36 -25
- package/dist/{chunk-BZKJ5NBU.mjs → chunk-3IPYLGY2.mjs} +1 -1
- package/dist/{chunk-LHLQIQPH.mjs → chunk-ECSI4QBK.mjs} +18 -7
- package/dist/{chunk-RVWBJ6LV.js → chunk-GHFSIZUO.js} +2 -10
- package/dist/{chunk-QYX5Q7KO.js → chunk-RZ7IXJYQ.js} +60 -60
- package/dist/{chunk-ORQAEOSE.mjs → chunk-SXOZVIKW.mjs} +2 -2
- package/dist/{chunk-MESZCLSS.mjs → chunk-UXD62LGG.mjs} +2 -10
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +43 -43
- package/dist/index.mjs +6 -6
- package/dist/rpc/bullmq/index.js +12 -12
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.js +12 -12
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.js +11 -11
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.js +13 -13
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.js +11 -11
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/server/elysia/index.js +32 -32
- package/dist/server/elysia/index.mjs +3 -3
- package/dist/server/express/index.js +30 -30
- package/dist/server/express/index.mjs +2 -2
- package/dist/server/fastify/index.js +31 -31
- package/dist/server/fastify/index.mjs +3 -3
- package/dist/server/h3/index.js +30 -30
- package/dist/server/h3/index.mjs +2 -2
- package/dist/server/hono/index.js +29 -29
- package/dist/server/hono/index.mjs +2 -2
- package/dist/server/hyper-express/index.js +29 -29
- package/dist/server/hyper-express/index.mjs +2 -2
- package/dist/server/koa/index.js +30 -30
- package/dist/server/koa/index.mjs +2 -2
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/package.json +2 -1
|
@@ -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 _chunk2HVTWYS2js = require('../../chunk-2HVTWYS2.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkRZ7IXJYQjs = require('../../chunk-RZ7IXJYQ.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
14
14
|
|
|
15
15
|
// src/server/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, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe, fastifyOpts } = opts;
|
|
20
20
|
const { moduleMap, meta } = data;
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkRZ7IXJYQjs.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
|
+
_chunkRZ7IXJYQjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
plugins: [
|
|
30
30
|
...globalPlugins,
|
|
31
31
|
...parallelPlugins
|
|
@@ -34,12 +34,12 @@ function bind(fastify, data, opts = {}) {
|
|
|
34
34
|
interceptors: globalInterceptors
|
|
35
35
|
});
|
|
36
36
|
fastify.register((fastify2, _, done) => {
|
|
37
|
-
|
|
37
|
+
_chunkRZ7IXJYQjs.Context.usePlugin(globalPlugins, "fastify").forEach((p) => {
|
|
38
38
|
p[Symbol.for("skip-override")] = true;
|
|
39
39
|
fastify2.register(p);
|
|
40
40
|
});
|
|
41
41
|
fastify2.register((fastify3, _opts, done2) => {
|
|
42
|
-
|
|
42
|
+
_chunkRZ7IXJYQjs.Context.usePlugin(parallelPlugins, "fastify").forEach((p) => {
|
|
43
43
|
p[Symbol.for("skip-override")] = true;
|
|
44
44
|
fastify3.register(p);
|
|
45
45
|
});
|
|
@@ -47,19 +47,19 @@ function bind(fastify, data, opts = {}) {
|
|
|
47
47
|
fastify3.post(parallelRoute, async (req, res) => {
|
|
48
48
|
const { body } = req;
|
|
49
49
|
async function errorHandler(e) {
|
|
50
|
-
const error = await
|
|
50
|
+
const error = await _chunkRZ7IXJYQjs.Context.filterRecord.default(e);
|
|
51
51
|
return res.status(error.status).send(error);
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
53
|
+
_chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
54
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkRZ7IXJYQjs.BadRequestException)("data format should be an array"));
|
|
55
55
|
try {
|
|
56
56
|
return Promise.all(body.map((item, i) => {
|
|
57
57
|
return new Promise(async (resolve) => {
|
|
58
58
|
const { tag, func } = item;
|
|
59
59
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
60
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
60
|
+
if (!metaMap.has(tag)) return resolve(await _chunkRZ7IXJYQjs.Context.filterRecord.default(new (0, _chunkRZ7IXJYQjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
61
61
|
const meta2 = metaMap.get(tag)[func];
|
|
62
|
-
if (!meta2) return resolve(await
|
|
62
|
+
if (!meta2) return resolve(await _chunkRZ7IXJYQjs.Context.filterRecord.default(new (0, _chunkRZ7IXJYQjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
63
63
|
const { data: { params } } = meta2;
|
|
64
64
|
const contextData = {
|
|
65
65
|
type: "fastify",
|
|
@@ -72,18 +72,18 @@ function bind(fastify, data, opts = {}) {
|
|
|
72
72
|
tag,
|
|
73
73
|
func,
|
|
74
74
|
app: fastify3,
|
|
75
|
-
...
|
|
75
|
+
..._chunkRZ7IXJYQjs.argToReq.call(void 0, params, item.args, req.headers),
|
|
76
76
|
// @ts-expect-error need @fastify/cookie
|
|
77
|
-
getCookie: /* @__PURE__ */
|
|
77
|
+
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
78
78
|
// @ts-expect-error need @fastify/cookie
|
|
79
|
-
setCookie: /* @__PURE__ */
|
|
79
|
+
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
80
80
|
// @ts-expect-error need @fastify/cookie
|
|
81
|
-
delCookie: /* @__PURE__ */
|
|
82
|
-
redirect: /* @__PURE__ */
|
|
83
|
-
setResHeaders: /* @__PURE__ */
|
|
84
|
-
setResStatus: /* @__PURE__ */
|
|
81
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
82
|
+
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
83
|
+
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
84
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
|
|
85
85
|
};
|
|
86
|
-
const context = new (0,
|
|
86
|
+
const context = new (0, _chunkRZ7IXJYQjs.Context)(contextData);
|
|
87
87
|
context.run({
|
|
88
88
|
globalGuards,
|
|
89
89
|
globalInterceptors,
|
|
@@ -107,7 +107,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
107
107
|
const { data: { plugins, define, http } } = meta2;
|
|
108
108
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
|
|
109
109
|
fastify2.register((fastify3, _opts, done2) => {
|
|
110
|
-
|
|
110
|
+
_chunkRZ7IXJYQjs.Context.usePlugin(plugins, "fastify").forEach((p) => {
|
|
111
111
|
p[Symbol.for("skip-override")] = true;
|
|
112
112
|
fastify3.register(p);
|
|
113
113
|
});
|
|
@@ -127,18 +127,18 @@ function bind(fastify, data, opts = {}) {
|
|
|
127
127
|
headers: req.headers,
|
|
128
128
|
app: fastify3,
|
|
129
129
|
// @ts-expect-error need @fastify/cookie
|
|
130
|
-
getCookie: /* @__PURE__ */
|
|
130
|
+
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
131
131
|
// @ts-expect-error need @fastify/cookie
|
|
132
|
-
setCookie: /* @__PURE__ */
|
|
132
|
+
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
133
133
|
// @ts-expect-error need @fastify/cookie
|
|
134
|
-
delCookie: /* @__PURE__ */
|
|
134
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => res.clearCookie(key, {
|
|
135
135
|
path: ""
|
|
136
136
|
}), "delCookie"),
|
|
137
|
-
redirect: /* @__PURE__ */
|
|
138
|
-
setResHeaders: /* @__PURE__ */
|
|
139
|
-
setResStatus: /* @__PURE__ */
|
|
137
|
+
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
138
|
+
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
139
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
|
|
140
140
|
};
|
|
141
|
-
const context = new (0,
|
|
141
|
+
const context = new (0, _chunkRZ7IXJYQjs.Context)(contextData);
|
|
142
142
|
if (http.headers) res.headers(http.headers);
|
|
143
143
|
return context.run({
|
|
144
144
|
globalGuards,
|
|
@@ -160,11 +160,11 @@ function bind(fastify, data, opts = {}) {
|
|
|
160
160
|
done();
|
|
161
161
|
}, fastifyOpts);
|
|
162
162
|
}
|
|
163
|
-
|
|
163
|
+
_chunkGHFSIZUOjs.__name.call(void 0, bind, "bind");
|
|
164
164
|
function Fastify(opts) {
|
|
165
|
-
return
|
|
165
|
+
return _chunk2HVTWYS2js.Define.call(void 0, "fastify", opts);
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
_chunkGHFSIZUOjs.__name.call(void 0, Fastify, "Fastify");
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-SXOZVIKW.mjs";
|
|
4
4
|
import {
|
|
5
5
|
BadRequestException,
|
|
6
6
|
Context,
|
|
7
7
|
argToReq,
|
|
8
8
|
createControllerMetaMap,
|
|
9
9
|
detectAopDep
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-3IPYLGY2.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-UXD62LGG.mjs";
|
|
14
14
|
|
|
15
15
|
// src/server/fastify/bind.ts
|
|
16
16
|
import Debug from "debug";
|
package/dist/server/h3/index.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkRZ7IXJYQjs = require('../../chunk-RZ7IXJYQ.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
11
11
|
|
|
12
12
|
// src/server/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, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
|
-
const metaMap =
|
|
19
|
+
const metaMap = _chunkRZ7IXJYQjs.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
|
+
_chunkRZ7IXJYQjs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
plugins: [
|
|
28
28
|
...globalPlugins,
|
|
29
29
|
...parallelPlugins
|
|
@@ -35,29 +35,29 @@ function bind(router, data, opts = {}) {
|
|
|
35
35
|
async function registerRoute() {
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
router.post(parallelRoute, _h3.eventHandler.call(void 0, {
|
|
38
|
-
onRequest:
|
|
38
|
+
onRequest: _chunkRZ7IXJYQjs.Context.usePlugin([
|
|
39
39
|
...globalPlugins,
|
|
40
40
|
...parallelPlugins
|
|
41
41
|
], "h3").map(_h3.defineRequestMiddleware),
|
|
42
|
-
handler: /* @__PURE__ */
|
|
42
|
+
handler: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, async (event) => {
|
|
43
43
|
const body = await _h3.readBody.call(void 0, event, {
|
|
44
44
|
strict: true
|
|
45
45
|
});
|
|
46
46
|
async function errorHandler(e) {
|
|
47
|
-
const error = await
|
|
47
|
+
const error = await _chunkRZ7IXJYQjs.Context.filterRecord.default(e);
|
|
48
48
|
_h3.setResponseStatus.call(void 0, event, error.status);
|
|
49
49
|
return error;
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
51
|
+
_chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
52
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkRZ7IXJYQjs.BadRequestException)("data format should be an array"));
|
|
53
53
|
try {
|
|
54
54
|
return Promise.all(body.map((item, i) => {
|
|
55
55
|
return new Promise(async (resolve) => {
|
|
56
56
|
const { tag, func } = item;
|
|
57
57
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
58
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
58
|
+
if (!metaMap.has(tag)) return resolve(await _chunkRZ7IXJYQjs.Context.filterRecord.default(new (0, _chunkRZ7IXJYQjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
59
59
|
const meta2 = metaMap.get(tag)[func];
|
|
60
|
-
if (!meta2) return resolve(await
|
|
60
|
+
if (!meta2) return resolve(await _chunkRZ7IXJYQjs.Context.filterRecord.default(new (0, _chunkRZ7IXJYQjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
61
61
|
const { data: { params } } = meta2;
|
|
62
62
|
const contextData = {
|
|
63
63
|
type: "h3",
|
|
@@ -69,15 +69,15 @@ function bind(router, data, opts = {}) {
|
|
|
69
69
|
func,
|
|
70
70
|
parallel: true,
|
|
71
71
|
app: router,
|
|
72
|
-
...
|
|
73
|
-
getCookie: /* @__PURE__ */
|
|
74
|
-
setCookie: /* @__PURE__ */
|
|
75
|
-
delCookie: /* @__PURE__ */
|
|
76
|
-
redirect: /* @__PURE__ */
|
|
77
|
-
setResHeaders: /* @__PURE__ */
|
|
78
|
-
setResStatus: /* @__PURE__ */
|
|
72
|
+
..._chunkRZ7IXJYQjs.argToReq.call(void 0, params, item.args, _h3.getRequestHeaders.call(void 0, event)),
|
|
73
|
+
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
74
|
+
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
75
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
76
|
+
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url, status) => _h3.sendRedirect.call(void 0, event, url, status), "redirect"),
|
|
77
|
+
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
78
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus")
|
|
79
79
|
};
|
|
80
|
-
const context = new (0,
|
|
80
|
+
const context = new (0, _chunkRZ7IXJYQjs.Context)(contextData);
|
|
81
81
|
context.run({
|
|
82
82
|
globalGuards,
|
|
83
83
|
globalInterceptors,
|
|
@@ -99,11 +99,11 @@ function bind(router, data, opts = {}) {
|
|
|
99
99
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
100
100
|
const needBody = params.some((item) => item.type === "body");
|
|
101
101
|
router[http.type](http.prefix + http.route, _h3.eventHandler.call(void 0, {
|
|
102
|
-
onRequest:
|
|
102
|
+
onRequest: _chunkRZ7IXJYQjs.Context.usePlugin([
|
|
103
103
|
...globalPlugins,
|
|
104
104
|
...plugins
|
|
105
105
|
], "h3").map(_h3.defineRequestMiddleware),
|
|
106
|
-
handler: /* @__PURE__ */
|
|
106
|
+
handler: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, async (event) => {
|
|
107
107
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
108
108
|
const contextData = {
|
|
109
109
|
type: "h3",
|
|
@@ -119,14 +119,14 @@ function bind(router, data, opts = {}) {
|
|
|
119
119
|
body: needBody ? await _h3.readBody.call(void 0, event, {
|
|
120
120
|
strict: true
|
|
121
121
|
}) : void 0,
|
|
122
|
-
getCookie: /* @__PURE__ */
|
|
123
|
-
setCookie: /* @__PURE__ */
|
|
124
|
-
redirect: /* @__PURE__ */
|
|
125
|
-
setResHeaders: /* @__PURE__ */
|
|
126
|
-
setResStatus: /* @__PURE__ */
|
|
127
|
-
delCookie: /* @__PURE__ */
|
|
122
|
+
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
123
|
+
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
124
|
+
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => _h3.sendRedirect.call(void 0, event, url), "redirect"),
|
|
125
|
+
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
126
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
127
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie")
|
|
128
128
|
};
|
|
129
|
-
const context = new (0,
|
|
129
|
+
const context = new (0, _chunkRZ7IXJYQjs.Context)(contextData);
|
|
130
130
|
_h3.setHeaders.call(void 0, event, http.headers || {});
|
|
131
131
|
return context.run({
|
|
132
132
|
globalGuards,
|
|
@@ -142,9 +142,9 @@ function bind(router, data, opts = {}) {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
_chunkGHFSIZUOjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
_chunkGHFSIZUOjs.__name.call(void 0, bind, "bind");
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
exports.bind = bind;
|
package/dist/server/h3/index.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-3IPYLGY2.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-UXD62LGG.mjs";
|
|
11
11
|
|
|
12
12
|
// src/server/h3/bind.ts
|
|
13
13
|
import { defineRequestMiddleware, deleteCookie, eventHandler, getCookie, getQuery, getRequestHeaders, getRouterParams, readBody, sendRedirect, setCookie, setHeaders, setResponseHeaders, setResponseStatus } from "h3";
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkRZ7IXJYQjs = require('../../chunk-RZ7IXJYQ.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
11
11
|
|
|
12
12
|
// src/server/hono/bind.ts
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hono");
|
|
|
16
16
|
function bind(router, data, opts = {}) {
|
|
17
17
|
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
|
-
const metaMap =
|
|
19
|
+
const metaMap = _chunkRZ7IXJYQjs.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
|
+
_chunkRZ7IXJYQjs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
plugins: [
|
|
28
28
|
...globalPlugins,
|
|
29
29
|
...parallelPlugins
|
|
@@ -33,25 +33,25 @@ function bind(router, data, opts = {}) {
|
|
|
33
33
|
});
|
|
34
34
|
registerRoute();
|
|
35
35
|
async function registerRoute() {
|
|
36
|
-
|
|
36
|
+
_chunkRZ7IXJYQjs.Context.usePlugin(globalPlugins, "hono").forEach((p) => router.use(p));
|
|
37
37
|
if (parallelRoute) {
|
|
38
|
-
router.post(parallelRoute, ...
|
|
38
|
+
router.post(parallelRoute, ..._chunkRZ7IXJYQjs.Context.usePlugin(parallelPlugins, "hono"), async (c) => {
|
|
39
39
|
const body = await c.req.json();
|
|
40
40
|
async function errorHandler(e) {
|
|
41
|
-
const error = await
|
|
41
|
+
const error = await _chunkRZ7IXJYQjs.Context.filterRecord.default(e);
|
|
42
42
|
c.status(error.status);
|
|
43
43
|
return c.json(error);
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
45
|
+
_chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkRZ7IXJYQjs.BadRequestException)("data format should be an array"));
|
|
47
47
|
try {
|
|
48
48
|
return Promise.all(body.map((item, i) => {
|
|
49
49
|
return new Promise(async (resolve) => {
|
|
50
50
|
const { tag, func } = item;
|
|
51
51
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
52
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
52
|
+
if (!metaMap.has(tag)) return resolve(await _chunkRZ7IXJYQjs.Context.filterRecord.default(new (0, _chunkRZ7IXJYQjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
53
53
|
const meta2 = metaMap.get(tag)[func];
|
|
54
|
-
if (!meta2) return resolve(await
|
|
54
|
+
if (!meta2) return resolve(await _chunkRZ7IXJYQjs.Context.filterRecord.default(new (0, _chunkRZ7IXJYQjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
55
55
|
const { data: { params } } = meta2;
|
|
56
56
|
const contextData = {
|
|
57
57
|
type: "hono",
|
|
@@ -63,17 +63,17 @@ function bind(router, data, opts = {}) {
|
|
|
63
63
|
tag,
|
|
64
64
|
func,
|
|
65
65
|
app: router,
|
|
66
|
-
...
|
|
67
|
-
getCookie: /* @__PURE__ */
|
|
68
|
-
delCookie: /* @__PURE__ */
|
|
69
|
-
setCookie: /* @__PURE__ */
|
|
70
|
-
redirect: /* @__PURE__ */
|
|
71
|
-
setResHeaders: /* @__PURE__ */
|
|
66
|
+
..._chunkRZ7IXJYQjs.argToReq.call(void 0, params, item.args, c.req.header()),
|
|
67
|
+
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
68
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
69
|
+
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
70
|
+
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
71
|
+
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => {
|
|
72
72
|
for (const name in headers) c.header(name, headers[name]);
|
|
73
73
|
}, "setResHeaders"),
|
|
74
|
-
setResStatus: /* @__PURE__ */
|
|
74
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.status(status), "setResStatus")
|
|
75
75
|
};
|
|
76
|
-
const context = new (0,
|
|
76
|
+
const context = new (0, _chunkRZ7IXJYQjs.Context)(contextData);
|
|
77
77
|
context.run({
|
|
78
78
|
globalGuards,
|
|
79
79
|
globalInterceptors,
|
|
@@ -95,7 +95,7 @@ function bind(router, data, opts = {}) {
|
|
|
95
95
|
const { data: { params, plugins, http } } = meta2;
|
|
96
96
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
97
97
|
const needBody = params.some((item) => item.type === "body");
|
|
98
|
-
router[http.type](http.prefix + http.route, ...
|
|
98
|
+
router[http.type](http.prefix + http.route, ..._chunkRZ7IXJYQjs.Context.usePlugin(plugins, "hono"), async (c) => {
|
|
99
99
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
100
100
|
const contextData = {
|
|
101
101
|
type: "hono",
|
|
@@ -109,16 +109,16 @@ function bind(router, data, opts = {}) {
|
|
|
109
109
|
params: c.req.param(),
|
|
110
110
|
headers: c.req.header(),
|
|
111
111
|
app: router,
|
|
112
|
-
getCookie: /* @__PURE__ */
|
|
113
|
-
delCookie: /* @__PURE__ */
|
|
114
|
-
setCookie: /* @__PURE__ */
|
|
115
|
-
redirect: /* @__PURE__ */
|
|
116
|
-
setResHeaders: /* @__PURE__ */
|
|
112
|
+
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
113
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
114
|
+
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
115
|
+
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
116
|
+
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => {
|
|
117
117
|
for (const name in headers) c.header(name, headers[name]);
|
|
118
118
|
}, "setResHeaders"),
|
|
119
|
-
setResStatus: /* @__PURE__ */
|
|
119
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.status(status), "setResStatus")
|
|
120
120
|
};
|
|
121
|
-
const context = new (0,
|
|
121
|
+
const context = new (0, _chunkRZ7IXJYQjs.Context)(contextData);
|
|
122
122
|
if (http.headers) {
|
|
123
123
|
for (const name in http.headers) c.header(name, http.headers[name]);
|
|
124
124
|
}
|
|
@@ -139,9 +139,9 @@ function bind(router, data, opts = {}) {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
_chunkGHFSIZUOjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
_chunkGHFSIZUOjs.__name.call(void 0, bind, "bind");
|
|
145
145
|
|
|
146
146
|
|
|
147
147
|
exports.bind = bind;
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-3IPYLGY2.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-UXD62LGG.mjs";
|
|
11
11
|
|
|
12
12
|
// src/server/hono/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkRZ7IXJYQjs = require('../../chunk-RZ7IXJYQ.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
11
11
|
|
|
12
12
|
// src/server/hyper-express/bind.ts
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -15,14 +15,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hyper-express");
|
|
|
15
15
|
function bind(router, data, opts = {}) {
|
|
16
16
|
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
17
17
|
const { moduleMap, meta } = data;
|
|
18
|
-
const metaMap =
|
|
18
|
+
const metaMap = _chunkRZ7IXJYQjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
19
19
|
const { controller, http, func, tag } = meta2.data;
|
|
20
20
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
21
21
|
debug(`register method "${func}" in module "${tag}"`);
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
_chunkRZ7IXJYQjs.detectAopDep.call(void 0, meta, {
|
|
26
26
|
plugins: [
|
|
27
27
|
...globalPlugins,
|
|
28
28
|
...parallelPlugins
|
|
@@ -32,26 +32,26 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
async function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunkRZ7IXJYQjs.Context.usePlugin(globalPlugins, "hyper-express").forEach((p) => router.use(p));
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
router.post(parallelRoute, {
|
|
38
|
-
middlewares:
|
|
38
|
+
middlewares: _chunkRZ7IXJYQjs.Context.usePlugin(parallelPlugins, "hyper-express")
|
|
39
39
|
}, async (req, res, next) => {
|
|
40
40
|
const body = await req.json();
|
|
41
41
|
async function errorHandler(e) {
|
|
42
|
-
const error = await
|
|
42
|
+
const error = await _chunkRZ7IXJYQjs.Context.filterRecord.default(e);
|
|
43
43
|
return res.status(error.status).json(error);
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
45
|
+
_chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkRZ7IXJYQjs.BadRequestException)("data format should be an array"));
|
|
47
47
|
try {
|
|
48
48
|
return Promise.all(body.map((item, i) => {
|
|
49
49
|
return new Promise(async (resolve) => {
|
|
50
50
|
const { tag, func } = item;
|
|
51
51
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
52
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
52
|
+
if (!metaMap.has(tag)) return resolve(await _chunkRZ7IXJYQjs.Context.filterRecord.default(new (0, _chunkRZ7IXJYQjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
53
53
|
const meta2 = metaMap.get(tag)[func];
|
|
54
|
-
if (!meta2) return resolve(await
|
|
54
|
+
if (!meta2) return resolve(await _chunkRZ7IXJYQjs.Context.filterRecord.default(new (0, _chunkRZ7IXJYQjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
55
55
|
const { data: { params } } = meta2;
|
|
56
56
|
const contextData = {
|
|
57
57
|
type: "hyper-express",
|
|
@@ -65,15 +65,15 @@ function bind(router, data, opts = {}) {
|
|
|
65
65
|
func,
|
|
66
66
|
next,
|
|
67
67
|
app: router,
|
|
68
|
-
...
|
|
69
|
-
getCookie: /* @__PURE__ */
|
|
70
|
-
setCookie: /* @__PURE__ */
|
|
71
|
-
delCookie: /* @__PURE__ */
|
|
72
|
-
redirect: /* @__PURE__ */
|
|
73
|
-
setResHeaders: /* @__PURE__ */
|
|
74
|
-
setResStatus: /* @__PURE__ */
|
|
68
|
+
..._chunkRZ7IXJYQjs.argToReq.call(void 0, params, item.args, req.headers),
|
|
69
|
+
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
70
|
+
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _2 => _2.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
|
|
71
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
72
|
+
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
73
|
+
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
74
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
|
|
75
75
|
};
|
|
76
|
-
const context = new (0,
|
|
76
|
+
const context = new (0, _chunkRZ7IXJYQjs.Context)(contextData);
|
|
77
77
|
context.run({
|
|
78
78
|
globalGuards,
|
|
79
79
|
globalInterceptors,
|
|
@@ -95,7 +95,7 @@ function bind(router, data, opts = {}) {
|
|
|
95
95
|
const { data: { params, plugins, http } } = meta2;
|
|
96
96
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
|
|
97
97
|
const needBody = params.some((item) => item.type === "body");
|
|
98
|
-
router[http.type](http.prefix + http.route, ...
|
|
98
|
+
router[http.type](http.prefix + http.route, ..._chunkRZ7IXJYQjs.Context.usePlugin(plugins, "hyper-express"), async (req, res, next) => {
|
|
99
99
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
100
100
|
const contextData = {
|
|
101
101
|
type: "hyper-express",
|
|
@@ -111,14 +111,14 @@ function bind(router, data, opts = {}) {
|
|
|
111
111
|
params: req.path_parameters,
|
|
112
112
|
headers: req.headers,
|
|
113
113
|
next,
|
|
114
|
-
getCookie: /* @__PURE__ */
|
|
115
|
-
setCookie: /* @__PURE__ */
|
|
116
|
-
delCookie: /* @__PURE__ */
|
|
117
|
-
redirect: /* @__PURE__ */
|
|
118
|
-
setResHeaders: /* @__PURE__ */
|
|
119
|
-
setResStatus: /* @__PURE__ */
|
|
114
|
+
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
115
|
+
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _4 => _4.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
|
|
116
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
117
|
+
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
118
|
+
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
119
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
|
|
120
120
|
};
|
|
121
|
-
const context = new (0,
|
|
121
|
+
const context = new (0, _chunkRZ7IXJYQjs.Context)(contextData);
|
|
122
122
|
if (http.headers) {
|
|
123
123
|
for (const name in http.headers) res.set(name, http.headers[name]);
|
|
124
124
|
}
|
|
@@ -139,9 +139,9 @@ function bind(router, data, opts = {}) {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
_chunkGHFSIZUOjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
_chunkGHFSIZUOjs.__name.call(void 0, bind, "bind");
|
|
145
145
|
|
|
146
146
|
|
|
147
147
|
exports.bind = bind;
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-3IPYLGY2.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-UXD62LGG.mjs";
|
|
11
11
|
|
|
12
12
|
// src/server/hyper-express/bind.ts
|
|
13
13
|
import Debug from "debug";
|