phecda-server 7.0.0-alpha.1 → 7.0.0-alpha.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/assets/ps.json +1 -1
- package/bin/cli.mjs +8 -7
- package/dist/{chunk-GSPBHZBH.js → chunk-6EBEME3I.js} +52 -52
- package/dist/{chunk-XYVMNY2X.mjs → chunk-A53KNKY4.mjs} +1 -1
- package/dist/{chunk-HMVLXNV3.mjs → chunk-KUGFI6SC.mjs} +1 -1
- package/dist/{chunk-V7EI76QQ.mjs → chunk-MMG73S64.mjs} +2 -2
- package/dist/{chunk-7YQ57BQS.js → chunk-PKSWGQLW.js} +18 -18
- package/dist/{chunk-MBCHNDAY.js → chunk-QCOBXM7F.js} +24 -24
- package/dist/{chunk-WHJ5FALK.mjs → chunk-QD3QR3NW.mjs} +3 -3
- package/dist/{chunk-J5CFUN4V.js → chunk-RQSQRZL4.js} +3 -3
- package/dist/{core-CYwEPfN4.d.ts → core-C1kHRqU9.d.ts} +1 -1
- package/dist/{core-BIcUwV18.d.mts → core-CSiaRU7r.d.mts} +1 -1
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +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 +42 -40
- package/dist/http/elysia/index.mjs +5 -3
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +39 -37
- package/dist/http/express/index.mjs +4 -2
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +40 -38
- package/dist/http/fastify/index.mjs +5 -3
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +39 -37
- package/dist/http/h3/index.mjs +4 -2
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +37 -35
- package/dist/http/hono/index.mjs +4 -2
- package/dist/http/hyper-express/index.d.mts +3 -3
- package/dist/http/hyper-express/index.d.ts +3 -3
- package/dist/http/hyper-express/index.js +37 -35
- package/dist/http/hyper-express/index.mjs +4 -2
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +39 -37
- package/dist/http/koa/index.mjs +4 -2
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +39 -39
- package/dist/index.mjs +5 -5
- package/dist/{meta-BXKLFTgG.d.mts → meta-D1M85Hef.d.mts} +1 -0
- package/dist/{meta-BXKLFTgG.d.ts → meta-D1M85Hef.d.ts} +1 -0
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +15 -14
- package/dist/rpc/bullmq/index.mjs +3 -2
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +15 -14
- package/dist/rpc/kafka/index.mjs +3 -2
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +14 -13
- package/dist/rpc/nats/index.mjs +3 -2
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +16 -15
- package/dist/rpc/rabbitmq/index.mjs +3 -2
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +14 -13
- package/dist/rpc/redis/index.mjs +3 -2
- package/dist/test.d.mts +2 -2
- package/dist/test.d.ts +2 -2
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types-BtbL49Zs.d.mts → types-C9Remkup.d.ts} +2 -1
- package/dist/{types-m3IEDKjP.d.ts → types-JMhFVp-Z.d.mts} +2 -1
- package/dist/{types-h40T3cRG.d.mts → types-ee1FBodH.d.ts} +2 -1
- package/dist/{types-VFzEM7LL.d.ts → types-wbHHC93P.d.mts} +2 -1
- package/package.json +1 -1
- package/register/loader.mjs +2 -2
package/dist/http/h3/index.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk6EBEME3Ijs = require('../../chunk-6EBEME3I.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkRQSQRZL4js = require('../../chunk-RQSQRZL4.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 = _chunk6EBEME3Ijs.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
|
+
_chunk6EBEME3Ijs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
addons: [
|
|
28
28
|
...globalAddons,
|
|
29
29
|
...parallelAddons
|
|
@@ -32,38 +32,39 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunk6EBEME3Ijs.Context.applyAddons(globalAddons, router, "h3");
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
38
|
-
|
|
38
|
+
_chunk6EBEME3Ijs.Context.applyAddons(parallelAddons, subRouter, "h3");
|
|
39
39
|
subRouter.post(parallelRoute, _h3.eventHandler.call(void 0, {
|
|
40
|
-
handler: /* @__PURE__ */
|
|
40
|
+
handler: /* @__PURE__ */ _chunkRQSQRZL4js.__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 _chunk6EBEME3Ijs.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
|
+
_chunkRQSQRZL4js.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk6EBEME3Ijs.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 _chunk6EBEME3Ijs.Context.filterRecord.default(new (0, _chunk6EBEME3Ijs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
57
57
|
const meta2 = metaMap.get(tag)[func];
|
|
58
|
-
if (!meta2) return resolve(await
|
|
58
|
+
if (!meta2) return resolve(await _chunk6EBEME3Ijs.Context.filterRecord.default(new (0, _chunk6EBEME3Ijs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
59
|
const { data: { params } } = meta2;
|
|
60
|
-
const aop =
|
|
60
|
+
const aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
61
61
|
globalFilter,
|
|
62
62
|
globalGuards,
|
|
63
63
|
globalPipe
|
|
64
64
|
});
|
|
65
65
|
const contextData = {
|
|
66
66
|
type: "h3",
|
|
67
|
+
category: "http",
|
|
67
68
|
index: i,
|
|
68
69
|
event,
|
|
69
70
|
meta: meta2,
|
|
@@ -72,17 +73,17 @@ function bind(router, data, opts = {}) {
|
|
|
72
73
|
func,
|
|
73
74
|
parallel: true,
|
|
74
75
|
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__ */
|
|
76
|
+
..._chunk6EBEME3Ijs.argToReq.call(void 0, params, item.args, _h3.getRequestHeaders.call(void 0, event)),
|
|
77
|
+
getCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
78
|
+
setCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
79
|
+
delCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
80
|
+
redirect: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (url, status) => _h3.sendRedirect.call(void 0, event, url, status), "redirect"),
|
|
81
|
+
setResHeaders: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
82
|
+
setResStatus: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
83
|
+
getRequest: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
84
|
+
getResponse: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => event.node.res, "getResponse")
|
|
84
85
|
};
|
|
85
|
-
const context = new (0,
|
|
86
|
+
const context = new (0, _chunk6EBEME3Ijs.Context)(contextData);
|
|
86
87
|
context.run(aop, resolve, resolve);
|
|
87
88
|
});
|
|
88
89
|
}));
|
|
@@ -101,18 +102,19 @@ function bind(router, data, opts = {}) {
|
|
|
101
102
|
const needBody = params.some((item) => item.type === "body");
|
|
102
103
|
let aop;
|
|
103
104
|
if (!dynamic) {
|
|
104
|
-
aop =
|
|
105
|
+
aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
105
106
|
globalFilter,
|
|
106
107
|
globalGuards,
|
|
107
108
|
globalPipe
|
|
108
109
|
});
|
|
109
110
|
}
|
|
110
111
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
111
|
-
|
|
112
|
+
_chunk6EBEME3Ijs.Context.applyAddons(addons, subRouter, "h3");
|
|
112
113
|
subRouter[http.type](http.prefix + http.route, _h3.defineEventHandler.call(void 0, async (event) => {
|
|
113
114
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
114
115
|
const contextData = {
|
|
115
116
|
type: "h3",
|
|
117
|
+
category: "http",
|
|
116
118
|
meta: meta2,
|
|
117
119
|
event,
|
|
118
120
|
moduleMap,
|
|
@@ -125,19 +127,19 @@ function bind(router, data, opts = {}) {
|
|
|
125
127
|
body: needBody ? await _h3.readBody.call(void 0, event, {
|
|
126
128
|
strict: true
|
|
127
129
|
}) : 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__ */
|
|
130
|
+
getCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
131
|
+
setCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
132
|
+
redirect: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (url) => _h3.sendRedirect.call(void 0, event, url), "redirect"),
|
|
133
|
+
setResHeaders: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
134
|
+
setResStatus: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
135
|
+
delCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
136
|
+
getRequest: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
137
|
+
getResponse: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => event.node.res, "getResponse")
|
|
136
138
|
};
|
|
137
|
-
const context = new (0,
|
|
139
|
+
const context = new (0, _chunk6EBEME3Ijs.Context)(contextData);
|
|
138
140
|
_h3.setHeaders.call(void 0, event, http.headers || {});
|
|
139
141
|
if (dynamic) {
|
|
140
|
-
aop =
|
|
142
|
+
aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
141
143
|
globalFilter,
|
|
142
144
|
globalGuards,
|
|
143
145
|
globalPipe
|
|
@@ -152,9 +154,9 @@ function bind(router, data, opts = {}) {
|
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
|
-
|
|
157
|
+
_chunkRQSQRZL4js.__name.call(void 0, registerRoute, "registerRoute");
|
|
156
158
|
}
|
|
157
|
-
|
|
159
|
+
_chunkRQSQRZL4js.__name.call(void 0, bind, "bind");
|
|
158
160
|
|
|
159
161
|
|
|
160
162
|
exports.bind = bind;
|
package/dist/http/h3/index.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-MMG73S64.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-QD3QR3NW.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";
|
|
@@ -64,6 +64,7 @@ function bind(router, data, opts = {}) {
|
|
|
64
64
|
});
|
|
65
65
|
const contextData = {
|
|
66
66
|
type: "h3",
|
|
67
|
+
category: "http",
|
|
67
68
|
index: i,
|
|
68
69
|
event,
|
|
69
70
|
meta: meta2,
|
|
@@ -113,6 +114,7 @@ function bind(router, data, opts = {}) {
|
|
|
113
114
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
114
115
|
const contextData = {
|
|
115
116
|
type: "h3",
|
|
117
|
+
category: "http",
|
|
116
118
|
meta: meta2,
|
|
117
119
|
event,
|
|
118
120
|
moduleMap,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context, Hono, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-wbHHC93P.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-CSiaRU7r.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-D1M85Hef.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HonoCtx extends HttpContext {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context, Hono, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-ee1FBodH.js';
|
|
3
|
+
import { F as Factory } from '../../core-C1kHRqU9.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-D1M85Hef.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HonoCtx extends HttpContext {
|
package/dist/http/hono/index.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk6EBEME3Ijs = require('../../chunk-6EBEME3I.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkRQSQRZL4js = require('../../chunk-RQSQRZL4.js');
|
|
11
11
|
|
|
12
12
|
// src/http/hono/bind.ts
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -17,14 +17,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hono");
|
|
|
17
17
|
function bind(router, data, opts = {}) {
|
|
18
18
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
19
19
|
const { moduleMap, meta } = data;
|
|
20
|
-
const metaMap =
|
|
20
|
+
const metaMap = _chunk6EBEME3Ijs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
21
21
|
const { controller, http, func, tag } = meta2.data;
|
|
22
22
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
23
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
_chunk6EBEME3Ijs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
addons: [
|
|
29
29
|
...globalAddons,
|
|
30
30
|
...parallelAddons
|
|
@@ -35,26 +35,26 @@ function bind(router, data, opts = {}) {
|
|
|
35
35
|
function registerRoute() {
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
const subApp = new (0, _hono.Hono)();
|
|
38
|
-
|
|
38
|
+
_chunk6EBEME3Ijs.Context.applyAddons(parallelAddons, subApp, "hono");
|
|
39
39
|
subApp.post("", async (c) => {
|
|
40
40
|
const body = await c.req.json();
|
|
41
41
|
async function errorHandler(e) {
|
|
42
|
-
const error = await
|
|
42
|
+
const error = await _chunk6EBEME3Ijs.Context.filterRecord.default(e);
|
|
43
43
|
c.status(error.status);
|
|
44
44
|
return c.json(error);
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
46
|
+
_chunkRQSQRZL4js.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk6EBEME3Ijs.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 _chunk6EBEME3Ijs.Context.filterRecord.default(new (0, _chunk6EBEME3Ijs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
54
54
|
const meta2 = metaMap.get(tag)[func];
|
|
55
|
-
if (!meta2) return resolve(await
|
|
55
|
+
if (!meta2) return resolve(await _chunk6EBEME3Ijs.Context.filterRecord.default(new (0, _chunk6EBEME3Ijs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
56
56
|
const { data: { params } } = meta2;
|
|
57
|
-
const aop =
|
|
57
|
+
const aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
58
58
|
globalFilter,
|
|
59
59
|
globalGuards,
|
|
60
60
|
globalPipe
|
|
@@ -62,6 +62,7 @@ function bind(router, data, opts = {}) {
|
|
|
62
62
|
const contextData = {
|
|
63
63
|
type: "hono",
|
|
64
64
|
parallel: true,
|
|
65
|
+
category: "http",
|
|
65
66
|
context: c,
|
|
66
67
|
index: i,
|
|
67
68
|
meta: meta2,
|
|
@@ -69,19 +70,19 @@ function bind(router, data, opts = {}) {
|
|
|
69
70
|
tag,
|
|
70
71
|
func,
|
|
71
72
|
app: router,
|
|
72
|
-
...
|
|
73
|
-
getCookie: /* @__PURE__ */
|
|
74
|
-
delCookie: /* @__PURE__ */
|
|
75
|
-
setCookie: /* @__PURE__ */
|
|
76
|
-
redirect: /* @__PURE__ */
|
|
77
|
-
setResHeaders: /* @__PURE__ */
|
|
73
|
+
..._chunk6EBEME3Ijs.argToReq.call(void 0, params, item.args, c.req.header()),
|
|
74
|
+
getCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
75
|
+
delCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
76
|
+
setCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
77
|
+
redirect: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
78
|
+
setResHeaders: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (headers) => {
|
|
78
79
|
for (const name in headers) c.header(name, headers[name]);
|
|
79
80
|
}, "setResHeaders"),
|
|
80
|
-
setResStatus: /* @__PURE__ */
|
|
81
|
-
getRequest: /* @__PURE__ */
|
|
82
|
-
getResponse: /* @__PURE__ */
|
|
81
|
+
setResStatus: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
82
|
+
getRequest: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
83
|
+
getResponse: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => c.res, "getResponse")
|
|
83
84
|
};
|
|
84
|
-
const context = new (0,
|
|
85
|
+
const context = new (0, _chunk6EBEME3Ijs.Context)(contextData);
|
|
85
86
|
context.run(aop, resolve, resolve);
|
|
86
87
|
});
|
|
87
88
|
})).then((ret) => {
|
|
@@ -101,18 +102,19 @@ function bind(router, data, opts = {}) {
|
|
|
101
102
|
const needBody = params.some((item) => item.type === "body");
|
|
102
103
|
let aop;
|
|
103
104
|
if (!dynamic) {
|
|
104
|
-
aop =
|
|
105
|
+
aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
105
106
|
globalFilter,
|
|
106
107
|
globalGuards,
|
|
107
108
|
globalPipe
|
|
108
109
|
});
|
|
109
110
|
}
|
|
110
111
|
const subApp = new (0, _hono.Hono)();
|
|
111
|
-
|
|
112
|
+
_chunk6EBEME3Ijs.Context.applyAddons(addons, subApp, "hono");
|
|
112
113
|
subApp[http.type](http.route, async (c) => {
|
|
113
114
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
114
115
|
const contextData = {
|
|
115
116
|
type: "hono",
|
|
117
|
+
category: "http",
|
|
116
118
|
context: c,
|
|
117
119
|
meta: meta2,
|
|
118
120
|
moduleMap,
|
|
@@ -123,23 +125,23 @@ function bind(router, data, opts = {}) {
|
|
|
123
125
|
params: c.req.param(),
|
|
124
126
|
headers: c.req.header(),
|
|
125
127
|
app: router,
|
|
126
|
-
getCookie: /* @__PURE__ */
|
|
127
|
-
delCookie: /* @__PURE__ */
|
|
128
|
-
setCookie: /* @__PURE__ */
|
|
129
|
-
redirect: /* @__PURE__ */
|
|
130
|
-
setResHeaders: /* @__PURE__ */
|
|
128
|
+
getCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
129
|
+
delCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
130
|
+
setCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
131
|
+
redirect: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
132
|
+
setResHeaders: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (headers) => {
|
|
131
133
|
for (const name in headers) c.header(name, headers[name]);
|
|
132
134
|
}, "setResHeaders"),
|
|
133
|
-
setResStatus: /* @__PURE__ */
|
|
134
|
-
getRequest: /* @__PURE__ */
|
|
135
|
-
getResponse: /* @__PURE__ */
|
|
135
|
+
setResStatus: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
136
|
+
getRequest: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
137
|
+
getResponse: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => c.res, "getResponse")
|
|
136
138
|
};
|
|
137
|
-
const context = new (0,
|
|
139
|
+
const context = new (0, _chunk6EBEME3Ijs.Context)(contextData);
|
|
138
140
|
if (http.headers) {
|
|
139
141
|
for (const name in http.headers) c.header(name, http.headers[name]);
|
|
140
142
|
}
|
|
141
143
|
if (dynamic) {
|
|
142
|
-
aop =
|
|
144
|
+
aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
143
145
|
globalFilter,
|
|
144
146
|
globalGuards,
|
|
145
147
|
globalPipe
|
|
@@ -158,9 +160,9 @@ function bind(router, data, opts = {}) {
|
|
|
158
160
|
}
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
|
-
|
|
163
|
+
_chunkRQSQRZL4js.__name.call(void 0, registerRoute, "registerRoute");
|
|
162
164
|
}
|
|
163
|
-
|
|
165
|
+
_chunkRQSQRZL4js.__name.call(void 0, bind, "bind");
|
|
164
166
|
|
|
165
167
|
|
|
166
168
|
exports.bind = bind;
|
package/dist/http/hono/index.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-MMG73S64.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-QD3QR3NW.mjs";
|
|
11
11
|
|
|
12
12
|
// src/http/hono/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
@@ -62,6 +62,7 @@ function bind(router, data, opts = {}) {
|
|
|
62
62
|
const contextData = {
|
|
63
63
|
type: "hono",
|
|
64
64
|
parallel: true,
|
|
65
|
+
category: "http",
|
|
65
66
|
context: c,
|
|
66
67
|
index: i,
|
|
67
68
|
meta: meta2,
|
|
@@ -113,6 +114,7 @@ function bind(router, data, opts = {}) {
|
|
|
113
114
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
114
115
|
const contextData = {
|
|
115
116
|
type: "hono",
|
|
117
|
+
category: "http",
|
|
116
118
|
context: c,
|
|
117
119
|
meta: meta2,
|
|
118
120
|
moduleMap,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-wbHHC93P.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-CSiaRU7r.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-D1M85Hef.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HyperExpressCtx extends HttpContext {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-ee1FBodH.js';
|
|
3
|
+
import { F as Factory } from '../../core-C1kHRqU9.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-D1M85Hef.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HyperExpressCtx extends HttpContext {
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk6EBEME3Ijs = require('../../chunk-6EBEME3I.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkRQSQRZL4js = require('../../chunk-RQSQRZL4.js');
|
|
11
11
|
|
|
12
12
|
// src/http/hyper-express/bind.ts
|
|
13
13
|
var _hyperexpress = require('hyper-express');
|
|
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hyper-express");
|
|
|
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 = _chunk6EBEME3Ijs.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
|
+
_chunk6EBEME3Ijs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
addons: [
|
|
28
28
|
...globalAddons,
|
|
29
29
|
...parallelAddons
|
|
@@ -32,33 +32,34 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
async function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunk6EBEME3Ijs.Context.applyAddons(globalAddons, router, "hyper-express");
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
const subRouter = new (0, _hyperexpress.Router)();
|
|
38
38
|
subRouter.post(parallelRoute, async (req, res, next) => {
|
|
39
39
|
const body = await req.json();
|
|
40
40
|
async function errorHandler(e) {
|
|
41
|
-
const error = await
|
|
41
|
+
const error = await _chunk6EBEME3Ijs.Context.filterRecord.default(e);
|
|
42
42
|
return res.status(error.status).json(error);
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
44
|
+
_chunkRQSQRZL4js.__name.call(void 0, errorHandler, "errorHandler");
|
|
45
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk6EBEME3Ijs.BadRequestException)("data format should be an array"));
|
|
46
46
|
try {
|
|
47
47
|
return Promise.all(body.map((item, i) => {
|
|
48
48
|
return new Promise(async (resolve) => {
|
|
49
49
|
const { tag, func } = item;
|
|
50
50
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
51
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
51
|
+
if (!metaMap.has(tag)) return resolve(await _chunk6EBEME3Ijs.Context.filterRecord.default(new (0, _chunk6EBEME3Ijs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
52
52
|
const meta2 = metaMap.get(tag)[func];
|
|
53
|
-
if (!meta2) return resolve(await
|
|
53
|
+
if (!meta2) return resolve(await _chunk6EBEME3Ijs.Context.filterRecord.default(new (0, _chunk6EBEME3Ijs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
54
54
|
const { data: { params } } = meta2;
|
|
55
|
-
const aop =
|
|
55
|
+
const aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
56
56
|
globalFilter,
|
|
57
57
|
globalGuards,
|
|
58
58
|
globalPipe
|
|
59
59
|
});
|
|
60
60
|
const contextData = {
|
|
61
61
|
type: "hyper-express",
|
|
62
|
+
category: "http",
|
|
62
63
|
parallel: true,
|
|
63
64
|
request: req,
|
|
64
65
|
index: i,
|
|
@@ -68,18 +69,18 @@ function bind(router, data, opts = {}) {
|
|
|
68
69
|
tag,
|
|
69
70
|
func,
|
|
70
71
|
app: router,
|
|
71
|
-
...
|
|
72
|
+
..._chunk6EBEME3Ijs.argToReq.call(void 0, params, item.args, req.headers),
|
|
72
73
|
next,
|
|
73
|
-
getCookie: /* @__PURE__ */
|
|
74
|
-
setCookie: /* @__PURE__ */
|
|
75
|
-
delCookie: /* @__PURE__ */
|
|
76
|
-
redirect: /* @__PURE__ */
|
|
77
|
-
setResHeaders: /* @__PURE__ */
|
|
78
|
-
setResStatus: /* @__PURE__ */
|
|
79
|
-
getRequest: /* @__PURE__ */
|
|
80
|
-
getResponse: /* @__PURE__ */
|
|
74
|
+
getCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
75
|
+
setCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _2 => _2.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
|
|
76
|
+
delCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
77
|
+
redirect: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
78
|
+
setResHeaders: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
79
|
+
setResStatus: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
80
|
+
getRequest: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => req, "getRequest"),
|
|
81
|
+
getResponse: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => res, "getResponse")
|
|
81
82
|
};
|
|
82
|
-
const context = new (0,
|
|
83
|
+
const context = new (0, _chunk6EBEME3Ijs.Context)(contextData);
|
|
83
84
|
context.run(aop, resolve, resolve);
|
|
84
85
|
});
|
|
85
86
|
})).then((ret) => {
|
|
@@ -99,18 +100,19 @@ function bind(router, data, opts = {}) {
|
|
|
99
100
|
const needBody = params.some((item) => item.type === "body");
|
|
100
101
|
let aop;
|
|
101
102
|
if (!dynamic) {
|
|
102
|
-
aop =
|
|
103
|
+
aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
103
104
|
globalFilter,
|
|
104
105
|
globalGuards,
|
|
105
106
|
globalPipe
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
const subRouter = new (0, _hyperexpress.Router)();
|
|
109
|
-
|
|
110
|
+
_chunk6EBEME3Ijs.Context.applyAddons(addons, subRouter, "hyper-express");
|
|
110
111
|
subRouter[http.type](http.prefix + http.route, async (req, res, next) => {
|
|
111
112
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
112
113
|
const contextData = {
|
|
113
114
|
type: "hyper-express",
|
|
115
|
+
category: "http",
|
|
114
116
|
request: req,
|
|
115
117
|
meta: meta2,
|
|
116
118
|
response: res,
|
|
@@ -123,21 +125,21 @@ function bind(router, data, opts = {}) {
|
|
|
123
125
|
params: req.path_parameters,
|
|
124
126
|
headers: req.headers,
|
|
125
127
|
next,
|
|
126
|
-
getCookie: /* @__PURE__ */
|
|
127
|
-
setCookie: /* @__PURE__ */
|
|
128
|
-
delCookie: /* @__PURE__ */
|
|
129
|
-
redirect: /* @__PURE__ */
|
|
130
|
-
setResHeaders: /* @__PURE__ */
|
|
131
|
-
setResStatus: /* @__PURE__ */
|
|
132
|
-
getRequest: /* @__PURE__ */
|
|
133
|
-
getResponse: /* @__PURE__ */
|
|
128
|
+
getCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
129
|
+
setCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _4 => _4.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
|
|
130
|
+
delCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
131
|
+
redirect: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
132
|
+
setResHeaders: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
133
|
+
setResStatus: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
134
|
+
getRequest: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => req, "getRequest"),
|
|
135
|
+
getResponse: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => res, "getResponse")
|
|
134
136
|
};
|
|
135
|
-
const context = new (0,
|
|
137
|
+
const context = new (0, _chunk6EBEME3Ijs.Context)(contextData);
|
|
136
138
|
if (http.headers) {
|
|
137
139
|
for (const name in http.headers) res.set(name, http.headers[name]);
|
|
138
140
|
}
|
|
139
141
|
if (dynamic) {
|
|
140
|
-
aop =
|
|
142
|
+
aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
141
143
|
globalFilter,
|
|
142
144
|
globalGuards,
|
|
143
145
|
globalPipe
|
|
@@ -156,9 +158,9 @@ function bind(router, data, opts = {}) {
|
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
160
|
}
|
|
159
|
-
|
|
161
|
+
_chunkRQSQRZL4js.__name.call(void 0, registerRoute, "registerRoute");
|
|
160
162
|
}
|
|
161
|
-
|
|
163
|
+
_chunkRQSQRZL4js.__name.call(void 0, bind, "bind");
|
|
162
164
|
|
|
163
165
|
|
|
164
166
|
exports.bind = bind;
|