phecda-server 7.0.0-alpha.6 → 7.0.0-alpha.8
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 +10 -1
- package/dist/{chunk-JF4YU32E.js → chunk-7EMAZGYO.js} +86 -56
- package/dist/{chunk-ICI5KUDX.mjs → chunk-7NWDKK7D.mjs} +1 -1
- package/dist/{chunk-HTY3H33L.mjs → chunk-B45BN7LY.mjs} +4 -4
- package/dist/{chunk-UKRQVTEY.js → chunk-BBNJVYVX.js} +24 -24
- package/dist/{chunk-WYI2F7LD.js → chunk-QJIAXSLZ.js} +19 -19
- package/dist/{chunk-3C7Z3IJN.mjs → chunk-SGMQZRP6.mjs} +39 -9
- package/dist/{chunk-62FBZWGW.js → chunk-VSGYTGHY.js} +24 -3
- package/dist/{chunk-KSDE5G57.mjs → chunk-YKP4ODZA.mjs} +24 -3
- package/dist/{core-CzElxZoF.d.ts → core-BGEsBtTG.d.ts} +1 -1
- package/dist/{core-DU7gQKSk.d.mts → core-BcKywWLd.d.mts} +1 -1
- package/dist/helper.d.mts +3 -2
- package/dist/helper.d.ts +3 -2
- package/dist/helper.js +5 -3
- package/dist/helper.mjs +4 -2
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +42 -41
- package/dist/http/elysia/index.mjs +6 -5
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +39 -38
- package/dist/http/express/index.mjs +5 -4
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +40 -39
- package/dist/http/fastify/index.mjs +6 -5
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +40 -39
- package/dist/http/h3/index.mjs +6 -5
- package/dist/http/hono/index.d.mts +4 -4
- package/dist/http/hono/index.d.ts +4 -4
- package/dist/http/hono/index.js +35 -35
- package/dist/http/hono/index.mjs +2 -2
- package/dist/http/hyper-express/index.d.mts +4 -4
- package/dist/http/hyper-express/index.d.ts +4 -4
- package/dist/http/hyper-express/index.js +37 -36
- package/dist/http/hyper-express/index.mjs +5 -4
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +39 -38
- package/dist/http/koa/index.mjs +5 -4
- package/dist/index.d.mts +38 -36
- package/dist/index.d.ts +38 -36
- package/dist/index.js +44 -43
- package/dist/index.mjs +16 -15
- package/dist/{meta-BTnLXuCa.d.ts → meta-B_HW7cWh.d.mts} +3 -3
- package/dist/{meta-BTnLXuCa.d.mts → meta-B_HW7cWh.d.ts} +3 -3
- package/dist/rpc/bullmq/index.d.mts +5 -5
- package/dist/rpc/bullmq/index.d.ts +5 -5
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.d.mts +4 -4
- package/dist/rpc/kafka/index.d.ts +4 -4
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +4 -4
- package/dist/rpc/nats/index.d.ts +4 -4
- package/dist/rpc/nats/index.js +13 -13
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.d.mts +4 -4
- package/dist/rpc/rabbitmq/index.d.ts +4 -4
- package/dist/rpc/rabbitmq/index.js +15 -15
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.d.mts +4 -4
- package/dist/rpc/redis/index.d.ts +4 -4
- package/dist/rpc/redis/index.js +13 -13
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types--E-OCZhC.d.ts → types-C2SQ9U9V.d.mts} +3 -3
- package/dist/{types-CbfaGkPA.d.ts → types-CYF0vha6.d.ts} +3 -3
- package/dist/{types-BYqBeqrs.d.mts → types-DEQb_e59.d.mts} +3 -3
- package/dist/{types-BxlzVoRv.d.mts → types-PFPIQWVF.d.ts} +3 -3
- package/package.json +3 -2
- package/register/loader.mjs +2 -2
package/dist/http/hono/index.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk7EMAZGYOjs = require('../../chunk-7EMAZGYO.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkVSGYTGHYjs = require('../../chunk-VSGYTGHY.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 = _chunk7EMAZGYOjs.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
|
+
_chunk7EMAZGYOjs.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
|
+
_chunk7EMAZGYOjs.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 _chunk7EMAZGYOjs.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
|
+
_chunkVSGYTGHYjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk7EMAZGYOjs.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 _chunk7EMAZGYOjs.Context.filterRecord.default(new (0, _chunk7EMAZGYOjs.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 _chunk7EMAZGYOjs.Context.filterRecord.default(new (0, _chunk7EMAZGYOjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
56
56
|
const { data: { params } } = meta2;
|
|
57
|
-
const aop =
|
|
57
|
+
const aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
58
58
|
globalFilter,
|
|
59
59
|
globalGuards,
|
|
60
60
|
globalPipe
|
|
@@ -70,19 +70,19 @@ function bind(router, data, opts = {}) {
|
|
|
70
70
|
tag,
|
|
71
71
|
func,
|
|
72
72
|
app: router,
|
|
73
|
-
...
|
|
74
|
-
getCookie: /* @__PURE__ */
|
|
75
|
-
delCookie: /* @__PURE__ */
|
|
76
|
-
setCookie: /* @__PURE__ */
|
|
77
|
-
redirect: /* @__PURE__ */
|
|
78
|
-
setResHeaders: /* @__PURE__ */
|
|
73
|
+
..._chunk7EMAZGYOjs.argToReq.call(void 0, params, item.args, c.req.header()),
|
|
74
|
+
getCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
75
|
+
delCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
76
|
+
setCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
77
|
+
redirect: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
78
|
+
setResHeaders: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (headers) => {
|
|
79
79
|
for (const name in headers) c.header(name, headers[name]);
|
|
80
80
|
}, "setResHeaders"),
|
|
81
|
-
setResStatus: /* @__PURE__ */
|
|
82
|
-
getRequest: /* @__PURE__ */
|
|
83
|
-
getResponse: /* @__PURE__ */
|
|
81
|
+
setResStatus: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
82
|
+
getRequest: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
83
|
+
getResponse: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => c.res, "getResponse")
|
|
84
84
|
};
|
|
85
|
-
const context = new (0,
|
|
85
|
+
const context = new (0, _chunk7EMAZGYOjs.Context)(contextData);
|
|
86
86
|
context.run(aop, resolve, resolve);
|
|
87
87
|
});
|
|
88
88
|
})).then((ret) => {
|
|
@@ -102,14 +102,14 @@ function bind(router, data, opts = {}) {
|
|
|
102
102
|
const needBody = params.some((item) => item.type === "body");
|
|
103
103
|
let aop;
|
|
104
104
|
if (!dynamic) {
|
|
105
|
-
aop =
|
|
105
|
+
aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
106
106
|
globalFilter,
|
|
107
107
|
globalGuards,
|
|
108
108
|
globalPipe
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
const subApp = new (0, _hono.Hono)();
|
|
112
|
-
|
|
112
|
+
_chunk7EMAZGYOjs.Context.applyAddons(addons, subApp, "hono");
|
|
113
113
|
subApp[http.type](http.route, async (c) => {
|
|
114
114
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
115
115
|
const contextData = {
|
|
@@ -125,23 +125,23 @@ function bind(router, data, opts = {}) {
|
|
|
125
125
|
params: c.req.param(),
|
|
126
126
|
headers: c.req.header(),
|
|
127
127
|
app: router,
|
|
128
|
-
getCookie: /* @__PURE__ */
|
|
129
|
-
delCookie: /* @__PURE__ */
|
|
130
|
-
setCookie: /* @__PURE__ */
|
|
131
|
-
redirect: /* @__PURE__ */
|
|
132
|
-
setResHeaders: /* @__PURE__ */
|
|
128
|
+
getCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
129
|
+
delCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
130
|
+
setCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
131
|
+
redirect: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
132
|
+
setResHeaders: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (headers) => {
|
|
133
133
|
for (const name in headers) c.header(name, headers[name]);
|
|
134
134
|
}, "setResHeaders"),
|
|
135
|
-
setResStatus: /* @__PURE__ */
|
|
136
|
-
getRequest: /* @__PURE__ */
|
|
137
|
-
getResponse: /* @__PURE__ */
|
|
135
|
+
setResStatus: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
136
|
+
getRequest: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
137
|
+
getResponse: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => c.res, "getResponse")
|
|
138
138
|
};
|
|
139
|
-
const context = new (0,
|
|
139
|
+
const context = new (0, _chunk7EMAZGYOjs.Context)(contextData);
|
|
140
140
|
if (http.headers) {
|
|
141
141
|
for (const name in http.headers) c.header(name, http.headers[name]);
|
|
142
142
|
}
|
|
143
143
|
if (dynamic) {
|
|
144
|
-
aop =
|
|
144
|
+
aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
145
145
|
globalFilter,
|
|
146
146
|
globalGuards,
|
|
147
147
|
globalPipe
|
|
@@ -160,9 +160,9 @@ function bind(router, data, opts = {}) {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
|
|
163
|
+
_chunkVSGYTGHYjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
164
164
|
}
|
|
165
|
-
|
|
165
|
+
_chunkVSGYTGHYjs.__name.call(void 0, bind, "bind");
|
|
166
166
|
|
|
167
167
|
|
|
168
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-SGMQZRP6.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-YKP4ODZA.mjs";
|
|
11
11
|
|
|
12
12
|
// src/http/hono/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { H as
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-C2SQ9U9V.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-BcKywWLd.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-B_HW7cWh.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
|
-
interface HyperExpressCtx extends
|
|
8
|
+
interface HyperExpressCtx extends HttpCtx {
|
|
9
9
|
type: 'hyper-express';
|
|
10
10
|
request: Request;
|
|
11
11
|
response: Response;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { H as
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-PFPIQWVF.js';
|
|
3
|
+
import { F as Factory } from '../../core-BGEsBtTG.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-B_HW7cWh.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
|
-
interface HyperExpressCtx extends
|
|
8
|
+
interface HyperExpressCtx extends HttpCtx {
|
|
9
9
|
type: 'hyper-express';
|
|
10
10
|
request: Request;
|
|
11
11
|
response: Response;
|
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var _chunkJF4YU32Ejs = require('../../chunk-JF4YU32E.js');
|
|
8
7
|
|
|
8
|
+
var _chunk7EMAZGYOjs = require('../../chunk-7EMAZGYO.js');
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
var _chunkVSGYTGHYjs = require('../../chunk-VSGYTGHY.js');
|
|
11
12
|
|
|
12
13
|
// src/http/hyper-express/bind.ts
|
|
13
14
|
var _hyperexpress = require('hyper-express');
|
|
@@ -16,14 +17,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hyper-express");
|
|
|
16
17
|
function bind(router, data, opts = {}) {
|
|
17
18
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
18
19
|
const { moduleMap, meta } = data;
|
|
19
|
-
const metaMap =
|
|
20
|
+
const metaMap = _chunk7EMAZGYOjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
20
21
|
const { controller, http, func, tag } = meta2.data;
|
|
21
22
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
22
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
23
24
|
return true;
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
|
-
|
|
27
|
+
_chunk7EMAZGYOjs.detectAopDep.call(void 0, meta, {
|
|
27
28
|
addons: [
|
|
28
29
|
...globalAddons,
|
|
29
30
|
...parallelAddons
|
|
@@ -32,27 +33,27 @@ function bind(router, data, opts = {}) {
|
|
|
32
33
|
});
|
|
33
34
|
registerRoute();
|
|
34
35
|
async function registerRoute() {
|
|
35
|
-
|
|
36
|
+
_chunk7EMAZGYOjs.Context.applyAddons(globalAddons, router, "hyper-express");
|
|
36
37
|
if (parallelRoute) {
|
|
37
38
|
const subRouter = new (0, _hyperexpress.Router)();
|
|
38
39
|
subRouter.post(parallelRoute, async (req, res, next) => {
|
|
39
40
|
const body = await req.json();
|
|
40
41
|
async function errorHandler(e) {
|
|
41
|
-
const error = await
|
|
42
|
+
const error = await _chunk7EMAZGYOjs.Context.filterRecord.default(e);
|
|
42
43
|
return res.status(error.status).json(error);
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
45
|
+
_chunkVSGYTGHYjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk7EMAZGYOjs.BadRequestException)("data format should be an array"));
|
|
46
47
|
try {
|
|
47
48
|
return Promise.all(body.map((item, i) => {
|
|
48
49
|
return new Promise(async (resolve) => {
|
|
49
50
|
const { tag, func } = item;
|
|
50
51
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
51
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
52
|
+
if (!metaMap.has(tag)) return resolve(await _chunk7EMAZGYOjs.Context.filterRecord.default(new (0, _chunk7EMAZGYOjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
52
53
|
const meta2 = metaMap.get(tag)[func];
|
|
53
|
-
if (!meta2) return resolve(await
|
|
54
|
+
if (!meta2) return resolve(await _chunk7EMAZGYOjs.Context.filterRecord.default(new (0, _chunk7EMAZGYOjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
54
55
|
const { data: { params } } = meta2;
|
|
55
|
-
const aop =
|
|
56
|
+
const aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
56
57
|
globalFilter,
|
|
57
58
|
globalGuards,
|
|
58
59
|
globalPipe
|
|
@@ -69,18 +70,18 @@ function bind(router, data, opts = {}) {
|
|
|
69
70
|
tag,
|
|
70
71
|
func,
|
|
71
72
|
app: router,
|
|
72
|
-
...
|
|
73
|
+
..._chunk7EMAZGYOjs.argToReq.call(void 0, params, item.args, req.headers),
|
|
73
74
|
next,
|
|
74
|
-
getCookie: /* @__PURE__ */
|
|
75
|
-
setCookie: /* @__PURE__ */
|
|
76
|
-
delCookie: /* @__PURE__ */
|
|
77
|
-
redirect: /* @__PURE__ */
|
|
78
|
-
setResHeaders: /* @__PURE__ */
|
|
79
|
-
setResStatus: /* @__PURE__ */
|
|
80
|
-
getRequest: /* @__PURE__ */
|
|
81
|
-
getResponse: /* @__PURE__ */
|
|
75
|
+
getCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
76
|
+
setCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _2 => _2.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
|
|
77
|
+
delCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
78
|
+
redirect: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
79
|
+
setResHeaders: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
80
|
+
setResStatus: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
81
|
+
getRequest: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => req, "getRequest"),
|
|
82
|
+
getResponse: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => res, "getResponse")
|
|
82
83
|
};
|
|
83
|
-
const context = new (0,
|
|
84
|
+
const context = new (0, _chunk7EMAZGYOjs.Context)(contextData);
|
|
84
85
|
context.run(aop, resolve, resolve);
|
|
85
86
|
});
|
|
86
87
|
})).then((ret) => {
|
|
@@ -100,15 +101,15 @@ function bind(router, data, opts = {}) {
|
|
|
100
101
|
const needBody = params.some((item) => item.type === "body");
|
|
101
102
|
let aop;
|
|
102
103
|
if (!dynamic) {
|
|
103
|
-
aop =
|
|
104
|
+
aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
104
105
|
globalFilter,
|
|
105
106
|
globalGuards,
|
|
106
107
|
globalPipe
|
|
107
108
|
});
|
|
108
109
|
}
|
|
109
110
|
const subRouter = new (0, _hyperexpress.Router)();
|
|
110
|
-
|
|
111
|
-
subRouter[http.type](http.prefix
|
|
111
|
+
_chunk7EMAZGYOjs.Context.applyAddons(addons, subRouter, "hyper-express");
|
|
112
|
+
subRouter[http.type](_chunk7EMAZGYOjs.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
|
|
112
113
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
113
114
|
const contextData = {
|
|
114
115
|
type: "hyper-express",
|
|
@@ -125,21 +126,21 @@ function bind(router, data, opts = {}) {
|
|
|
125
126
|
params: req.path_parameters,
|
|
126
127
|
headers: req.headers,
|
|
127
128
|
next,
|
|
128
|
-
getCookie: /* @__PURE__ */
|
|
129
|
-
setCookie: /* @__PURE__ */
|
|
130
|
-
delCookie: /* @__PURE__ */
|
|
131
|
-
redirect: /* @__PURE__ */
|
|
132
|
-
setResHeaders: /* @__PURE__ */
|
|
133
|
-
setResStatus: /* @__PURE__ */
|
|
134
|
-
getRequest: /* @__PURE__ */
|
|
135
|
-
getResponse: /* @__PURE__ */
|
|
129
|
+
getCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
130
|
+
setCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _4 => _4.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
|
|
131
|
+
delCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
132
|
+
redirect: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
133
|
+
setResHeaders: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
134
|
+
setResStatus: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
135
|
+
getRequest: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => req, "getRequest"),
|
|
136
|
+
getResponse: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => res, "getResponse")
|
|
136
137
|
};
|
|
137
|
-
const context = new (0,
|
|
138
|
+
const context = new (0, _chunk7EMAZGYOjs.Context)(contextData);
|
|
138
139
|
if (http.headers) {
|
|
139
140
|
for (const name in http.headers) res.set(name, http.headers[name]);
|
|
140
141
|
}
|
|
141
142
|
if (dynamic) {
|
|
142
|
-
aop =
|
|
143
|
+
aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
143
144
|
globalFilter,
|
|
144
145
|
globalGuards,
|
|
145
146
|
globalPipe
|
|
@@ -158,9 +159,9 @@ function bind(router, data, opts = {}) {
|
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
|
-
|
|
162
|
+
_chunkVSGYTGHYjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
162
163
|
}
|
|
163
|
-
|
|
164
|
+
_chunkVSGYTGHYjs.__name.call(void 0, bind, "bind");
|
|
164
165
|
|
|
165
166
|
|
|
166
167
|
exports.bind = bind;
|
|
@@ -3,11 +3,12 @@ import {
|
|
|
3
3
|
Context,
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
|
-
detectAopDep
|
|
7
|
-
|
|
6
|
+
detectAopDep,
|
|
7
|
+
joinUrl
|
|
8
|
+
} from "../../chunk-SGMQZRP6.mjs";
|
|
8
9
|
import {
|
|
9
10
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-YKP4ODZA.mjs";
|
|
11
12
|
|
|
12
13
|
// src/http/hyper-express/bind.ts
|
|
13
14
|
import { Router } from "hyper-express";
|
|
@@ -108,7 +109,7 @@ function bind(router, data, opts = {}) {
|
|
|
108
109
|
}
|
|
109
110
|
const subRouter = new Router();
|
|
110
111
|
Context.applyAddons(addons, subRouter, "hyper-express");
|
|
111
|
-
subRouter[http.type](http.prefix
|
|
112
|
+
subRouter[http.type](joinUrl(http.prefix, http.route), async (req, res, next) => {
|
|
112
113
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
113
114
|
const contextData = {
|
|
114
115
|
type: "hyper-express",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
|
-
import { H as
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-C2SQ9U9V.mjs';
|
|
4
|
+
import { F as Factory } from '../../core-BcKywWLd.mjs';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-B_HW7cWh.mjs';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
|
-
interface KoaCtx extends
|
|
9
|
+
interface KoaCtx extends HttpCtx {
|
|
10
10
|
type: 'koa';
|
|
11
11
|
ctx: DefaultContext & RouterParamContext<DefaultState, DefaultContext>;
|
|
12
12
|
next: Function;
|
package/dist/http/koa/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
|
-
import { H as
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-PFPIQWVF.js';
|
|
4
|
+
import { F as Factory } from '../../core-BGEsBtTG.js';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-B_HW7cWh.js';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
|
-
interface KoaCtx extends
|
|
9
|
+
interface KoaCtx extends HttpCtx {
|
|
10
10
|
type: 'koa';
|
|
11
11
|
ctx: DefaultContext & RouterParamContext<DefaultState, DefaultContext>;
|
|
12
12
|
next: Function;
|
package/dist/http/koa/index.js
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var _chunkJF4YU32Ejs = require('../../chunk-JF4YU32E.js');
|
|
9
8
|
|
|
9
|
+
var _chunk7EMAZGYOjs = require('../../chunk-7EMAZGYO.js');
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
var _chunkVSGYTGHYjs = require('../../chunk-VSGYTGHY.js');
|
|
12
13
|
|
|
13
14
|
// src/http/koa/bind.ts
|
|
14
15
|
var _router = require('@koa/router'); var _router2 = _interopRequireDefault(_router);
|
|
@@ -18,14 +19,14 @@ function bind(router, data, opts = {}) {
|
|
|
18
19
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
19
20
|
const { moduleMap, meta } = data;
|
|
20
21
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
21
|
-
const metaMap =
|
|
22
|
+
const metaMap = _chunk7EMAZGYOjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
23
|
const { controller, http, func, tag } = meta2.data;
|
|
23
24
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
24
25
|
debug(`register method "${func}" in module "${tag}"`);
|
|
25
26
|
return true;
|
|
26
27
|
}
|
|
27
28
|
});
|
|
28
|
-
|
|
29
|
+
_chunk7EMAZGYOjs.detectAopDep.call(void 0, meta, {
|
|
29
30
|
addons: [
|
|
30
31
|
...globalAddons,
|
|
31
32
|
...parallelAddons
|
|
@@ -34,29 +35,29 @@ function bind(router, data, opts = {}) {
|
|
|
34
35
|
});
|
|
35
36
|
registerRoute();
|
|
36
37
|
function registerRoute() {
|
|
37
|
-
|
|
38
|
+
_chunk7EMAZGYOjs.Context.applyAddons(globalAddons, router, "koa");
|
|
38
39
|
if (parallelRoute) {
|
|
39
40
|
const subRouter = new (0, _router2.default)();
|
|
40
|
-
|
|
41
|
+
_chunk7EMAZGYOjs.Context.applyAddons(parallelAddons, subRouter, "koa");
|
|
41
42
|
subRouter.post(parallelRoute, async (ctx, next) => {
|
|
42
43
|
const { body } = ctx.request;
|
|
43
44
|
async function errorHandler(e) {
|
|
44
|
-
const error = await
|
|
45
|
+
const error = await _chunk7EMAZGYOjs.Context.filterRecord.default(e);
|
|
45
46
|
ctx.status = error.status;
|
|
46
47
|
ctx.body = error;
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
49
|
+
_chunkVSGYTGHYjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk7EMAZGYOjs.BadRequestException)("data format should be an array"));
|
|
50
51
|
try {
|
|
51
52
|
return Promise.all(body.map((item, i) => {
|
|
52
53
|
return new Promise(async (resolve) => {
|
|
53
54
|
const { tag, func } = item;
|
|
54
55
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
55
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
56
|
+
if (!metaMap.has(tag)) return resolve(await _chunk7EMAZGYOjs.Context.filterRecord.default(new (0, _chunk7EMAZGYOjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
56
57
|
const meta2 = metaMap.get(tag)[func];
|
|
57
|
-
if (!meta2) return resolve(await
|
|
58
|
+
if (!meta2) return resolve(await _chunk7EMAZGYOjs.Context.filterRecord.default(new (0, _chunk7EMAZGYOjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
58
59
|
const { data: { params } } = meta2;
|
|
59
|
-
const aop =
|
|
60
|
+
const aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
60
61
|
globalGuards,
|
|
61
62
|
globalFilter,
|
|
62
63
|
globalPipe
|
|
@@ -71,21 +72,21 @@ function bind(router, data, opts = {}) {
|
|
|
71
72
|
parallel: true,
|
|
72
73
|
next,
|
|
73
74
|
app: router,
|
|
74
|
-
...
|
|
75
|
+
..._chunk7EMAZGYOjs.argToReq.call(void 0, params, item.args, ctx.headers),
|
|
75
76
|
tag,
|
|
76
77
|
func,
|
|
77
|
-
getCookie: /* @__PURE__ */
|
|
78
|
-
setCookie: /* @__PURE__ */
|
|
79
|
-
delCookie: /* @__PURE__ */
|
|
78
|
+
getCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
|
|
79
|
+
setCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
|
|
80
|
+
delCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
|
|
80
81
|
expires: /* @__PURE__ */ new Date(0)
|
|
81
82
|
}), "delCookie"),
|
|
82
|
-
redirect: /* @__PURE__ */
|
|
83
|
-
setResHeaders: /* @__PURE__ */
|
|
84
|
-
setResStatus: /* @__PURE__ */
|
|
85
|
-
getRequest: /* @__PURE__ */
|
|
86
|
-
getResponse: /* @__PURE__ */
|
|
83
|
+
redirect: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
|
|
84
|
+
setResHeaders: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
|
|
85
|
+
setResStatus: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
|
|
86
|
+
getRequest: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
87
|
+
getResponse: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
87
88
|
};
|
|
88
|
-
const context = new (0,
|
|
89
|
+
const context = new (0, _chunk7EMAZGYOjs.Context)(contextData);
|
|
89
90
|
context.run(aop, resolve, resolve);
|
|
90
91
|
});
|
|
91
92
|
})).then((ret) => {
|
|
@@ -104,15 +105,15 @@ function bind(router, data, opts = {}) {
|
|
|
104
105
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
105
106
|
let aop;
|
|
106
107
|
if (!dynamic) {
|
|
107
|
-
aop =
|
|
108
|
+
aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
108
109
|
globalFilter,
|
|
109
110
|
globalGuards,
|
|
110
111
|
globalPipe
|
|
111
112
|
});
|
|
112
113
|
}
|
|
113
114
|
const subRouter = new (0, _router2.default)();
|
|
114
|
-
|
|
115
|
-
router[http.type](http.prefix
|
|
115
|
+
_chunk7EMAZGYOjs.Context.applyAddons(addons, subRouter, "koa");
|
|
116
|
+
router[http.type](_chunk7EMAZGYOjs.joinUrl.call(void 0, http.prefix, http.route), async (ctx, next) => {
|
|
116
117
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
117
118
|
const contextData = {
|
|
118
119
|
type: "koa",
|
|
@@ -128,21 +129,21 @@ function bind(router, data, opts = {}) {
|
|
|
128
129
|
body: ctx.request.body,
|
|
129
130
|
headers: ctx.headers,
|
|
130
131
|
next,
|
|
131
|
-
getCookie: /* @__PURE__ */
|
|
132
|
-
setCookie: /* @__PURE__ */
|
|
133
|
-
delCookie: /* @__PURE__ */
|
|
132
|
+
getCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
|
|
133
|
+
setCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
|
|
134
|
+
delCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
|
|
134
135
|
expires: /* @__PURE__ */ new Date(0)
|
|
135
136
|
}), "delCookie"),
|
|
136
|
-
redirect: /* @__PURE__ */
|
|
137
|
-
setResHeaders: /* @__PURE__ */
|
|
138
|
-
setResStatus: /* @__PURE__ */
|
|
139
|
-
getRequest: /* @__PURE__ */
|
|
140
|
-
getResponse: /* @__PURE__ */
|
|
137
|
+
redirect: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
|
|
138
|
+
setResHeaders: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
|
|
139
|
+
setResStatus: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
|
|
140
|
+
getRequest: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
141
|
+
getResponse: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
141
142
|
};
|
|
142
|
-
const context = new (0,
|
|
143
|
+
const context = new (0, _chunk7EMAZGYOjs.Context)(contextData);
|
|
143
144
|
if (http.headers) ctx.set(http.headers);
|
|
144
145
|
if (dynamic) {
|
|
145
|
-
aop =
|
|
146
|
+
aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
146
147
|
globalFilter,
|
|
147
148
|
globalGuards,
|
|
148
149
|
globalPipe
|
|
@@ -161,13 +162,13 @@ function bind(router, data, opts = {}) {
|
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
_chunkVSGYTGHYjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
166
|
+
_chunk7EMAZGYOjs.HMR.call(void 0, async () => {
|
|
166
167
|
router.stack = originStack;
|
|
167
168
|
registerRoute();
|
|
168
169
|
});
|
|
169
170
|
}
|
|
170
|
-
|
|
171
|
+
_chunkVSGYTGHYjs.__name.call(void 0, bind, "bind");
|
|
171
172
|
|
|
172
173
|
|
|
173
174
|
exports.bind = bind;
|
package/dist/http/koa/index.mjs
CHANGED
|
@@ -4,11 +4,12 @@ import {
|
|
|
4
4
|
HMR,
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
|
-
detectAopDep
|
|
8
|
-
|
|
7
|
+
detectAopDep,
|
|
8
|
+
joinUrl
|
|
9
|
+
} from "../../chunk-SGMQZRP6.mjs";
|
|
9
10
|
import {
|
|
10
11
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-YKP4ODZA.mjs";
|
|
12
13
|
|
|
13
14
|
// src/http/koa/bind.ts
|
|
14
15
|
import Router from "@koa/router";
|
|
@@ -112,7 +113,7 @@ function bind(router, data, opts = {}) {
|
|
|
112
113
|
}
|
|
113
114
|
const subRouter = new Router();
|
|
114
115
|
Context.applyAddons(addons, subRouter, "koa");
|
|
115
|
-
router[http.type](http.prefix
|
|
116
|
+
router[http.type](joinUrl(http.prefix, http.route), async (ctx, next) => {
|
|
116
117
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
117
118
|
const contextData = {
|
|
118
119
|
type: "koa",
|