phecda-server 8.1.0 → 8.2.0
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 +17 -2
- package/dist/{chunk-BLLRB5DQ.mjs → chunk-2P2UICBC.mjs} +2 -1
- package/dist/{chunk-UYZSUBX4.js → chunk-C424F7TV.js} +27 -27
- package/dist/{chunk-NQ55PA2X.mjs → chunk-JRNXLEAU.mjs} +2 -2
- package/dist/{chunk-FI5756JX.mjs → chunk-LYLSA56Y.mjs} +1 -1
- package/dist/{chunk-HKN3AAB2.js → chunk-MPKVT4SQ.js} +55 -54
- package/dist/{chunk-4LLLQOMF.js → chunk-OUQM7GZH.js} +2 -2
- package/dist/{chunk-OLNN4U3O.js → chunk-SRPCXPAQ.js} +20 -20
- package/dist/{chunk-PFPOEZHH.mjs → chunk-YDJAOLT2.mjs} +1 -1
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +40 -40
- package/dist/http/elysia/index.mjs +3 -3
- package/dist/http/express/index.js +37 -37
- package/dist/http/express/index.mjs +2 -2
- package/dist/http/fastify/index.js +38 -38
- package/dist/http/fastify/index.mjs +3 -3
- package/dist/http/h3/index.js +38 -38
- package/dist/http/h3/index.mjs +2 -2
- package/dist/http/hono/index.js +34 -34
- package/dist/http/hono/index.mjs +2 -2
- package/dist/http/hyper-express/index.js +35 -35
- package/dist/http/hyper-express/index.mjs +2 -2
- package/dist/http/koa/index.js +37 -37
- package/dist/http/koa/index.mjs +2 -2
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +46 -44
- package/dist/index.mjs +6 -4
- package/dist/rpc/bullmq/index.js +11 -11
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/electron/index.js +8 -8
- package/dist/rpc/electron/index.mjs +2 -2
- package/dist/rpc/kafka/index.js +10 -10
- 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 +12 -12
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.js +10 -10
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/rpc/ws/index.js +7 -7
- package/dist/rpc/ws/index.mjs +2 -2
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/package.json +31 -31
- package/register/utils.mjs +1 -10
- package/register/export.mjs +0 -39
|
@@ -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 _chunkC424F7TVjs = require('../../chunk-C424F7TV.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkMPKVT4SQjs = require('../../chunk-MPKVT4SQ.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkOUQM7GZHjs = require('../../chunk-OUQM7GZH.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 = _chunkMPKVT4SQjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
22
|
const { controller, http, method, tag } = meta2.data;
|
|
23
23
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _2 => _2.method])) {
|
|
24
24
|
debug(`register method "${method}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunkMPKVT4SQjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -33,28 +33,28 @@ function bind(fastify, data, opts = {}) {
|
|
|
33
33
|
guards: globalGuards
|
|
34
34
|
});
|
|
35
35
|
fastify.register(async (fastify2, _, done) => {
|
|
36
|
-
|
|
36
|
+
_chunkMPKVT4SQjs.Context.applyAddons(globalAddons, fastify2, "fastify");
|
|
37
37
|
if (parallelRoute) {
|
|
38
38
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
39
|
-
|
|
39
|
+
_chunkMPKVT4SQjs.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 _chunkMPKVT4SQjs.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
|
+
_chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkMPKVT4SQjs.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
|
if (!item) return resolve(null);
|
|
52
52
|
const { tag, method } = item;
|
|
53
53
|
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
54
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
54
|
+
if (!metaMap.has(tag)) return resolve(await _chunkMPKVT4SQjs.Context.filterRecord.default(new (0, _chunkMPKVT4SQjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
55
55
|
const meta2 = metaMap.get(tag)[method];
|
|
56
|
-
if (!meta2) return resolve(await
|
|
57
|
-
const aop =
|
|
56
|
+
if (!meta2) return resolve(await _chunkMPKVT4SQjs.Context.filterRecord.default(new (0, _chunkMPKVT4SQjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
57
|
+
const aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
58
58
|
globalFilter,
|
|
59
59
|
globalGuards,
|
|
60
60
|
globalPipe
|
|
@@ -71,18 +71,18 @@ function bind(fastify, data, opts = {}) {
|
|
|
71
71
|
app: fastify3,
|
|
72
72
|
...item,
|
|
73
73
|
// @ts-expect-error need @fastify/cookie
|
|
74
|
-
getCookie: /* @__PURE__ */
|
|
74
|
+
getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
75
75
|
// @ts-expect-error need @fastify/cookie
|
|
76
|
-
setCookie: /* @__PURE__ */
|
|
76
|
+
setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
77
77
|
// @ts-expect-error need @fastify/cookie
|
|
78
|
-
delCookie: /* @__PURE__ */
|
|
79
|
-
redirect: /* @__PURE__ */
|
|
80
|
-
setResHeaders: /* @__PURE__ */
|
|
81
|
-
setResStatus: /* @__PURE__ */
|
|
82
|
-
getRequest: /* @__PURE__ */
|
|
83
|
-
getResponse: /* @__PURE__ */
|
|
78
|
+
delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
79
|
+
redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
80
|
+
setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
81
|
+
setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
82
|
+
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => req.raw, "getRequest"),
|
|
83
|
+
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => res.raw, "getResponse")
|
|
84
84
|
};
|
|
85
|
-
const context = new (0,
|
|
85
|
+
const context = new (0, _chunkMPKVT4SQjs.Context)(contextData);
|
|
86
86
|
context.run(aop, resolve, resolve);
|
|
87
87
|
});
|
|
88
88
|
})).then((ret) => {
|
|
@@ -101,16 +101,16 @@ function bind(fastify, data, opts = {}) {
|
|
|
101
101
|
const { data: { addons, define, http } } = meta2;
|
|
102
102
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.method])) continue;
|
|
103
103
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
104
|
-
|
|
104
|
+
_chunkMPKVT4SQjs.Context.applyAddons(addons, fastify3, "fastify");
|
|
105
105
|
let aop;
|
|
106
106
|
if (!dynamic) {
|
|
107
|
-
aop =
|
|
107
|
+
aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
108
108
|
globalFilter,
|
|
109
109
|
globalGuards,
|
|
110
110
|
globalPipe
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
fastify3[http.method](
|
|
113
|
+
fastify3[http.method](_chunkMPKVT4SQjs.joinUrl.call(void 0, http.prefix, http.route), _optionalChain([define, 'optionalAccess', _4 => _4.fastify]) || {}, async (req, res) => {
|
|
114
114
|
debug(`invoke method "${method}" in module "${tag}"`);
|
|
115
115
|
const contextData = {
|
|
116
116
|
type: "fastify",
|
|
@@ -127,23 +127,23 @@ 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__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
131
131
|
// @ts-expect-error need @fastify/cookie
|
|
132
|
-
setCookie: /* @__PURE__ */
|
|
132
|
+
setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__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__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => res.clearCookie(key, {
|
|
135
135
|
url: ""
|
|
136
136
|
}), "delCookie"),
|
|
137
|
-
redirect: /* @__PURE__ */
|
|
138
|
-
setResHeaders: /* @__PURE__ */
|
|
139
|
-
setResStatus: /* @__PURE__ */
|
|
140
|
-
getRequest: /* @__PURE__ */
|
|
141
|
-
getResponse: /* @__PURE__ */
|
|
137
|
+
redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
138
|
+
setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
139
|
+
setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
140
|
+
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => req.raw, "getRequest"),
|
|
141
|
+
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => res.raw, "getResponse")
|
|
142
142
|
};
|
|
143
|
-
const context = new (0,
|
|
143
|
+
const context = new (0, _chunkMPKVT4SQjs.Context)(contextData);
|
|
144
144
|
if (http.headers) res.headers(http.headers);
|
|
145
145
|
if (dynamic) {
|
|
146
|
-
aop =
|
|
146
|
+
aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
147
147
|
globalFilter,
|
|
148
148
|
globalGuards,
|
|
149
149
|
globalPipe
|
|
@@ -164,11 +164,11 @@ function bind(fastify, data, opts = {}) {
|
|
|
164
164
|
done();
|
|
165
165
|
}, fastifyOpts);
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
_chunkOUQM7GZHjs.__name.call(void 0, bind, "bind");
|
|
168
168
|
function Fastify(opts) {
|
|
169
|
-
return
|
|
169
|
+
return _chunkC424F7TVjs.Define.call(void 0, "fastify", opts);
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
_chunkOUQM7GZHjs.__name.call(void 0, Fastify, "Fastify");
|
|
172
172
|
|
|
173
173
|
|
|
174
174
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-LYLSA56Y.mjs";
|
|
4
4
|
import {
|
|
5
5
|
BadRequestException,
|
|
6
6
|
Context,
|
|
7
7
|
createControllerMetaMap,
|
|
8
8
|
detectAopDep,
|
|
9
9
|
joinUrl
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-2P2UICBC.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-JRNXLEAU.mjs";
|
|
14
14
|
|
|
15
15
|
// src/http/fastify/bind.ts
|
|
16
16
|
import Debug from "debug";
|
package/dist/http/h3/index.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkMPKVT4SQjs = require('../../chunk-MPKVT4SQ.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkOUQM7GZHjs = require('../../chunk-OUQM7GZH.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 = _chunkMPKVT4SQjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
20
20
|
const { controller, http, method, tag } = meta2.data;
|
|
21
21
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
22
22
|
debug(`register method "${method}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
_chunkMPKVT4SQjs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
addons: [
|
|
28
28
|
...globalAddons,
|
|
29
29
|
...parallelAddons
|
|
@@ -32,32 +32,32 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunkMPKVT4SQjs.Context.applyAddons(globalAddons, router, "h3");
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
38
|
-
|
|
38
|
+
_chunkMPKVT4SQjs.Context.applyAddons(parallelAddons, subRouter, "h3");
|
|
39
39
|
subRouter.post(parallelRoute, _h3.eventHandler.call(void 0, {
|
|
40
|
-
handler: /* @__PURE__ */
|
|
40
|
+
handler: /* @__PURE__ */ _chunkOUQM7GZHjs.__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 _chunkMPKVT4SQjs.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
|
+
_chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkMPKVT4SQjs.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
|
if (!item) return resolve(null);
|
|
55
55
|
const { tag, method } = item;
|
|
56
56
|
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
57
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
57
|
+
if (!metaMap.has(tag)) return resolve(await _chunkMPKVT4SQjs.Context.filterRecord.default(new (0, _chunkMPKVT4SQjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
58
58
|
const meta2 = metaMap.get(tag)[method];
|
|
59
|
-
if (!meta2) return resolve(await
|
|
60
|
-
const aop =
|
|
59
|
+
if (!meta2) return resolve(await _chunkMPKVT4SQjs.Context.filterRecord.default(new (0, _chunkMPKVT4SQjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
60
|
+
const aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
61
61
|
globalFilter,
|
|
62
62
|
globalGuards,
|
|
63
63
|
globalPipe
|
|
@@ -72,16 +72,16 @@ function bind(router, data, opts = {}) {
|
|
|
72
72
|
parallel: true,
|
|
73
73
|
app: router,
|
|
74
74
|
...item,
|
|
75
|
-
getCookie: /* @__PURE__ */
|
|
76
|
-
setCookie: /* @__PURE__ */
|
|
77
|
-
delCookie: /* @__PURE__ */
|
|
78
|
-
redirect: /* @__PURE__ */
|
|
79
|
-
setResHeaders: /* @__PURE__ */
|
|
80
|
-
setResStatus: /* @__PURE__ */
|
|
81
|
-
getRequest: /* @__PURE__ */
|
|
82
|
-
getResponse: /* @__PURE__ */
|
|
75
|
+
getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
76
|
+
setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
77
|
+
delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
78
|
+
redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url, status) => _h3.sendRedirect.call(void 0, event, url, status), "redirect"),
|
|
79
|
+
setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
80
|
+
setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
81
|
+
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
82
|
+
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
83
83
|
};
|
|
84
|
-
const context = new (0,
|
|
84
|
+
const context = new (0, _chunkMPKVT4SQjs.Context)(contextData);
|
|
85
85
|
context.run(aop, resolve, resolve);
|
|
86
86
|
});
|
|
87
87
|
}));
|
|
@@ -100,15 +100,15 @@ function bind(router, data, opts = {}) {
|
|
|
100
100
|
const needBody = params.some((item) => item.type === "body");
|
|
101
101
|
let aop;
|
|
102
102
|
if (!dynamic) {
|
|
103
|
-
aop =
|
|
103
|
+
aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
104
104
|
globalFilter,
|
|
105
105
|
globalGuards,
|
|
106
106
|
globalPipe
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
110
|
-
|
|
111
|
-
subRouter[http.method](
|
|
110
|
+
_chunkMPKVT4SQjs.Context.applyAddons(addons, subRouter, "h3");
|
|
111
|
+
subRouter[http.method](_chunkMPKVT4SQjs.joinUrl.call(void 0, http.prefix, http.route), _h3.defineEventHandler.call(void 0, async (event) => {
|
|
112
112
|
debug(`invoke method "${method}" in module "${tag}"`);
|
|
113
113
|
const contextData = {
|
|
114
114
|
type: "h3",
|
|
@@ -125,19 +125,19 @@ function bind(router, data, opts = {}) {
|
|
|
125
125
|
body: needBody ? await _h3.readBody.call(void 0, event, {
|
|
126
126
|
strict: true
|
|
127
127
|
}) : 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__ */
|
|
128
|
+
getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
129
|
+
setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
130
|
+
redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url) => _h3.sendRedirect.call(void 0, event, url), "redirect"),
|
|
131
|
+
setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
132
|
+
setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
133
|
+
delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
134
|
+
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
135
|
+
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
136
136
|
};
|
|
137
|
-
const context = new (0,
|
|
137
|
+
const context = new (0, _chunkMPKVT4SQjs.Context)(contextData);
|
|
138
138
|
_h3.setHeaders.call(void 0, event, http.headers || {});
|
|
139
139
|
if (dynamic) {
|
|
140
|
-
aop =
|
|
140
|
+
aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
141
141
|
globalFilter,
|
|
142
142
|
globalGuards,
|
|
143
143
|
globalPipe
|
|
@@ -148,13 +148,13 @@ function bind(router, data, opts = {}) {
|
|
|
148
148
|
return err;
|
|
149
149
|
});
|
|
150
150
|
}));
|
|
151
|
-
router.use(
|
|
151
|
+
router.use(_chunkMPKVT4SQjs.joinUrl.call(void 0, http.prefix, http.route), _h3.useBase.call(void 0, "", subRouter.handler));
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
_chunkOUQM7GZHjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
_chunkOUQM7GZHjs.__name.call(void 0, bind, "bind");
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
exports.bind = bind;
|
package/dist/http/h3/index.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
joinUrl
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-2P2UICBC.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-JRNXLEAU.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";
|
package/dist/http/hono/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkMPKVT4SQjs = require('../../chunk-MPKVT4SQ.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkOUQM7GZHjs = require('../../chunk-OUQM7GZH.js');
|
|
10
10
|
|
|
11
11
|
// src/http/hono/bind.ts
|
|
12
12
|
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, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
|
-
const metaMap =
|
|
19
|
+
const metaMap = _chunkMPKVT4SQjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
20
20
|
const { controller, http, method, tag } = meta2.data;
|
|
21
21
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
22
22
|
debug(`register method "${method}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
_chunkMPKVT4SQjs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
addons: [
|
|
28
28
|
...globalAddons,
|
|
29
29
|
...parallelAddons
|
|
@@ -34,26 +34,26 @@ function bind(router, data, opts = {}) {
|
|
|
34
34
|
function registerRoute() {
|
|
35
35
|
if (parallelRoute) {
|
|
36
36
|
const subApp = new (0, _hono.Hono)();
|
|
37
|
-
|
|
37
|
+
_chunkMPKVT4SQjs.Context.applyAddons(parallelAddons, subApp, "hono");
|
|
38
38
|
subApp.post("", async (c) => {
|
|
39
39
|
const body = await c.req.json();
|
|
40
40
|
async function errorHandler(e) {
|
|
41
|
-
const error = await
|
|
41
|
+
const error = await _chunkMPKVT4SQjs.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
|
+
_chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkMPKVT4SQjs.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
|
if (!item) return resolve(null);
|
|
51
51
|
const { tag, method } = item;
|
|
52
52
|
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
53
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
53
|
+
if (!metaMap.has(tag)) return resolve(await _chunkMPKVT4SQjs.Context.filterRecord.default(new (0, _chunkMPKVT4SQjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
54
54
|
const meta2 = metaMap.get(tag)[method];
|
|
55
|
-
if (!meta2) return resolve(await
|
|
56
|
-
const aop =
|
|
55
|
+
if (!meta2) return resolve(await _chunkMPKVT4SQjs.Context.filterRecord.default(new (0, _chunkMPKVT4SQjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
56
|
+
const aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
57
57
|
globalFilter,
|
|
58
58
|
globalGuards,
|
|
59
59
|
globalPipe
|
|
@@ -68,18 +68,18 @@ function bind(router, data, opts = {}) {
|
|
|
68
68
|
moduleMap,
|
|
69
69
|
app: router,
|
|
70
70
|
...item,
|
|
71
|
-
getCookie: /* @__PURE__ */
|
|
72
|
-
delCookie: /* @__PURE__ */
|
|
73
|
-
setCookie: /* @__PURE__ */
|
|
74
|
-
redirect: /* @__PURE__ */
|
|
75
|
-
setResHeaders: /* @__PURE__ */
|
|
71
|
+
getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
72
|
+
delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
73
|
+
setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
74
|
+
redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
75
|
+
setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => {
|
|
76
76
|
for (const name in headers) c.header(name, headers[name]);
|
|
77
77
|
}, "setResHeaders"),
|
|
78
|
-
setResStatus: /* @__PURE__ */
|
|
79
|
-
getRequest: /* @__PURE__ */
|
|
80
|
-
getResponse: /* @__PURE__ */
|
|
78
|
+
setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
79
|
+
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
80
|
+
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => c.res, "getResponse")
|
|
81
81
|
};
|
|
82
|
-
const context = new (0,
|
|
82
|
+
const context = new (0, _chunkMPKVT4SQjs.Context)(contextData);
|
|
83
83
|
context.run(aop, resolve, resolve);
|
|
84
84
|
});
|
|
85
85
|
})).then((ret) => {
|
|
@@ -99,14 +99,14 @@ function bind(router, data, opts = {}) {
|
|
|
99
99
|
const needBody = params.some((item) => item.type === "body");
|
|
100
100
|
let aop;
|
|
101
101
|
if (!dynamic) {
|
|
102
|
-
aop =
|
|
102
|
+
aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
103
103
|
globalFilter,
|
|
104
104
|
globalGuards,
|
|
105
105
|
globalPipe
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
const subApp = new (0, _hono.Hono)();
|
|
109
|
-
|
|
109
|
+
_chunkMPKVT4SQjs.Context.applyAddons(addons, subApp, "hono");
|
|
110
110
|
subApp[http.method](http.route, async (c) => {
|
|
111
111
|
debug(`invoke method "${method}" in module "${tag}"`);
|
|
112
112
|
const contextData = {
|
|
@@ -122,23 +122,23 @@ function bind(router, data, opts = {}) {
|
|
|
122
122
|
params: c.req.param(),
|
|
123
123
|
headers: c.req.header(),
|
|
124
124
|
app: router,
|
|
125
|
-
getCookie: /* @__PURE__ */
|
|
126
|
-
delCookie: /* @__PURE__ */
|
|
127
|
-
setCookie: /* @__PURE__ */
|
|
128
|
-
redirect: /* @__PURE__ */
|
|
129
|
-
setResHeaders: /* @__PURE__ */
|
|
125
|
+
getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
126
|
+
delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
127
|
+
setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
128
|
+
redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
129
|
+
setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => {
|
|
130
130
|
for (const name in headers) c.header(name, headers[name]);
|
|
131
131
|
}, "setResHeaders"),
|
|
132
|
-
setResStatus: /* @__PURE__ */
|
|
133
|
-
getRequest: /* @__PURE__ */
|
|
134
|
-
getResponse: /* @__PURE__ */
|
|
132
|
+
setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
133
|
+
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
134
|
+
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => c.res, "getResponse")
|
|
135
135
|
};
|
|
136
|
-
const context = new (0,
|
|
136
|
+
const context = new (0, _chunkMPKVT4SQjs.Context)(contextData);
|
|
137
137
|
if (http.headers) {
|
|
138
138
|
for (const name in http.headers) c.header(name, http.headers[name]);
|
|
139
139
|
}
|
|
140
140
|
if (dynamic) {
|
|
141
|
-
aop =
|
|
141
|
+
aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
142
142
|
globalFilter,
|
|
143
143
|
globalGuards,
|
|
144
144
|
globalPipe
|
|
@@ -157,9 +157,9 @@ function bind(router, data, opts = {}) {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
_chunkOUQM7GZHjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
_chunkOUQM7GZHjs.__name.call(void 0, bind, "bind");
|
|
163
163
|
|
|
164
164
|
|
|
165
165
|
exports.bind = bind;
|
package/dist/http/hono/index.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
Context,
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-2P2UICBC.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-JRNXLEAU.mjs";
|
|
10
10
|
|
|
11
11
|
// src/http/hono/bind.ts
|
|
12
12
|
import Debug from "debug";
|