phecda-server 7.0.0-alpha.10 → 7.0.0-alpha.12
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 +3 -3
- package/dist/{chunk-G7JFKM2M.js → chunk-IJFIY6QN.js} +1 -9
- package/dist/{chunk-Z7NAAE4M.mjs → chunk-VX4BZEL7.mjs} +0 -8
- package/dist/{core-CUTbX_IS.d.ts → core-CDzIy2g0.d.ts} +1 -1
- package/dist/{core-DIfgUKIU.d.mts → core-jUg1HvYT.d.mts} +1 -1
- package/dist/helper.d.mts +2 -4
- package/dist/helper.d.ts +2 -4
- package/dist/helper.js +2 -4
- package/dist/helper.mjs +1 -3
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +18 -17
- package/dist/http/elysia/index.mjs +2 -1
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +17 -16
- package/dist/http/express/index.mjs +2 -1
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +17 -16
- package/dist/http/fastify/index.mjs +2 -1
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +18 -17
- package/dist/http/h3/index.mjs +2 -1
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +15 -14
- package/dist/http/hono/index.mjs +2 -1
- 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 +16 -15
- package/dist/http/hyper-express/index.mjs +2 -1
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +17 -16
- package/dist/http/koa/index.mjs +2 -1
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +19 -19
- package/dist/index.mjs +1 -1
- package/dist/{meta-CR-D39hQ.d.mts → meta-xvg6V7pH.d.mts} +2 -19
- package/dist/{meta-CR-D39hQ.d.ts → meta-xvg6V7pH.d.ts} +2 -19
- package/dist/rpc/bullmq/index.d.mts +4 -6
- package/dist/rpc/bullmq/index.d.ts +4 -6
- package/dist/rpc/bullmq/index.js +7 -75
- package/dist/rpc/bullmq/index.mjs +3 -71
- package/dist/rpc/kafka/index.d.mts +4 -9
- package/dist/rpc/kafka/index.d.ts +4 -9
- package/dist/rpc/kafka/index.js +7 -86
- package/dist/rpc/kafka/index.mjs +3 -82
- package/dist/rpc/nats/index.d.mts +4 -6
- package/dist/rpc/nats/index.d.ts +4 -6
- package/dist/rpc/nats/index.js +7 -67
- package/dist/rpc/nats/index.mjs +2 -62
- package/dist/rpc/rabbitmq/index.d.mts +4 -6
- package/dist/rpc/rabbitmq/index.d.ts +4 -6
- package/dist/rpc/rabbitmq/index.js +7 -73
- package/dist/rpc/rabbitmq/index.mjs +3 -69
- package/dist/rpc/redis/index.d.mts +4 -9
- package/dist/rpc/redis/index.d.ts +4 -9
- package/dist/rpc/redis/index.js +7 -74
- package/dist/rpc/redis/index.mjs +3 -70
- package/dist/test.d.mts +8 -4
- package/dist/test.d.ts +8 -4
- package/dist/types-6qaaUIKZ.d.mts +14 -0
- package/dist/{types-BF1TDbFV.d.ts → types-B-1OL-3P.d.ts} +1 -1
- package/dist/types-BtXOT5rI.d.ts +14 -0
- package/dist/{types-DYviSl5B.d.mts → types-Ctd6pLNE.d.mts} +1 -1
- package/package.json +2 -3
- package/register/loader.mjs +31 -22
- package/register/utils.mjs +26 -0
- package/dist/types-DYRu0vic.d.ts +0 -19
- package/dist/types-DqH1qA-q.d.mts +0 -19
package/dist/http/h3/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { H3Event, Router, _RequestMiddleware } from 'h3';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-CDzIy2g0.js';
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-B-1OL-3P.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-xvg6V7pH.js';
|
|
6
6
|
import 'node:http';
|
|
7
7
|
|
|
8
8
|
interface H3Ctx extends HttpCtx {
|
package/dist/http/h3/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkIJFIY6QNjs = require('../../chunk-IJFIY6QN.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
@@ -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 = _chunkIJFIY6QNjs.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
|
+
_chunkIJFIY6QNjs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
addons: [
|
|
28
28
|
...globalAddons,
|
|
29
29
|
...parallelAddons
|
|
@@ -32,31 +32,32 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunkIJFIY6QNjs.Context.applyAddons(globalAddons, router, "h3");
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
38
|
-
|
|
38
|
+
_chunkIJFIY6QNjs.Context.applyAddons(parallelAddons, subRouter, "h3");
|
|
39
39
|
subRouter.post(parallelRoute, _h3.eventHandler.call(void 0, {
|
|
40
40
|
handler: /* @__PURE__ */ _chunk4LLLQOMFjs.__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 _chunkIJFIY6QNjs.Context.filterRecord.default(e);
|
|
46
46
|
_h3.setResponseStatus.call(void 0, event, error.status);
|
|
47
47
|
return error;
|
|
48
48
|
}
|
|
49
49
|
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkIJFIY6QNjs.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
|
+
if (!item) return resolve(null);
|
|
54
55
|
const { tag, func } = item;
|
|
55
56
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
56
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
57
|
+
if (!metaMap.has(tag)) return resolve(await _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
57
58
|
const meta2 = metaMap.get(tag)[func];
|
|
58
|
-
if (!meta2) return resolve(await
|
|
59
|
-
const aop =
|
|
59
|
+
if (!meta2) return resolve(await _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
60
|
+
const aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
60
61
|
globalFilter,
|
|
61
62
|
globalGuards,
|
|
62
63
|
globalPipe
|
|
@@ -80,7 +81,7 @@ function bind(router, data, opts = {}) {
|
|
|
80
81
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
81
82
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
82
83
|
};
|
|
83
|
-
const context = new (0,
|
|
84
|
+
const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
|
|
84
85
|
context.run(aop, resolve, resolve);
|
|
85
86
|
});
|
|
86
87
|
}));
|
|
@@ -99,15 +100,15 @@ 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 = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
103
104
|
globalFilter,
|
|
104
105
|
globalGuards,
|
|
105
106
|
globalPipe
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
const subRouter = _h3.createRouter.call(void 0, );
|
|
109
|
-
|
|
110
|
-
subRouter[http.type](
|
|
110
|
+
_chunkIJFIY6QNjs.Context.applyAddons(addons, subRouter, "h3");
|
|
111
|
+
subRouter[http.type](_chunkIJFIY6QNjs.joinUrl.call(void 0, http.prefix, http.route), _h3.defineEventHandler.call(void 0, async (event) => {
|
|
111
112
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
112
113
|
const contextData = {
|
|
113
114
|
type: "h3",
|
|
@@ -133,10 +134,10 @@ function bind(router, data, opts = {}) {
|
|
|
133
134
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
134
135
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
135
136
|
};
|
|
136
|
-
const context = new (0,
|
|
137
|
+
const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
|
|
137
138
|
_h3.setHeaders.call(void 0, event, http.headers || {});
|
|
138
139
|
if (dynamic) {
|
|
139
|
-
aop =
|
|
140
|
+
aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
140
141
|
globalFilter,
|
|
141
142
|
globalGuards,
|
|
142
143
|
globalPipe
|
|
@@ -147,7 +148,7 @@ function bind(router, data, opts = {}) {
|
|
|
147
148
|
return err;
|
|
148
149
|
});
|
|
149
150
|
}));
|
|
150
|
-
router.use(
|
|
151
|
+
router.use(_chunkIJFIY6QNjs.joinUrl.call(void 0, http.prefix, http.route), _h3.useBase.call(void 0, "", subRouter.handler));
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
}
|
package/dist/http/h3/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
joinUrl
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-VX4BZEL7.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
10
|
} from "../../chunk-NQ55PA2X.mjs";
|
|
@@ -51,6 +51,7 @@ function bind(router, data, opts = {}) {
|
|
|
51
51
|
try {
|
|
52
52
|
return Promise.all(body.map((item, i) => {
|
|
53
53
|
return new Promise(async (resolve) => {
|
|
54
|
+
if (!item) return resolve(null);
|
|
54
55
|
const { tag, func } = item;
|
|
55
56
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
56
57
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context, Hono, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-Ctd6pLNE.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-jUg1HvYT.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-xvg6V7pH.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HonoCtx extends HttpCtx {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context, Hono, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-B-1OL-3P.js';
|
|
3
|
+
import { F as Factory } from '../../core-CDzIy2g0.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-xvg6V7pH.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HonoCtx extends HttpCtx {
|
package/dist/http/hono/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkIJFIY6QNjs = require('../../chunk-IJFIY6QN.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hono");
|
|
|
16
16
|
function bind(router, data, opts = {}) {
|
|
17
17
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
|
-
const metaMap =
|
|
19
|
+
const metaMap = _chunkIJFIY6QNjs.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
|
+
_chunkIJFIY6QNjs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
addons: [
|
|
28
28
|
...globalAddons,
|
|
29
29
|
...parallelAddons
|
|
@@ -34,25 +34,26 @@ function bind(router, data, opts = {}) {
|
|
|
34
34
|
function registerRoute() {
|
|
35
35
|
if (parallelRoute) {
|
|
36
36
|
const subApp = new (0, _hono.Hono)();
|
|
37
|
-
|
|
37
|
+
_chunkIJFIY6QNjs.Context.applyAddons(parallelAddons, subApp, "hono");
|
|
38
38
|
subApp.post("", async (c) => {
|
|
39
39
|
const body = await c.req.json();
|
|
40
40
|
async function errorHandler(e) {
|
|
41
|
-
const error = await
|
|
41
|
+
const error = await _chunkIJFIY6QNjs.Context.filterRecord.default(e);
|
|
42
42
|
c.status(error.status);
|
|
43
43
|
return c.json(error);
|
|
44
44
|
}
|
|
45
45
|
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkIJFIY6QNjs.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
|
+
if (!item) return resolve(null);
|
|
50
51
|
const { tag, func } = item;
|
|
51
52
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
52
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
53
|
+
if (!metaMap.has(tag)) return resolve(await _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
53
54
|
const meta2 = metaMap.get(tag)[func];
|
|
54
|
-
if (!meta2) return resolve(await
|
|
55
|
-
const aop =
|
|
55
|
+
if (!meta2) return resolve(await _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
56
|
+
const aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
56
57
|
globalFilter,
|
|
57
58
|
globalGuards,
|
|
58
59
|
globalPipe
|
|
@@ -78,7 +79,7 @@ function bind(router, data, opts = {}) {
|
|
|
78
79
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
79
80
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => c.res, "getResponse")
|
|
80
81
|
};
|
|
81
|
-
const context = new (0,
|
|
82
|
+
const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
|
|
82
83
|
context.run(aop, resolve, resolve);
|
|
83
84
|
});
|
|
84
85
|
})).then((ret) => {
|
|
@@ -98,14 +99,14 @@ function bind(router, data, opts = {}) {
|
|
|
98
99
|
const needBody = params.some((item) => item.type === "body");
|
|
99
100
|
let aop;
|
|
100
101
|
if (!dynamic) {
|
|
101
|
-
aop =
|
|
102
|
+
aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
102
103
|
globalFilter,
|
|
103
104
|
globalGuards,
|
|
104
105
|
globalPipe
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
108
|
const subApp = new (0, _hono.Hono)();
|
|
108
|
-
|
|
109
|
+
_chunkIJFIY6QNjs.Context.applyAddons(addons, subApp, "hono");
|
|
109
110
|
subApp[http.type](http.route, async (c) => {
|
|
110
111
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
111
112
|
const contextData = {
|
|
@@ -132,12 +133,12 @@ function bind(router, data, opts = {}) {
|
|
|
132
133
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
133
134
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => c.res, "getResponse")
|
|
134
135
|
};
|
|
135
|
-
const context = new (0,
|
|
136
|
+
const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
|
|
136
137
|
if (http.headers) {
|
|
137
138
|
for (const name in http.headers) c.header(name, http.headers[name]);
|
|
138
139
|
}
|
|
139
140
|
if (dynamic) {
|
|
140
|
-
aop =
|
|
141
|
+
aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
141
142
|
globalFilter,
|
|
142
143
|
globalGuards,
|
|
143
144
|
globalPipe
|
package/dist/http/hono/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Context,
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-VX4BZEL7.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
9
|
} from "../../chunk-NQ55PA2X.mjs";
|
|
@@ -47,6 +47,7 @@ function bind(router, data, opts = {}) {
|
|
|
47
47
|
try {
|
|
48
48
|
return Promise.all(body.map((item, i) => {
|
|
49
49
|
return new Promise(async (resolve) => {
|
|
50
|
+
if (!item) return resolve(null);
|
|
50
51
|
const { tag, func } = item;
|
|
51
52
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
52
53
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-Ctd6pLNE.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-jUg1HvYT.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-xvg6V7pH.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HyperExpressCtx extends HttpCtx {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-B-1OL-3P.js';
|
|
3
|
+
import { F as Factory } from '../../core-CDzIy2g0.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-xvg6V7pH.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HyperExpressCtx extends HttpCtx {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkIJFIY6QNjs = require('../../chunk-IJFIY6QN.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
@@ -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 = _chunkIJFIY6QNjs.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
|
+
_chunkIJFIY6QNjs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
addons: [
|
|
28
28
|
...globalAddons,
|
|
29
29
|
...parallelAddons
|
|
@@ -32,26 +32,27 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
async function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunkIJFIY6QNjs.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 _chunkIJFIY6QNjs.Context.filterRecord.default(e);
|
|
42
42
|
return res.status(error.status).json(error);
|
|
43
43
|
}
|
|
44
44
|
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
45
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
45
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkIJFIY6QNjs.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
|
+
if (!item) return resolve(null);
|
|
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 _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
52
53
|
const meta2 = metaMap.get(tag)[func];
|
|
53
|
-
if (!meta2) return resolve(await
|
|
54
|
-
const aop =
|
|
54
|
+
if (!meta2) return resolve(await _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
55
|
+
const aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
55
56
|
globalFilter,
|
|
56
57
|
globalGuards,
|
|
57
58
|
globalPipe
|
|
@@ -77,7 +78,7 @@ function bind(router, data, opts = {}) {
|
|
|
77
78
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req, "getRequest"),
|
|
78
79
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res, "getResponse")
|
|
79
80
|
};
|
|
80
|
-
const context = new (0,
|
|
81
|
+
const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
|
|
81
82
|
context.run(aop, resolve, resolve);
|
|
82
83
|
});
|
|
83
84
|
})).then((ret) => {
|
|
@@ -97,15 +98,15 @@ function bind(router, data, opts = {}) {
|
|
|
97
98
|
const needBody = params.some((item) => item.type === "body");
|
|
98
99
|
let aop;
|
|
99
100
|
if (!dynamic) {
|
|
100
|
-
aop =
|
|
101
|
+
aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
101
102
|
globalFilter,
|
|
102
103
|
globalGuards,
|
|
103
104
|
globalPipe
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
const subRouter = new (0, _hyperexpress.Router)();
|
|
107
|
-
|
|
108
|
-
subRouter[http.type](
|
|
108
|
+
_chunkIJFIY6QNjs.Context.applyAddons(addons, subRouter, "hyper-express");
|
|
109
|
+
subRouter[http.type](_chunkIJFIY6QNjs.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
|
|
109
110
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
110
111
|
const contextData = {
|
|
111
112
|
type: "hyper-express",
|
|
@@ -131,12 +132,12 @@ function bind(router, data, opts = {}) {
|
|
|
131
132
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req, "getRequest"),
|
|
132
133
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res, "getResponse")
|
|
133
134
|
};
|
|
134
|
-
const context = new (0,
|
|
135
|
+
const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
|
|
135
136
|
if (http.headers) {
|
|
136
137
|
for (const name in http.headers) res.set(name, http.headers[name]);
|
|
137
138
|
}
|
|
138
139
|
if (dynamic) {
|
|
139
|
-
aop =
|
|
140
|
+
aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
140
141
|
globalFilter,
|
|
141
142
|
globalGuards,
|
|
142
143
|
globalPipe
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
joinUrl
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-VX4BZEL7.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
10
|
} from "../../chunk-NQ55PA2X.mjs";
|
|
@@ -46,6 +46,7 @@ function bind(router, data, opts = {}) {
|
|
|
46
46
|
try {
|
|
47
47
|
return Promise.all(body.map((item, i) => {
|
|
48
48
|
return new Promise(async (resolve) => {
|
|
49
|
+
if (!item) return resolve(null);
|
|
49
50
|
const { tag, func } = item;
|
|
50
51
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
51
52
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-Ctd6pLNE.mjs';
|
|
4
|
+
import { F as Factory } from '../../core-jUg1HvYT.mjs';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-xvg6V7pH.mjs';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
9
|
interface KoaCtx extends HttpCtx {
|
package/dist/http/koa/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-B-1OL-3P.js';
|
|
4
|
+
import { F as Factory } from '../../core-CDzIy2g0.js';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-xvg6V7pH.js';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
9
|
interface KoaCtx extends HttpCtx {
|
package/dist/http/koa/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkIJFIY6QNjs = require('../../chunk-IJFIY6QN.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -18,14 +18,14 @@ 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
20
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkIJFIY6QNjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
22
|
const { controller, http, func, tag } = meta2.data;
|
|
23
23
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
24
24
|
debug(`register method "${func}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunkIJFIY6QNjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -34,28 +34,29 @@ function bind(router, data, opts = {}) {
|
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
36
|
function registerRoute() {
|
|
37
|
-
|
|
37
|
+
_chunkIJFIY6QNjs.Context.applyAddons(globalAddons, router, "koa");
|
|
38
38
|
if (parallelRoute) {
|
|
39
39
|
const subRouter = new (0, _router2.default)();
|
|
40
|
-
|
|
40
|
+
_chunkIJFIY6QNjs.Context.applyAddons(parallelAddons, subRouter, "koa");
|
|
41
41
|
subRouter.post(parallelRoute, async (ctx, next) => {
|
|
42
42
|
const { body } = ctx.request;
|
|
43
43
|
async function errorHandler(e) {
|
|
44
|
-
const error = await
|
|
44
|
+
const error = await _chunkIJFIY6QNjs.Context.filterRecord.default(e);
|
|
45
45
|
ctx.status = error.status;
|
|
46
46
|
ctx.body = error;
|
|
47
47
|
}
|
|
48
48
|
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
49
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
49
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkIJFIY6QNjs.BadRequestException)("data format should be an array"));
|
|
50
50
|
try {
|
|
51
51
|
return Promise.all(body.map((item, i) => {
|
|
52
52
|
return new Promise(async (resolve) => {
|
|
53
|
+
if (!item) return resolve(null);
|
|
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 _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
56
57
|
const meta2 = metaMap.get(tag)[func];
|
|
57
|
-
if (!meta2) return resolve(await
|
|
58
|
-
const aop =
|
|
58
|
+
if (!meta2) return resolve(await _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
|
+
const aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
59
60
|
globalGuards,
|
|
60
61
|
globalFilter,
|
|
61
62
|
globalPipe
|
|
@@ -82,7 +83,7 @@ function bind(router, data, opts = {}) {
|
|
|
82
83
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
83
84
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
84
85
|
};
|
|
85
|
-
const context = new (0,
|
|
86
|
+
const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
|
|
86
87
|
context.run(aop, resolve, resolve);
|
|
87
88
|
});
|
|
88
89
|
})).then((ret) => {
|
|
@@ -101,15 +102,15 @@ function bind(router, data, opts = {}) {
|
|
|
101
102
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
102
103
|
let aop;
|
|
103
104
|
if (!dynamic) {
|
|
104
|
-
aop =
|
|
105
|
+
aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
105
106
|
globalFilter,
|
|
106
107
|
globalGuards,
|
|
107
108
|
globalPipe
|
|
108
109
|
});
|
|
109
110
|
}
|
|
110
111
|
const subRouter = new (0, _router2.default)();
|
|
111
|
-
|
|
112
|
-
router[http.type](
|
|
112
|
+
_chunkIJFIY6QNjs.Context.applyAddons(addons, subRouter, "koa");
|
|
113
|
+
router[http.type](_chunkIJFIY6QNjs.joinUrl.call(void 0, http.prefix, http.route), async (ctx, next) => {
|
|
113
114
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
114
115
|
const contextData = {
|
|
115
116
|
type: "koa",
|
|
@@ -136,10 +137,10 @@ function bind(router, data, opts = {}) {
|
|
|
136
137
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
137
138
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
138
139
|
};
|
|
139
|
-
const context = new (0,
|
|
140
|
+
const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
|
|
140
141
|
if (http.headers) ctx.set(http.headers);
|
|
141
142
|
if (dynamic) {
|
|
142
|
-
aop =
|
|
143
|
+
aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
143
144
|
globalFilter,
|
|
144
145
|
globalGuards,
|
|
145
146
|
globalPipe
|
package/dist/http/koa/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
joinUrl
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-VX4BZEL7.mjs";
|
|
8
8
|
import {
|
|
9
9
|
HMR,
|
|
10
10
|
__name
|
|
@@ -50,6 +50,7 @@ function bind(router, data, opts = {}) {
|
|
|
50
50
|
try {
|
|
51
51
|
return Promise.all(body.map((item, i) => {
|
|
52
52
|
return new Promise(async (resolve) => {
|
|
53
|
+
if (!item) return resolve(null);
|
|
53
54
|
const { tag, func } = item;
|
|
54
55
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
55
56
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-
|
|
2
|
-
export {
|
|
3
|
-
import { G as Generator } from './core-
|
|
4
|
-
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-
|
|
1
|
+
import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-xvg6V7pH.mjs';
|
|
2
|
+
export { d as BaseRequestType, e as CustomResponse, g as ERROR_SYMBOL, f as ExtractResponse, I as IS_DEV, h as IS_ONLY_GENERATE, j as IS_PURE, i as IS_STRICT, L as LOG_LEVEL, M as Meta, P as PS_EXIT_CODE, S as ServiceMetaData } from './meta-xvg6V7pH.mjs';
|
|
3
|
+
import { G as Generator } from './core-jUg1HvYT.mjs';
|
|
4
|
+
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-jUg1HvYT.mjs';
|
|
5
5
|
import { Base } from 'phecda-core';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
|
-
import { H as HttpCtx } from './types-
|
|
8
|
-
export { C as CookieSerializeOptions, a as HttpOptions } from './types-
|
|
9
|
-
import { R as RpcCtx } from './types-
|
|
10
|
-
export {
|
|
7
|
+
import { H as HttpCtx } from './types-Ctd6pLNE.mjs';
|
|
8
|
+
export { C as CookieSerializeOptions, a as HttpOptions } from './types-Ctd6pLNE.mjs';
|
|
9
|
+
import { R as RpcCtx } from './types-6qaaUIKZ.mjs';
|
|
10
|
+
export { a as RpcServerOptions } from './types-6qaaUIKZ.mjs';
|
|
11
11
|
export { Mixin } from 'ts-mixer';
|
|
12
12
|
import 'node:http';
|
|
13
13
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-
|
|
2
|
-
export {
|
|
3
|
-
import { G as Generator } from './core-
|
|
4
|
-
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-
|
|
1
|
+
import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-xvg6V7pH.js';
|
|
2
|
+
export { d as BaseRequestType, e as CustomResponse, g as ERROR_SYMBOL, f as ExtractResponse, I as IS_DEV, h as IS_ONLY_GENERATE, j as IS_PURE, i as IS_STRICT, L as LOG_LEVEL, M as Meta, P as PS_EXIT_CODE, S as ServiceMetaData } from './meta-xvg6V7pH.js';
|
|
3
|
+
import { G as Generator } from './core-CDzIy2g0.js';
|
|
4
|
+
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-CDzIy2g0.js';
|
|
5
5
|
import { Base } from 'phecda-core';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
|
-
import { H as HttpCtx } from './types-
|
|
8
|
-
export { C as CookieSerializeOptions, a as HttpOptions } from './types-
|
|
9
|
-
import { R as RpcCtx } from './types-
|
|
10
|
-
export {
|
|
7
|
+
import { H as HttpCtx } from './types-B-1OL-3P.js';
|
|
8
|
+
export { C as CookieSerializeOptions, a as HttpOptions } from './types-B-1OL-3P.js';
|
|
9
|
+
import { R as RpcCtx } from './types-BtXOT5rI.js';
|
|
10
|
+
export { a as RpcServerOptions } from './types-BtXOT5rI.js';
|
|
11
11
|
export { Mixin } from 'ts-mixer';
|
|
12
12
|
import 'node:http';
|
|
13
13
|
|