phecda-server 6.0.2 → 6.1.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/dist/{chunk-WXFZZZRY.mjs → chunk-2CFYUXPM.mjs} +1 -1
- package/dist/{chunk-HDQAT2IM.mjs → chunk-3H3T54IC.mjs} +116 -87
- package/dist/{chunk-7SYPUIBY.js → chunk-DVTBLV6I.js} +60 -60
- package/dist/{chunk-UXD62LGG.mjs → chunk-G7TD2VB7.mjs} +10 -2
- package/dist/{chunk-F3W3NN7F.mjs → chunk-J7B24YSE.mjs} +1 -1
- package/dist/{chunk-XCND2QW3.js → chunk-JDV2XJYE.js} +25 -25
- package/dist/chunk-NL6QBQAR.js +266 -0
- package/dist/{chunk-GHFSIZUO.js → chunk-TVT62GIX.js} +11 -3
- package/dist/core-BlN0Spy9.d.ts +47 -0
- package/dist/core-P1CsH6jz.d.mts +47 -0
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +49 -43
- package/dist/index.mjs +15 -9
- package/dist/rpc/bullmq/index.d.mts +1 -1
- package/dist/rpc/bullmq/index.d.ts +1 -1
- package/dist/rpc/bullmq/index.js +12 -12
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.d.mts +1 -1
- package/dist/rpc/kafka/index.d.ts +1 -1
- package/dist/rpc/kafka/index.js +12 -12
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +1 -1
- package/dist/rpc/nats/index.d.ts +1 -1
- package/dist/rpc/nats/index.js +11 -11
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.d.mts +1 -1
- package/dist/rpc/rabbitmq/index.d.ts +1 -1
- package/dist/rpc/rabbitmq/index.js +13 -13
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.d.mts +1 -1
- package/dist/rpc/redis/index.d.ts +1 -1
- package/dist/rpc/redis/index.js +11 -11
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/server/elysia/index.d.mts +1 -1
- package/dist/server/elysia/index.d.ts +1 -1
- package/dist/server/elysia/index.js +36 -36
- package/dist/server/elysia/index.mjs +3 -3
- package/dist/server/express/index.d.mts +1 -1
- package/dist/server/express/index.d.ts +1 -1
- package/dist/server/express/index.js +34 -34
- package/dist/server/express/index.mjs +2 -2
- package/dist/server/fastify/index.d.mts +1 -1
- package/dist/server/fastify/index.d.ts +1 -1
- package/dist/server/fastify/index.js +35 -35
- package/dist/server/fastify/index.mjs +3 -3
- package/dist/server/h3/index.d.mts +1 -1
- package/dist/server/h3/index.d.ts +1 -1
- package/dist/server/h3/index.js +34 -34
- package/dist/server/h3/index.mjs +2 -2
- package/dist/server/hono/index.d.mts +1 -1
- package/dist/server/hono/index.d.ts +1 -1
- package/dist/server/hono/index.js +33 -33
- package/dist/server/hono/index.mjs +2 -2
- package/dist/server/hyper-express/index.d.mts +1 -1
- package/dist/server/hyper-express/index.d.ts +1 -1
- package/dist/server/hyper-express/index.js +33 -33
- package/dist/server/hyper-express/index.mjs +2 -2
- package/dist/server/koa/index.d.mts +1 -1
- package/dist/server/koa/index.d.ts +1 -1
- package/dist/server/koa/index.js +34 -34
- package/dist/server/koa/index.mjs +2 -2
- package/dist/test.d.mts +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/package.json +2 -2
- package/dist/chunk-LYEZ6RGX.js +0 -237
- package/dist/core-2SNw8m2B.d.mts +0 -30
- package/dist/core-BmJJLUqj.d.ts +0 -30
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkDVTBLV6Ijs = require('../../chunk-DVTBLV6I.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkTVT62GIXjs = require('../../chunk-TVT62GIX.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 = _chunkDVTBLV6Ijs.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
|
+
_chunkDVTBLV6Ijs.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
|
+
_chunkDVTBLV6Ijs.Context.usePlugin(globalPlugins, "hono").forEach((p) => router.use(p));
|
|
37
37
|
if (parallelRoute) {
|
|
38
|
-
router.post(parallelRoute, ...
|
|
38
|
+
router.post(parallelRoute, ..._chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.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
|
+
_chunkTVT62GIXjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.Context.filterRecord.default(new (0, _chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.Context.filterRecord.default(new (0, _chunkDVTBLV6Ijs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
55
55
|
const { data: { params } } = meta2;
|
|
56
56
|
const contextData = {
|
|
57
57
|
type: "hono",
|
|
@@ -63,19 +63,19 @@ 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
|
+
..._chunkDVTBLV6Ijs.argToReq.call(void 0, params, item.args, c.req.header()),
|
|
67
|
+
getCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
68
|
+
delCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
69
|
+
setCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
70
|
+
redirect: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
71
|
+
setResHeaders: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (headers) => {
|
|
72
72
|
for (const name in headers) c.header(name, headers[name]);
|
|
73
73
|
}, "setResHeaders"),
|
|
74
|
-
setResStatus: /* @__PURE__ */
|
|
75
|
-
getRequest: /* @__PURE__ */
|
|
76
|
-
getResponse: /* @__PURE__ */
|
|
74
|
+
setResStatus: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
75
|
+
getRequest: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
76
|
+
getResponse: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => c.res, "getResponse")
|
|
77
77
|
};
|
|
78
|
-
const context = new (0,
|
|
78
|
+
const context = new (0, _chunkDVTBLV6Ijs.Context)(contextData);
|
|
79
79
|
context.run({
|
|
80
80
|
globalGuards,
|
|
81
81
|
globalInterceptors,
|
|
@@ -97,7 +97,7 @@ function bind(router, data, opts = {}) {
|
|
|
97
97
|
const { data: { params, plugins, http } } = meta2;
|
|
98
98
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
99
99
|
const needBody = params.some((item) => item.type === "body");
|
|
100
|
-
router[http.type](http.prefix + http.route, ...
|
|
100
|
+
router[http.type](http.prefix + http.route, ..._chunkDVTBLV6Ijs.Context.usePlugin(plugins, "hono"), async (c) => {
|
|
101
101
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
102
102
|
const contextData = {
|
|
103
103
|
type: "hono",
|
|
@@ -111,18 +111,18 @@ function bind(router, data, opts = {}) {
|
|
|
111
111
|
params: c.req.param(),
|
|
112
112
|
headers: c.req.header(),
|
|
113
113
|
app: router,
|
|
114
|
-
getCookie: /* @__PURE__ */
|
|
115
|
-
delCookie: /* @__PURE__ */
|
|
116
|
-
setCookie: /* @__PURE__ */
|
|
117
|
-
redirect: /* @__PURE__ */
|
|
118
|
-
setResHeaders: /* @__PURE__ */
|
|
114
|
+
getCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
115
|
+
delCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
116
|
+
setCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
117
|
+
redirect: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
118
|
+
setResHeaders: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (headers) => {
|
|
119
119
|
for (const name in headers) c.header(name, headers[name]);
|
|
120
120
|
}, "setResHeaders"),
|
|
121
|
-
setResStatus: /* @__PURE__ */
|
|
122
|
-
getRequest: /* @__PURE__ */
|
|
123
|
-
getResponse: /* @__PURE__ */
|
|
121
|
+
setResStatus: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
122
|
+
getRequest: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
123
|
+
getResponse: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => c.res, "getResponse")
|
|
124
124
|
};
|
|
125
|
-
const context = new (0,
|
|
125
|
+
const context = new (0, _chunkDVTBLV6Ijs.Context)(contextData);
|
|
126
126
|
if (http.headers) {
|
|
127
127
|
for (const name in http.headers) c.header(name, http.headers[name]);
|
|
128
128
|
}
|
|
@@ -143,9 +143,9 @@ function bind(router, data, opts = {}) {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
_chunkTVT62GIXjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
_chunkTVT62GIXjs.__name.call(void 0, bind, "bind");
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
exports.bind = bind;
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-2CFYUXPM.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-G7TD2VB7.mjs";
|
|
11
11
|
|
|
12
12
|
// src/server/hono/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
2
|
import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { F as Factory } from '../../core-P1CsH6jz.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../meta-KtfiBIde.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
2
|
import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { F as Factory } from '../../core-BlN0Spy9.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../meta-KtfiBIde.js';
|
|
6
6
|
import 'phecda-core';
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkDVTBLV6Ijs = require('../../chunk-DVTBLV6I.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkTVT62GIXjs = require('../../chunk-TVT62GIX.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 = _chunkDVTBLV6Ijs.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
|
+
_chunkDVTBLV6Ijs.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
|
+
_chunkDVTBLV6Ijs.Context.usePlugin(globalPlugins, "hyper-express").forEach((p) => router.use(p));
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
router.post(parallelRoute, {
|
|
38
|
-
middlewares:
|
|
38
|
+
middlewares: _chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.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
|
+
_chunkTVT62GIXjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.Context.filterRecord.default(new (0, _chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.Context.filterRecord.default(new (0, _chunkDVTBLV6Ijs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
55
55
|
const { data: { params } } = meta2;
|
|
56
56
|
const contextData = {
|
|
57
57
|
type: "hyper-express",
|
|
@@ -65,17 +65,17 @@ 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__ */
|
|
75
|
-
getRequest: /* @__PURE__ */
|
|
76
|
-
getResponse: /* @__PURE__ */
|
|
68
|
+
..._chunkDVTBLV6Ijs.argToReq.call(void 0, params, item.args, req.headers),
|
|
69
|
+
getCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
70
|
+
setCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__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__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
72
|
+
redirect: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
73
|
+
setResHeaders: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
74
|
+
setResStatus: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
75
|
+
getRequest: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => req, "getRequest"),
|
|
76
|
+
getResponse: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => res, "getResponse")
|
|
77
77
|
};
|
|
78
|
-
const context = new (0,
|
|
78
|
+
const context = new (0, _chunkDVTBLV6Ijs.Context)(contextData);
|
|
79
79
|
context.run({
|
|
80
80
|
globalGuards,
|
|
81
81
|
globalInterceptors,
|
|
@@ -97,7 +97,7 @@ function bind(router, data, opts = {}) {
|
|
|
97
97
|
const { data: { params, plugins, http } } = meta2;
|
|
98
98
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
|
|
99
99
|
const needBody = params.some((item) => item.type === "body");
|
|
100
|
-
router[http.type](http.prefix + http.route, ...
|
|
100
|
+
router[http.type](http.prefix + http.route, ..._chunkDVTBLV6Ijs.Context.usePlugin(plugins, "hyper-express"), async (req, res, next) => {
|
|
101
101
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
102
102
|
const contextData = {
|
|
103
103
|
type: "hyper-express",
|
|
@@ -113,16 +113,16 @@ function bind(router, data, opts = {}) {
|
|
|
113
113
|
params: req.path_parameters,
|
|
114
114
|
headers: req.headers,
|
|
115
115
|
next,
|
|
116
|
-
getCookie: /* @__PURE__ */
|
|
117
|
-
setCookie: /* @__PURE__ */
|
|
118
|
-
delCookie: /* @__PURE__ */
|
|
119
|
-
redirect: /* @__PURE__ */
|
|
120
|
-
setResHeaders: /* @__PURE__ */
|
|
121
|
-
setResStatus: /* @__PURE__ */
|
|
122
|
-
getRequest: /* @__PURE__ */
|
|
123
|
-
getResponse: /* @__PURE__ */
|
|
116
|
+
getCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
117
|
+
setCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _4 => _4.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
|
|
118
|
+
delCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
119
|
+
redirect: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
120
|
+
setResHeaders: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
121
|
+
setResStatus: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
122
|
+
getRequest: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => req, "getRequest"),
|
|
123
|
+
getResponse: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => res, "getResponse")
|
|
124
124
|
};
|
|
125
|
-
const context = new (0,
|
|
125
|
+
const context = new (0, _chunkDVTBLV6Ijs.Context)(contextData);
|
|
126
126
|
if (http.headers) {
|
|
127
127
|
for (const name in http.headers) res.set(name, http.headers[name]);
|
|
128
128
|
}
|
|
@@ -143,9 +143,9 @@ function bind(router, data, opts = {}) {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
_chunkTVT62GIXjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
_chunkTVT62GIXjs.__name.call(void 0, bind, "bind");
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
exports.bind = bind;
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-2CFYUXPM.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-G7TD2VB7.mjs";
|
|
11
11
|
|
|
12
12
|
// src/server/hyper-express/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
3
|
import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
4
|
+
import { F as Factory } from '../../core-P1CsH6jz.mjs';
|
|
5
5
|
import 'node:http';
|
|
6
6
|
import '../../meta-KtfiBIde.mjs';
|
|
7
7
|
import 'phecda-core';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
3
|
import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
4
|
+
import { F as Factory } from '../../core-BlN0Spy9.js';
|
|
5
5
|
import 'node:http';
|
|
6
6
|
import '../../meta-KtfiBIde.js';
|
|
7
7
|
import 'phecda-core';
|
package/dist/server/koa/index.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkDVTBLV6Ijs = require('../../chunk-DVTBLV6I.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkTVT62GIXjs = require('../../chunk-TVT62GIX.js');
|
|
12
12
|
|
|
13
13
|
// src/server/koa/bind.ts
|
|
14
14
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -17,14 +17,14 @@ 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
19
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
20
|
-
const metaMap =
|
|
20
|
+
const metaMap = _chunkDVTBLV6Ijs.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
|
+
_chunkDVTBLV6Ijs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
plugins: [
|
|
29
29
|
...globalPlugins,
|
|
30
30
|
...parallelPlugins
|
|
@@ -34,25 +34,25 @@ function bind(router, data, opts = {}) {
|
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
36
|
async function registerRoute() {
|
|
37
|
-
|
|
37
|
+
_chunkDVTBLV6Ijs.Context.usePlugin(globalPlugins, "koa").forEach((p) => router.use(p));
|
|
38
38
|
if (parallelRoute) {
|
|
39
|
-
router.post(parallelRoute, ...
|
|
39
|
+
router.post(parallelRoute, ..._chunkDVTBLV6Ijs.Context.usePlugin(parallelPlugins, "koa"), async (ctx, next) => {
|
|
40
40
|
const { body } = ctx.request;
|
|
41
41
|
async function errorHandler(e) {
|
|
42
|
-
const error = await
|
|
42
|
+
const error = await _chunkDVTBLV6Ijs.Context.filterRecord.default(e);
|
|
43
43
|
ctx.status = error.status;
|
|
44
44
|
ctx.body = error;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
46
|
+
_chunkTVT62GIXjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.Context.filterRecord.default(new (0, _chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.Context.filterRecord.default(new (0, _chunkDVTBLV6Ijs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
56
56
|
const { data: { params } } = meta2;
|
|
57
57
|
const contextData = {
|
|
58
58
|
type: "koa",
|
|
@@ -63,21 +63,21 @@ function bind(router, data, opts = {}) {
|
|
|
63
63
|
parallel: true,
|
|
64
64
|
next,
|
|
65
65
|
app: router,
|
|
66
|
-
...
|
|
66
|
+
..._chunkDVTBLV6Ijs.argToReq.call(void 0, params, item.args, ctx.headers),
|
|
67
67
|
tag,
|
|
68
68
|
func,
|
|
69
|
-
getCookie: /* @__PURE__ */
|
|
70
|
-
setCookie: /* @__PURE__ */
|
|
71
|
-
delCookie: /* @__PURE__ */
|
|
69
|
+
getCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
|
|
70
|
+
setCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
|
|
71
|
+
delCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
|
|
72
72
|
expires: /* @__PURE__ */ new Date(0)
|
|
73
73
|
}), "delCookie"),
|
|
74
|
-
redirect: /* @__PURE__ */
|
|
75
|
-
setResHeaders: /* @__PURE__ */
|
|
76
|
-
setResStatus: /* @__PURE__ */
|
|
77
|
-
getRequest: /* @__PURE__ */
|
|
78
|
-
getResponse: /* @__PURE__ */
|
|
74
|
+
redirect: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
|
|
75
|
+
setResHeaders: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
|
|
76
|
+
setResStatus: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
|
|
77
|
+
getRequest: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
78
|
+
getResponse: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
79
79
|
};
|
|
80
|
-
const context = new (0,
|
|
80
|
+
const context = new (0, _chunkDVTBLV6Ijs.Context)(contextData);
|
|
81
81
|
context.run({
|
|
82
82
|
globalGuards,
|
|
83
83
|
globalInterceptors,
|
|
@@ -98,7 +98,7 @@ function bind(router, data, opts = {}) {
|
|
|
98
98
|
const meta2 = metaMap.get(tag)[func];
|
|
99
99
|
const { data: { plugins, http } } = meta2;
|
|
100
100
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
101
|
-
router[http.type](http.prefix + http.route, ...
|
|
101
|
+
router[http.type](http.prefix + http.route, ..._chunkDVTBLV6Ijs.Context.usePlugin(plugins, "koa"), async (ctx, next) => {
|
|
102
102
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
103
103
|
const contextData = {
|
|
104
104
|
type: "koa",
|
|
@@ -113,18 +113,18 @@ function bind(router, data, opts = {}) {
|
|
|
113
113
|
body: ctx.request.body,
|
|
114
114
|
headers: ctx.headers,
|
|
115
115
|
next,
|
|
116
|
-
getCookie: /* @__PURE__ */
|
|
117
|
-
setCookie: /* @__PURE__ */
|
|
118
|
-
delCookie: /* @__PURE__ */
|
|
116
|
+
getCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
|
|
117
|
+
setCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
|
|
118
|
+
delCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
|
|
119
119
|
expires: /* @__PURE__ */ new Date(0)
|
|
120
120
|
}), "delCookie"),
|
|
121
|
-
redirect: /* @__PURE__ */
|
|
122
|
-
setResHeaders: /* @__PURE__ */
|
|
123
|
-
setResStatus: /* @__PURE__ */
|
|
124
|
-
getRequest: /* @__PURE__ */
|
|
125
|
-
getResponse: /* @__PURE__ */
|
|
121
|
+
redirect: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
|
|
122
|
+
setResHeaders: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
|
|
123
|
+
setResStatus: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
|
|
124
|
+
getRequest: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
125
|
+
getResponse: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
126
126
|
};
|
|
127
|
-
const context = new (0,
|
|
127
|
+
const context = new (0, _chunkDVTBLV6Ijs.Context)(contextData);
|
|
128
128
|
if (http.headers) ctx.set(http.headers);
|
|
129
129
|
await context.run({
|
|
130
130
|
globalGuards,
|
|
@@ -143,13 +143,13 @@ function bind(router, data, opts = {}) {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
_chunkTVT62GIXjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
147
|
+
_chunkDVTBLV6Ijs.HMR.call(void 0, async () => {
|
|
148
148
|
router.stack = originStack;
|
|
149
149
|
registerRoute();
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
_chunkTVT62GIXjs.__name.call(void 0, bind, "bind");
|
|
153
153
|
|
|
154
154
|
|
|
155
155
|
exports.bind = bind;
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
7
|
detectAopDep
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-2CFYUXPM.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-G7TD2VB7.mjs";
|
|
12
12
|
|
|
13
13
|
// src/server/koa/bind.ts
|
|
14
14
|
import Debug from "debug";
|
package/dist/test.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import * as supertest from 'supertest';
|
|
|
2
2
|
import { Test } from 'supertest';
|
|
3
3
|
import { Server } from 'node:http';
|
|
4
4
|
import { Construct } from 'phecda-core';
|
|
5
|
-
import { F as Factory } from './core-
|
|
5
|
+
import { F as Factory } from './core-P1CsH6jz.mjs';
|
|
6
6
|
import { P as PickFunc } from './meta-KtfiBIde.mjs';
|
|
7
7
|
|
|
8
8
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
package/dist/test.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as supertest from 'supertest';
|
|
|
2
2
|
import { Test } from 'supertest';
|
|
3
3
|
import { Server } from 'node:http';
|
|
4
4
|
import { Construct } from 'phecda-core';
|
|
5
|
-
import { F as Factory } from './core-
|
|
5
|
+
import { F as Factory } from './core-BlN0Spy9.js';
|
|
6
6
|
import { P as PickFunc } from './meta-KtfiBIde.js';
|
|
7
7
|
|
|
8
8
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
package/dist/test.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkNL6QBQARjs = require('./chunk-NL6QBQAR.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkTVT62GIXjs = require('./chunk-TVT62GIX.js');
|
|
7
7
|
|
|
8
8
|
// src/test.ts
|
|
9
9
|
var _phecdacore = require('phecda-core');
|
|
10
10
|
async function TestFactory(...Modules) {
|
|
11
|
-
const { moduleMap, modelMap } = await
|
|
11
|
+
const { moduleMap, modelMap } = await _chunkNL6QBQARjs.Factory.call(void 0, Modules);
|
|
12
12
|
return {
|
|
13
13
|
get(Model) {
|
|
14
14
|
const tag = _phecdacore.getTag.call(void 0, Model);
|
|
@@ -19,7 +19,7 @@ async function TestFactory(...Modules) {
|
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
_chunkTVT62GIXjs.__name.call(void 0, TestFactory, "TestFactory");
|
|
23
23
|
async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
24
24
|
const { default: request, agent } = await Promise.resolve().then(() => _interopRequireWildcard(require("supertest")));
|
|
25
25
|
const Agent = agent(app);
|
|
@@ -59,11 +59,11 @@ async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
_chunkTVT62GIXjs.__name.call(void 0, module, "module");
|
|
63
63
|
Agent.module = module;
|
|
64
64
|
return Agent;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
_chunkTVT62GIXjs.__name.call(void 0, TestHttp, "TestHttp");
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
|
package/dist/test.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
|
|
5
5
|
"author": "fgsreally",
|
|
6
6
|
"license": "MIT",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"picocolors": "^1.0.0",
|
|
147
147
|
"reflect-metadata": "^0.1.13",
|
|
148
148
|
"ts-mixer": "^6.0.4",
|
|
149
|
-
"phecda-core": "4.0.
|
|
149
|
+
"phecda-core": "4.0.1"
|
|
150
150
|
},
|
|
151
151
|
"devDependencies": {
|
|
152
152
|
"@koa/router": "^12.0.1",
|