phecda-server 5.2.2 → 5.2.4
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 +1 -0
- package/dist/{chunk-VMLHTEW3.js → chunk-AWY6FTH4.js} +38 -38
- package/dist/{chunk-ZP7HNASU.js → chunk-FNJWO324.js} +1 -1
- package/dist/{chunk-BSE2DSDK.js → chunk-H6NYBVBV.js} +64 -64
- package/dist/{chunk-V3WIKOP3.mjs → chunk-IJNA24EZ.mjs} +2 -2
- package/dist/{chunk-CKQW3FDK.mjs → chunk-LGP5AT6W.mjs} +7 -4
- package/dist/{chunk-JE6BBDXW.mjs → chunk-Q4AGVGVA.mjs} +1 -1
- package/dist/{chunk-5BVUCNMA.js → chunk-UJAI73O6.js} +24 -21
- package/dist/{chunk-VLV3AO3H.mjs → chunk-VYDBNZJ2.mjs} +1 -1
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +54 -48
- package/dist/index.mjs +20 -14
- package/dist/rpc/bullmq/index.js +12 -12
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.js +10 -10
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.js +12 -11
- package/dist/rpc/nats/index.mjs +3 -2
- package/dist/rpc/rabbitmq/index.js +13 -13
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.js +11 -11
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/server/elysia/index.d.ts +1 -1
- package/dist/server/elysia/index.js +20 -20
- package/dist/server/elysia/index.mjs +3 -3
- package/dist/server/express/index.d.ts +1 -1
- package/dist/server/express/index.js +18 -18
- package/dist/server/express/index.mjs +2 -2
- package/dist/server/fastify/index.d.ts +1 -1
- package/dist/server/fastify/index.js +19 -19
- package/dist/server/fastify/index.mjs +3 -3
- package/dist/server/h3/index.d.ts +1 -1
- package/dist/server/h3/index.js +16 -16
- package/dist/server/h3/index.mjs +2 -2
- package/dist/server/hono/index.d.ts +1 -1
- package/dist/server/hono/index.js +17 -17
- package/dist/server/hono/index.mjs +2 -2
- package/dist/server/hyper-express/index.d.ts +1 -1
- package/dist/server/hyper-express/index.js +17 -17
- package/dist/server/hyper-express/index.mjs +2 -2
- package/dist/server/koa/index.d.ts +1 -1
- package/dist/server/koa/index.js +18 -18
- package/dist/server/koa/index.mjs +2 -2
- package/dist/test.d.ts +1 -1
- package/dist/test.js +8 -8
- package/dist/test.mjs +2 -2
- package/dist/{types-68f2ec2a.d.ts → types-0a76c4bc.d.ts} +9 -0
- package/package.json +1 -1
- package/register/loader.mjs +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-IJNA24EZ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
BadRequestException,
|
|
6
6
|
Context,
|
|
7
7
|
argToReq,
|
|
8
8
|
createControllerMetaMap,
|
|
9
9
|
detectAopDep
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-Q4AGVGVA.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-VYDBNZJ2.mjs";
|
|
14
14
|
|
|
15
15
|
// src/server/elysia/bind.ts
|
|
16
16
|
import Debug from "debug";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Request, Response, Router, RequestHandler } from 'express';
|
|
2
|
-
import { a as HttpContext, H as HttpOptions } from '../../types-
|
|
2
|
+
import { a as HttpContext, H as HttpOptions } from '../../types-0a76c4bc.js';
|
|
3
3
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../types-81be0ba3.js';
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
|
|
12
12
|
|
|
13
13
|
// src/server/express/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 = _chunkH6NYBVBVjs.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
|
+
_chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
plugins: [
|
|
29
29
|
...globalPlugins,
|
|
30
30
|
...parallelPlugins
|
|
@@ -33,32 +33,32 @@ function bind(router, data, opts = {}) {
|
|
|
33
33
|
interceptors: globalInterceptors
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
|
-
|
|
36
|
+
_chunkH6NYBVBVjs.HMR.call(void 0, async () => {
|
|
37
37
|
router.stack = originStack;
|
|
38
38
|
registerRoute();
|
|
39
39
|
});
|
|
40
40
|
async function registerRoute() {
|
|
41
|
-
|
|
41
|
+
_chunkH6NYBVBVjs.Context.usePlugin(globalPlugins, "express").forEach((p) => router.use(p));
|
|
42
42
|
if (parallelRoute) {
|
|
43
|
-
router.post(parallelRoute, ...
|
|
43
|
+
router.post(parallelRoute, ..._chunkH6NYBVBVjs.Context.usePlugin(parallelPlugins, "express"), async (req, res, next) => {
|
|
44
44
|
const { body } = req;
|
|
45
45
|
async function errorHandler(e) {
|
|
46
|
-
const error = await
|
|
46
|
+
const error = await _chunkH6NYBVBVjs.Context.filterRecord.default(e);
|
|
47
47
|
return res.status(error.status).json(error);
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
_chunkFNJWO324js.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
50
|
if (!Array.isArray(body))
|
|
51
|
-
return errorHandler(new (0,
|
|
51
|
+
return errorHandler(new (0, _chunkH6NYBVBVjs.BadRequestException)("data format should be an array"));
|
|
52
52
|
try {
|
|
53
53
|
return Promise.all(body.map((item, i) => {
|
|
54
54
|
return new Promise(async (resolve) => {
|
|
55
55
|
const { tag, func } = item;
|
|
56
56
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
57
57
|
if (!metaMap.has(tag))
|
|
58
|
-
return resolve(await
|
|
58
|
+
return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
59
59
|
const meta2 = metaMap.get(tag)[func];
|
|
60
60
|
if (!meta2)
|
|
61
|
-
return resolve(await
|
|
61
|
+
return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
62
62
|
const { data: { params } } = meta2;
|
|
63
63
|
const contextData = {
|
|
64
64
|
type: "express",
|
|
@@ -72,9 +72,9 @@ function bind(router, data, opts = {}) {
|
|
|
72
72
|
func,
|
|
73
73
|
next,
|
|
74
74
|
app: router,
|
|
75
|
-
...
|
|
75
|
+
..._chunkH6NYBVBVjs.argToReq.call(void 0, params, item.args, req.headers)
|
|
76
76
|
};
|
|
77
|
-
const context = new (0,
|
|
77
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
|
|
78
78
|
context.run({
|
|
79
79
|
globalGuards,
|
|
80
80
|
globalInterceptors,
|
|
@@ -96,7 +96,7 @@ function bind(router, data, opts = {}) {
|
|
|
96
96
|
const { data: { plugins, http } } = meta2;
|
|
97
97
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
|
|
98
98
|
continue;
|
|
99
|
-
router[http.type](http.prefix + http.route, ...
|
|
99
|
+
router[http.type](http.prefix + http.route, ..._chunkH6NYBVBVjs.Context.usePlugin(plugins, "express"), async (req, res, next) => {
|
|
100
100
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
101
101
|
const contextData = {
|
|
102
102
|
type: "express",
|
|
@@ -113,7 +113,7 @@ function bind(router, data, opts = {}) {
|
|
|
113
113
|
app: router,
|
|
114
114
|
next
|
|
115
115
|
};
|
|
116
|
-
const context = new (0,
|
|
116
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
|
|
117
117
|
if (http.headers) {
|
|
118
118
|
for (const name in http.headers)
|
|
119
119
|
res.set(name, http.headers[name]);
|
|
@@ -139,9 +139,9 @@ function bind(router, data, opts = {}) {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
_chunkFNJWO324js.__name.call(void 0, registerRoute, "registerRoute");
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
_chunkFNJWO324js.__name.call(void 0, bind, "bind");
|
|
145
145
|
|
|
146
146
|
|
|
147
147
|
exports.bind = bind;
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
7
|
detectAopDep
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-Q4AGVGVA.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-VYDBNZJ2.mjs";
|
|
12
12
|
|
|
13
13
|
// src/server/express/bind.ts
|
|
14
14
|
import Debug from "debug";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
|
-
import { a as HttpContext, H as HttpOptions } from '../../types-
|
|
2
|
+
import { a as HttpContext, H as HttpOptions } from '../../types-0a76c4bc.js';
|
|
3
3
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../types-81be0ba3.js';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkAWY6FTH4js = require('../../chunk-AWY6FTH4.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
|
|
14
14
|
|
|
15
15
|
// src/server/fastify/bind.ts
|
|
16
16
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -18,14 +18,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/fastify");
|
|
|
18
18
|
function bind(fastify, data, opts = {}) {
|
|
19
19
|
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe, fastifyOpts } = opts;
|
|
20
20
|
const { moduleMap, meta } = data;
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkH6NYBVBVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
22
|
const { controller, http, func, tag } = meta2.data;
|
|
23
23
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _2 => _2.type])) {
|
|
24
24
|
debug(`register method "${func}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
plugins: [
|
|
30
30
|
...globalPlugins,
|
|
31
31
|
...parallelPlugins
|
|
@@ -34,12 +34,12 @@ function bind(fastify, data, opts = {}) {
|
|
|
34
34
|
interceptors: globalInterceptors
|
|
35
35
|
});
|
|
36
36
|
fastify.register((fastify2, _, done) => {
|
|
37
|
-
|
|
37
|
+
_chunkH6NYBVBVjs.Context.usePlugin(globalPlugins, "fastify").forEach((p) => {
|
|
38
38
|
p[Symbol.for("skip-override")] = true;
|
|
39
39
|
fastify2.register(p);
|
|
40
40
|
});
|
|
41
41
|
fastify2.register((fastify3, _opts, done2) => {
|
|
42
|
-
|
|
42
|
+
_chunkH6NYBVBVjs.Context.usePlugin(parallelPlugins, "fastify").forEach((p) => {
|
|
43
43
|
p[Symbol.for("skip-override")] = true;
|
|
44
44
|
fastify3.register(p);
|
|
45
45
|
});
|
|
@@ -47,22 +47,22 @@ function bind(fastify, data, opts = {}) {
|
|
|
47
47
|
fastify3.post(parallelRoute, async (req, res) => {
|
|
48
48
|
const { body } = req;
|
|
49
49
|
async function errorHandler(e) {
|
|
50
|
-
const error = await
|
|
50
|
+
const error = await _chunkH6NYBVBVjs.Context.filterRecord.default(e);
|
|
51
51
|
return res.status(error.status).send(error);
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
_chunkFNJWO324js.__name.call(void 0, errorHandler, "errorHandler");
|
|
54
54
|
if (!Array.isArray(body))
|
|
55
|
-
return errorHandler(new (0,
|
|
55
|
+
return errorHandler(new (0, _chunkH6NYBVBVjs.BadRequestException)("data format should be an array"));
|
|
56
56
|
try {
|
|
57
57
|
return Promise.all(body.map((item, i) => {
|
|
58
58
|
return new Promise(async (resolve) => {
|
|
59
59
|
const { tag, func } = item;
|
|
60
60
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
61
61
|
if (!metaMap.has(tag))
|
|
62
|
-
return resolve(await
|
|
62
|
+
return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
63
63
|
const meta2 = metaMap.get(tag)[func];
|
|
64
64
|
if (!meta2)
|
|
65
|
-
return resolve(await
|
|
65
|
+
return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
66
66
|
const { data: { params } } = meta2;
|
|
67
67
|
const contextData = {
|
|
68
68
|
type: "fastify",
|
|
@@ -75,9 +75,9 @@ function bind(fastify, data, opts = {}) {
|
|
|
75
75
|
tag,
|
|
76
76
|
func,
|
|
77
77
|
app: fastify3,
|
|
78
|
-
...
|
|
78
|
+
..._chunkH6NYBVBVjs.argToReq.call(void 0, params, item.args, req.headers)
|
|
79
79
|
};
|
|
80
|
-
const context = new (0,
|
|
80
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
|
|
81
81
|
context.run({
|
|
82
82
|
globalGuards,
|
|
83
83
|
globalInterceptors,
|
|
@@ -102,7 +102,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
102
102
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.type]))
|
|
103
103
|
continue;
|
|
104
104
|
fastify2.register((fastify3, _opts, done2) => {
|
|
105
|
-
|
|
105
|
+
_chunkH6NYBVBVjs.Context.usePlugin(plugins, "fastify").forEach((p) => {
|
|
106
106
|
p[Symbol.for("skip-override")] = true;
|
|
107
107
|
fastify3.register(p);
|
|
108
108
|
});
|
|
@@ -122,7 +122,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
122
122
|
headers: req.headers,
|
|
123
123
|
app: fastify3
|
|
124
124
|
};
|
|
125
|
-
const context = new (0,
|
|
125
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
|
|
126
126
|
if (http.headers) {
|
|
127
127
|
for (const name in http.headers)
|
|
128
128
|
res.header(name, http.headers[name]);
|
|
@@ -149,11 +149,11 @@ function bind(fastify, data, opts = {}) {
|
|
|
149
149
|
done();
|
|
150
150
|
}, fastifyOpts);
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
_chunkFNJWO324js.__name.call(void 0, bind, "bind");
|
|
153
153
|
function Fastify(opts) {
|
|
154
|
-
return
|
|
154
|
+
return _chunkAWY6FTH4js.Define.call(void 0, "fastify", opts);
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
_chunkFNJWO324js.__name.call(void 0, Fastify, "Fastify");
|
|
157
157
|
|
|
158
158
|
|
|
159
159
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-IJNA24EZ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
BadRequestException,
|
|
6
6
|
Context,
|
|
7
7
|
argToReq,
|
|
8
8
|
createControllerMetaMap,
|
|
9
9
|
detectAopDep
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-Q4AGVGVA.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-VYDBNZJ2.mjs";
|
|
14
14
|
|
|
15
15
|
// src/server/fastify/bind.ts
|
|
16
16
|
import Debug from "debug";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { H3Event, Router, _RequestMiddleware } from 'h3';
|
|
2
2
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
3
|
-
import { a as HttpContext, H as HttpOptions } from '../../types-
|
|
3
|
+
import { a as HttpContext, H as HttpOptions } from '../../types-0a76c4bc.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
5
|
import '../../types-81be0ba3.js';
|
|
6
6
|
import 'node:http';
|
package/dist/server/h3/index.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
|
|
11
11
|
|
|
12
12
|
// src/server/h3/bind.ts
|
|
13
13
|
var _h3 = require('h3');
|
|
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/h3");
|
|
|
16
16
|
function bind(router, data, opts = {}) {
|
|
17
17
|
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
|
-
const metaMap =
|
|
19
|
+
const metaMap = _chunkH6NYBVBVjs.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
|
+
_chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
plugins: [
|
|
28
28
|
...globalPlugins,
|
|
29
29
|
...parallelPlugins
|
|
@@ -35,7 +35,7 @@ function bind(router, data, opts = {}) {
|
|
|
35
35
|
async function registerRoute() {
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
router.post(parallelRoute, _h3.eventHandler.call(void 0, {
|
|
38
|
-
onRequest:
|
|
38
|
+
onRequest: _chunkH6NYBVBVjs.Context.usePlugin([
|
|
39
39
|
...globalPlugins,
|
|
40
40
|
...parallelPlugins
|
|
41
41
|
], "h3").map(_h3.defineRequestMiddleware),
|
|
@@ -44,23 +44,23 @@ function bind(router, data, opts = {}) {
|
|
|
44
44
|
strict: true
|
|
45
45
|
});
|
|
46
46
|
async function errorHandler(e) {
|
|
47
|
-
const error = await
|
|
47
|
+
const error = await _chunkH6NYBVBVjs.Context.filterRecord.default(e);
|
|
48
48
|
_h3.setResponseStatus.call(void 0, event, error.status);
|
|
49
49
|
return error;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
_chunkFNJWO324js.__name.call(void 0, errorHandler, "errorHandler");
|
|
52
52
|
if (!Array.isArray(body))
|
|
53
|
-
return errorHandler(new (0,
|
|
53
|
+
return errorHandler(new (0, _chunkH6NYBVBVjs.BadRequestException)("data format should be an array"));
|
|
54
54
|
try {
|
|
55
55
|
return Promise.all(body.map((item, i) => {
|
|
56
56
|
return new Promise(async (resolve) => {
|
|
57
57
|
const { tag, func } = item;
|
|
58
58
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
59
59
|
if (!metaMap.has(tag))
|
|
60
|
-
return resolve(await
|
|
60
|
+
return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
61
61
|
const meta2 = metaMap.get(tag)[func];
|
|
62
62
|
if (!meta2)
|
|
63
|
-
return resolve(await
|
|
63
|
+
return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
64
64
|
const { data: { params } } = meta2;
|
|
65
65
|
const contextData = {
|
|
66
66
|
type: "h3",
|
|
@@ -72,9 +72,9 @@ function bind(router, data, opts = {}) {
|
|
|
72
72
|
func,
|
|
73
73
|
parallel: true,
|
|
74
74
|
app: router,
|
|
75
|
-
...
|
|
75
|
+
..._chunkH6NYBVBVjs.argToReq.call(void 0, params, item.args, _h3.getRequestHeaders.call(void 0, event))
|
|
76
76
|
};
|
|
77
|
-
const context = new (0,
|
|
77
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
|
|
78
78
|
context.run({
|
|
79
79
|
globalGuards,
|
|
80
80
|
globalInterceptors,
|
|
@@ -97,7 +97,7 @@ function bind(router, data, opts = {}) {
|
|
|
97
97
|
continue;
|
|
98
98
|
const needBody = params.some((item) => item.type === "body");
|
|
99
99
|
router[http.type](http.prefix + http.route, _h3.eventHandler.call(void 0, {
|
|
100
|
-
onRequest:
|
|
100
|
+
onRequest: _chunkH6NYBVBVjs.Context.usePlugin([
|
|
101
101
|
...globalPlugins,
|
|
102
102
|
...plugins
|
|
103
103
|
], "h3").map(_h3.defineRequestMiddleware),
|
|
@@ -118,7 +118,7 @@ function bind(router, data, opts = {}) {
|
|
|
118
118
|
strict: true
|
|
119
119
|
}) : void 0
|
|
120
120
|
};
|
|
121
|
-
const context = new (0,
|
|
121
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
|
|
122
122
|
_h3.setHeaders.call(void 0, event, http.headers || {});
|
|
123
123
|
return context.run({
|
|
124
124
|
globalGuards,
|
|
@@ -134,9 +134,9 @@ function bind(router, data, opts = {}) {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
_chunkFNJWO324js.__name.call(void 0, registerRoute, "registerRoute");
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
_chunkFNJWO324js.__name.call(void 0, bind, "bind");
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
exports.bind = bind;
|
package/dist/server/h3/index.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-Q4AGVGVA.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-VYDBNZJ2.mjs";
|
|
11
11
|
|
|
12
12
|
// src/server/h3/bind.ts
|
|
13
13
|
import { defineRequestMiddleware, eventHandler, getQuery, getRequestHeaders, getRouterParams, readBody, setHeaders, setResponseStatus } from "h3";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, Hono, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { a as HttpContext, H as HttpOptions } from '../../types-
|
|
2
|
+
import { a as HttpContext, H as HttpOptions } from '../../types-0a76c4bc.js';
|
|
3
3
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../types-81be0ba3.js';
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
|
|
11
11
|
|
|
12
12
|
// src/server/hono/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/hono");
|
|
|
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 = _chunkH6NYBVBVjs.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
|
+
_chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
|
|
26
26
|
plugins: [
|
|
27
27
|
...globalPlugins,
|
|
28
28
|
...parallelPlugins
|
|
@@ -32,28 +32,28 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
async function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunkH6NYBVBVjs.Context.usePlugin(globalPlugins, "hono").forEach((p) => router.use(p));
|
|
36
36
|
if (parallelRoute) {
|
|
37
|
-
router.post(parallelRoute, ...
|
|
37
|
+
router.post(parallelRoute, ..._chunkH6NYBVBVjs.Context.usePlugin(parallelPlugins, "hono"), async (c) => {
|
|
38
38
|
const body = await c.req.json();
|
|
39
39
|
async function errorHandler(e) {
|
|
40
|
-
const error = await
|
|
40
|
+
const error = await _chunkH6NYBVBVjs.Context.filterRecord.default(e);
|
|
41
41
|
c.status(error.status);
|
|
42
42
|
return c.json(error);
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
_chunkFNJWO324js.__name.call(void 0, errorHandler, "errorHandler");
|
|
45
45
|
if (!Array.isArray(body))
|
|
46
|
-
return errorHandler(new (0,
|
|
46
|
+
return errorHandler(new (0, _chunkH6NYBVBVjs.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
52
|
if (!metaMap.has(tag))
|
|
53
|
-
return resolve(await
|
|
53
|
+
return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
54
54
|
const meta2 = metaMap.get(tag)[func];
|
|
55
55
|
if (!meta2)
|
|
56
|
-
return resolve(await
|
|
56
|
+
return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
57
57
|
const { data: { params } } = meta2;
|
|
58
58
|
const contextData = {
|
|
59
59
|
type: "hono",
|
|
@@ -65,9 +65,9 @@ function bind(router, data, opts = {}) {
|
|
|
65
65
|
tag,
|
|
66
66
|
func,
|
|
67
67
|
app: router,
|
|
68
|
-
...
|
|
68
|
+
..._chunkH6NYBVBVjs.argToReq.call(void 0, params, item.args, c.req.header())
|
|
69
69
|
};
|
|
70
|
-
const context = new (0,
|
|
70
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
|
|
71
71
|
context.run({
|
|
72
72
|
globalGuards,
|
|
73
73
|
globalInterceptors,
|
|
@@ -90,7 +90,7 @@ function bind(router, data, opts = {}) {
|
|
|
90
90
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
|
|
91
91
|
continue;
|
|
92
92
|
const needBody = params.some((item) => item.type === "body");
|
|
93
|
-
router[http.type](http.prefix + http.route, ...
|
|
93
|
+
router[http.type](http.prefix + http.route, ..._chunkH6NYBVBVjs.Context.usePlugin(plugins, "hono"), async (c) => {
|
|
94
94
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
95
95
|
const contextData = {
|
|
96
96
|
type: "hono",
|
|
@@ -105,7 +105,7 @@ function bind(router, data, opts = {}) {
|
|
|
105
105
|
headers: c.req.header(),
|
|
106
106
|
app: router
|
|
107
107
|
};
|
|
108
|
-
const context = new (0,
|
|
108
|
+
const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
|
|
109
109
|
if (http.headers) {
|
|
110
110
|
for (const name in http.headers)
|
|
111
111
|
c.header(name, http.headers[name]);
|
|
@@ -130,9 +130,9 @@ function bind(router, data, opts = {}) {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
_chunkFNJWO324js.__name.call(void 0, registerRoute, "registerRoute");
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
_chunkFNJWO324js.__name.call(void 0, bind, "bind");
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
exports.bind = bind;
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-Q4AGVGVA.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-VYDBNZJ2.mjs";
|
|
11
11
|
|
|
12
12
|
// src/server/hono/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { a as HttpContext, H as HttpOptions } from '../../types-
|
|
2
|
+
import { a as HttpContext, H as HttpOptions } from '../../types-0a76c4bc.js';
|
|
3
3
|
import { F as Factory } from '../../core-7f6d2be6.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../types-81be0ba3.js';
|