phecda-server 6.0.1 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-TZYATAJX.js → chunk-7SYPUIBY.js} +2 -5
- package/dist/{chunk-YUXERDQ6.mjs → chunk-WXFZZZRY.mjs} +8 -11
- package/dist/{core-Blq8frmr.d.ts → core-2SNw8m2B.d.mts} +1 -1
- package/dist/{core-D2oL8Ge0.d.mts → core-BmJJLUqj.d.ts} +1 -1
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +2 -2
- package/dist/helper.mjs +1 -1
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +24 -24
- package/dist/index.mjs +8 -8
- package/dist/{types-BlIBlnVT.d.mts → meta-KtfiBIde.d.mts} +44 -44
- package/dist/{types-BlIBlnVT.d.ts → meta-KtfiBIde.d.ts} +44 -44
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +6 -6
- package/dist/rpc/bullmq/index.mjs +1 -1
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +5 -5
- package/dist/rpc/kafka/index.mjs +1 -1
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +5 -5
- package/dist/rpc/nats/index.mjs +1 -1
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +6 -6
- package/dist/rpc/rabbitmq/index.mjs +1 -1
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +6 -6
- package/dist/rpc/redis/index.mjs +1 -1
- package/dist/server/elysia/index.d.mts +3 -3
- package/dist/server/elysia/index.d.ts +3 -3
- package/dist/server/elysia/index.js +27 -15
- package/dist/server/elysia/index.mjs +15 -3
- package/dist/server/express/index.d.mts +3 -3
- package/dist/server/express/index.d.ts +3 -3
- package/dist/server/express/index.js +20 -16
- package/dist/server/express/index.mjs +7 -3
- package/dist/server/fastify/index.d.mts +3 -3
- package/dist/server/fastify/index.d.ts +3 -3
- package/dist/server/fastify/index.js +19 -15
- package/dist/server/fastify/index.mjs +7 -3
- package/dist/server/h3/index.d.mts +3 -3
- package/dist/server/h3/index.d.ts +3 -3
- package/dist/server/h3/index.js +18 -14
- package/dist/server/h3/index.mjs +7 -3
- package/dist/server/hono/index.d.mts +3 -3
- package/dist/server/hono/index.d.ts +3 -3
- package/dist/server/hono/index.js +19 -15
- package/dist/server/hono/index.mjs +7 -3
- package/dist/server/hyper-express/index.d.mts +3 -3
- package/dist/server/hyper-express/index.d.ts +3 -3
- package/dist/server/hyper-express/index.js +19 -15
- package/dist/server/hyper-express/index.mjs +7 -3
- package/dist/server/koa/index.d.mts +3 -3
- package/dist/server/koa/index.d.ts +3 -3
- package/dist/server/koa/index.js +20 -16
- package/dist/server/koa/index.mjs +7 -3
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/{types-Dgxirc9f.d.mts → types-BvD3B5Ny.d.mts} +4 -2
- package/dist/{types-BCJhmpQh.d.ts → types-DIw7B6Up.d.ts} +4 -2
- package/dist/{types-B-ZFZajI.d.ts → types-JVT0mgLD.d.ts} +1 -1
- package/dist/{types-AgVwUXPC.d.mts → types-t9D1fU6G.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
7
|
detectAopDep
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-WXFZZZRY.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
11
|
} from "../../chunk-UXD62LGG.mjs";
|
|
@@ -77,7 +77,9 @@ function bind(router, data, opts = {}) {
|
|
|
77
77
|
}), "delCookie"),
|
|
78
78
|
redirect: /* @__PURE__ */ __name((url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
79
79
|
setResHeaders: /* @__PURE__ */ __name((headers) => res.set(headers), "setResHeaders"),
|
|
80
|
-
setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus")
|
|
80
|
+
setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus"),
|
|
81
|
+
getRequest: /* @__PURE__ */ __name(() => req, "getRequest"),
|
|
82
|
+
getResponse: /* @__PURE__ */ __name(() => res, "getResponse")
|
|
81
83
|
};
|
|
82
84
|
const context = new Context(contextData);
|
|
83
85
|
context.run({
|
|
@@ -123,7 +125,9 @@ function bind(router, data, opts = {}) {
|
|
|
123
125
|
}), "delCookie"),
|
|
124
126
|
redirect: /* @__PURE__ */ __name((url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
125
127
|
setResHeaders: /* @__PURE__ */ __name((headers) => res.set(headers), "setResHeaders"),
|
|
126
|
-
setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus")
|
|
128
|
+
setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus"),
|
|
129
|
+
getRequest: /* @__PURE__ */ __name(() => req, "getRequest"),
|
|
130
|
+
getResponse: /* @__PURE__ */ __name(() => res, "getResponse")
|
|
127
131
|
};
|
|
128
132
|
const context = new Context(contextData);
|
|
129
133
|
if (http.headers) res.set(http.headers);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-2SNw8m2B.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../
|
|
5
|
+
import '../../meta-KtfiBIde.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface FastifyCtx extends HttpContext {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
|
|
3
|
+
import { F as Factory } from '../../core-BmJJLUqj.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../
|
|
5
|
+
import '../../meta-KtfiBIde.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface FastifyCtx extends HttpContext {
|
|
@@ -7,7 +7,7 @@ var _chunkXCND2QW3js = require('../../chunk-XCND2QW3.js');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
@@ -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 = _chunk7SYPUIBYjs.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
|
+
_chunk7SYPUIBYjs.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
|
+
_chunk7SYPUIBYjs.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
|
+
_chunk7SYPUIBYjs.Context.usePlugin(parallelPlugins, "fastify").forEach((p) => {
|
|
43
43
|
p[Symbol.for("skip-override")] = true;
|
|
44
44
|
fastify3.register(p);
|
|
45
45
|
});
|
|
@@ -47,19 +47,19 @@ 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 _chunk7SYPUIBYjs.Context.filterRecord.default(e);
|
|
51
51
|
return res.status(error.status).send(error);
|
|
52
52
|
}
|
|
53
53
|
_chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
54
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
54
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk7SYPUIBYjs.BadRequestException)("data format should be an array"));
|
|
55
55
|
try {
|
|
56
56
|
return Promise.all(body.map((item, i) => {
|
|
57
57
|
return new Promise(async (resolve) => {
|
|
58
58
|
const { tag, func } = item;
|
|
59
59
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
60
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
60
|
+
if (!metaMap.has(tag)) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
61
61
|
const meta2 = metaMap.get(tag)[func];
|
|
62
|
-
if (!meta2) return resolve(await
|
|
62
|
+
if (!meta2) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
63
63
|
const { data: { params } } = meta2;
|
|
64
64
|
const contextData = {
|
|
65
65
|
type: "fastify",
|
|
@@ -72,7 +72,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
72
72
|
tag,
|
|
73
73
|
func,
|
|
74
74
|
app: fastify3,
|
|
75
|
-
...
|
|
75
|
+
..._chunk7SYPUIBYjs.argToReq.call(void 0, params, item.args, req.headers),
|
|
76
76
|
// @ts-expect-error need @fastify/cookie
|
|
77
77
|
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
78
78
|
// @ts-expect-error need @fastify/cookie
|
|
@@ -81,9 +81,11 @@ function bind(fastify, data, opts = {}) {
|
|
|
81
81
|
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
82
82
|
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
83
83
|
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
84
|
-
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
|
|
84
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
85
|
+
getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => req, "getRequest"),
|
|
86
|
+
getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => res, "getResponse")
|
|
85
87
|
};
|
|
86
|
-
const context = new (0,
|
|
88
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
|
|
87
89
|
context.run({
|
|
88
90
|
globalGuards,
|
|
89
91
|
globalInterceptors,
|
|
@@ -107,7 +109,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
107
109
|
const { data: { plugins, define, http } } = meta2;
|
|
108
110
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
|
|
109
111
|
fastify2.register((fastify3, _opts, done2) => {
|
|
110
|
-
|
|
112
|
+
_chunk7SYPUIBYjs.Context.usePlugin(plugins, "fastify").forEach((p) => {
|
|
111
113
|
p[Symbol.for("skip-override")] = true;
|
|
112
114
|
fastify3.register(p);
|
|
113
115
|
});
|
|
@@ -136,9 +138,11 @@ function bind(fastify, data, opts = {}) {
|
|
|
136
138
|
}), "delCookie"),
|
|
137
139
|
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
138
140
|
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
139
|
-
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
|
|
141
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
142
|
+
getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => req, "getRequest"),
|
|
143
|
+
getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => res, "getResponse")
|
|
140
144
|
};
|
|
141
|
-
const context = new (0,
|
|
145
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
|
|
142
146
|
if (http.headers) res.headers(http.headers);
|
|
143
147
|
return context.run({
|
|
144
148
|
globalGuards,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
argToReq,
|
|
8
8
|
createControllerMetaMap,
|
|
9
9
|
detectAopDep
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-WXFZZZRY.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
13
|
} from "../../chunk-UXD62LGG.mjs";
|
|
@@ -81,7 +81,9 @@ function bind(fastify, data, opts = {}) {
|
|
|
81
81
|
delCookie: /* @__PURE__ */ __name((key) => res.clearCookie(key), "delCookie"),
|
|
82
82
|
redirect: /* @__PURE__ */ __name((url, status) => res.redirect(url, status), "redirect"),
|
|
83
83
|
setResHeaders: /* @__PURE__ */ __name((headers) => res.headers(headers), "setResHeaders"),
|
|
84
|
-
setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus")
|
|
84
|
+
setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus"),
|
|
85
|
+
getRequest: /* @__PURE__ */ __name(() => req, "getRequest"),
|
|
86
|
+
getResponse: /* @__PURE__ */ __name(() => res, "getResponse")
|
|
85
87
|
};
|
|
86
88
|
const context = new Context(contextData);
|
|
87
89
|
context.run({
|
|
@@ -136,7 +138,9 @@ function bind(fastify, data, opts = {}) {
|
|
|
136
138
|
}), "delCookie"),
|
|
137
139
|
redirect: /* @__PURE__ */ __name((url, status) => res.redirect(url, status), "redirect"),
|
|
138
140
|
setResHeaders: /* @__PURE__ */ __name((headers) => res.headers(headers), "setResHeaders"),
|
|
139
|
-
setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus")
|
|
141
|
+
setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus"),
|
|
142
|
+
getRequest: /* @__PURE__ */ __name(() => req, "getRequest"),
|
|
143
|
+
getResponse: /* @__PURE__ */ __name(() => res, "getResponse")
|
|
140
144
|
};
|
|
141
145
|
const context = new Context(contextData);
|
|
142
146
|
if (http.headers) res.headers(http.headers);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { H3Event, Router, _RequestMiddleware } from 'h3';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-2SNw8m2B.mjs';
|
|
3
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../
|
|
5
|
+
import '../../meta-KtfiBIde.mjs';
|
|
6
6
|
import 'node:http';
|
|
7
7
|
|
|
8
8
|
interface H3Ctx extends HttpContext {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { H3Event, Router, _RequestMiddleware } from 'h3';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-BmJJLUqj.js';
|
|
3
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../
|
|
5
|
+
import '../../meta-KtfiBIde.js';
|
|
6
6
|
import 'node:http';
|
|
7
7
|
|
|
8
8
|
interface H3Ctx extends HttpContext {
|
package/dist/server/h3/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.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, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
|
-
const metaMap =
|
|
19
|
+
const metaMap = _chunk7SYPUIBYjs.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
|
+
_chunk7SYPUIBYjs.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: _chunk7SYPUIBYjs.Context.usePlugin([
|
|
39
39
|
...globalPlugins,
|
|
40
40
|
...parallelPlugins
|
|
41
41
|
], "h3").map(_h3.defineRequestMiddleware),
|
|
@@ -44,20 +44,20 @@ 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 _chunk7SYPUIBYjs.Context.filterRecord.default(e);
|
|
48
48
|
_h3.setResponseStatus.call(void 0, event, error.status);
|
|
49
49
|
return error;
|
|
50
50
|
}
|
|
51
51
|
_chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
52
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
52
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk7SYPUIBYjs.BadRequestException)("data format should be an array"));
|
|
53
53
|
try {
|
|
54
54
|
return Promise.all(body.map((item, i) => {
|
|
55
55
|
return new Promise(async (resolve) => {
|
|
56
56
|
const { tag, func } = item;
|
|
57
57
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
58
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
58
|
+
if (!metaMap.has(tag)) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
59
59
|
const meta2 = metaMap.get(tag)[func];
|
|
60
|
-
if (!meta2) return resolve(await
|
|
60
|
+
if (!meta2) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
61
61
|
const { data: { params } } = meta2;
|
|
62
62
|
const contextData = {
|
|
63
63
|
type: "h3",
|
|
@@ -69,15 +69,17 @@ function bind(router, data, opts = {}) {
|
|
|
69
69
|
func,
|
|
70
70
|
parallel: true,
|
|
71
71
|
app: router,
|
|
72
|
-
...
|
|
72
|
+
..._chunk7SYPUIBYjs.argToReq.call(void 0, params, item.args, _h3.getRequestHeaders.call(void 0, event)),
|
|
73
73
|
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
74
74
|
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
75
75
|
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
76
76
|
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url, status) => _h3.sendRedirect.call(void 0, event, url, status), "redirect"),
|
|
77
77
|
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
78
|
-
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus")
|
|
78
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
79
|
+
getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
80
|
+
getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
79
81
|
};
|
|
80
|
-
const context = new (0,
|
|
82
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
|
|
81
83
|
context.run({
|
|
82
84
|
globalGuards,
|
|
83
85
|
globalInterceptors,
|
|
@@ -99,7 +101,7 @@ function bind(router, data, opts = {}) {
|
|
|
99
101
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
100
102
|
const needBody = params.some((item) => item.type === "body");
|
|
101
103
|
router[http.type](http.prefix + http.route, _h3.eventHandler.call(void 0, {
|
|
102
|
-
onRequest:
|
|
104
|
+
onRequest: _chunk7SYPUIBYjs.Context.usePlugin([
|
|
103
105
|
...globalPlugins,
|
|
104
106
|
...plugins
|
|
105
107
|
], "h3").map(_h3.defineRequestMiddleware),
|
|
@@ -124,9 +126,11 @@ function bind(router, data, opts = {}) {
|
|
|
124
126
|
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => _h3.sendRedirect.call(void 0, event, url), "redirect"),
|
|
125
127
|
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
126
128
|
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
127
|
-
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie")
|
|
129
|
+
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
130
|
+
getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
131
|
+
getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
128
132
|
};
|
|
129
|
-
const context = new (0,
|
|
133
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
|
|
130
134
|
_h3.setHeaders.call(void 0, event, http.headers || {});
|
|
131
135
|
return context.run({
|
|
132
136
|
globalGuards,
|
package/dist/server/h3/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-WXFZZZRY.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
10
|
} from "../../chunk-UXD62LGG.mjs";
|
|
@@ -75,7 +75,9 @@ function bind(router, data, opts = {}) {
|
|
|
75
75
|
delCookie: /* @__PURE__ */ __name((key) => deleteCookie(event, key), "delCookie"),
|
|
76
76
|
redirect: /* @__PURE__ */ __name((url, status) => sendRedirect(event, url, status), "redirect"),
|
|
77
77
|
setResHeaders: /* @__PURE__ */ __name((headers) => setResponseHeaders(event, headers), "setResHeaders"),
|
|
78
|
-
setResStatus: /* @__PURE__ */ __name((code) => setResponseStatus(event, code), "setResStatus")
|
|
78
|
+
setResStatus: /* @__PURE__ */ __name((code) => setResponseStatus(event, code), "setResStatus"),
|
|
79
|
+
getRequest: /* @__PURE__ */ __name(() => event.node.req, "getRequest"),
|
|
80
|
+
getResponse: /* @__PURE__ */ __name(() => event.node.res, "getResponse")
|
|
79
81
|
};
|
|
80
82
|
const context = new Context(contextData);
|
|
81
83
|
context.run({
|
|
@@ -124,7 +126,9 @@ function bind(router, data, opts = {}) {
|
|
|
124
126
|
redirect: /* @__PURE__ */ __name((url) => sendRedirect(event, url), "redirect"),
|
|
125
127
|
setResHeaders: /* @__PURE__ */ __name((headers) => setResponseHeaders(event, headers), "setResHeaders"),
|
|
126
128
|
setResStatus: /* @__PURE__ */ __name((code) => setResponseStatus(event, code), "setResStatus"),
|
|
127
|
-
delCookie: /* @__PURE__ */ __name((key) => deleteCookie(event, key), "delCookie")
|
|
129
|
+
delCookie: /* @__PURE__ */ __name((key) => deleteCookie(event, key), "delCookie"),
|
|
130
|
+
getRequest: /* @__PURE__ */ __name(() => event.node.req, "getRequest"),
|
|
131
|
+
getResponse: /* @__PURE__ */ __name(() => event.node.res, "getResponse")
|
|
128
132
|
};
|
|
129
133
|
const context = new Context(contextData);
|
|
130
134
|
setHeaders(event, http.headers || {});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context, Hono, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-2SNw8m2B.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../
|
|
5
|
+
import '../../meta-KtfiBIde.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HonoCtx extends HttpContext {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context, Hono, MiddlewareHandler } from 'hono';
|
|
2
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
|
|
3
|
+
import { F as Factory } from '../../core-BmJJLUqj.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../
|
|
5
|
+
import '../../meta-KtfiBIde.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HonoCtx extends HttpContext {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.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, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
|
-
const metaMap =
|
|
19
|
+
const metaMap = _chunk7SYPUIBYjs.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
|
+
_chunk7SYPUIBYjs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
plugins: [
|
|
28
28
|
...globalPlugins,
|
|
29
29
|
...parallelPlugins
|
|
@@ -33,25 +33,25 @@ function bind(router, data, opts = {}) {
|
|
|
33
33
|
});
|
|
34
34
|
registerRoute();
|
|
35
35
|
async function registerRoute() {
|
|
36
|
-
|
|
36
|
+
_chunk7SYPUIBYjs.Context.usePlugin(globalPlugins, "hono").forEach((p) => router.use(p));
|
|
37
37
|
if (parallelRoute) {
|
|
38
|
-
router.post(parallelRoute, ...
|
|
38
|
+
router.post(parallelRoute, ..._chunk7SYPUIBYjs.Context.usePlugin(parallelPlugins, "hono"), async (c) => {
|
|
39
39
|
const body = await c.req.json();
|
|
40
40
|
async function errorHandler(e) {
|
|
41
|
-
const error = await
|
|
41
|
+
const error = await _chunk7SYPUIBYjs.Context.filterRecord.default(e);
|
|
42
42
|
c.status(error.status);
|
|
43
43
|
return c.json(error);
|
|
44
44
|
}
|
|
45
45
|
_chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk7SYPUIBYjs.BadRequestException)("data format should be an array"));
|
|
47
47
|
try {
|
|
48
48
|
return Promise.all(body.map((item, i) => {
|
|
49
49
|
return new Promise(async (resolve) => {
|
|
50
50
|
const { tag, func } = item;
|
|
51
51
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
52
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
52
|
+
if (!metaMap.has(tag)) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
53
53
|
const meta2 = metaMap.get(tag)[func];
|
|
54
|
-
if (!meta2) return resolve(await
|
|
54
|
+
if (!meta2) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
55
55
|
const { data: { params } } = meta2;
|
|
56
56
|
const contextData = {
|
|
57
57
|
type: "hono",
|
|
@@ -63,7 +63,7 @@ function bind(router, data, opts = {}) {
|
|
|
63
63
|
tag,
|
|
64
64
|
func,
|
|
65
65
|
app: router,
|
|
66
|
-
...
|
|
66
|
+
..._chunk7SYPUIBYjs.argToReq.call(void 0, params, item.args, c.req.header()),
|
|
67
67
|
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
|
|
68
68
|
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
|
|
69
69
|
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
|
|
@@ -71,9 +71,11 @@ function bind(router, data, opts = {}) {
|
|
|
71
71
|
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => {
|
|
72
72
|
for (const name in headers) c.header(name, headers[name]);
|
|
73
73
|
}, "setResHeaders"),
|
|
74
|
-
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.status(status), "setResStatus")
|
|
74
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
75
|
+
getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
76
|
+
getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => c.res, "getResponse")
|
|
75
77
|
};
|
|
76
|
-
const context = new (0,
|
|
78
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
|
|
77
79
|
context.run({
|
|
78
80
|
globalGuards,
|
|
79
81
|
globalInterceptors,
|
|
@@ -95,7 +97,7 @@ function bind(router, data, opts = {}) {
|
|
|
95
97
|
const { data: { params, plugins, http } } = meta2;
|
|
96
98
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
97
99
|
const needBody = params.some((item) => item.type === "body");
|
|
98
|
-
router[http.type](http.prefix + http.route, ...
|
|
100
|
+
router[http.type](http.prefix + http.route, ..._chunk7SYPUIBYjs.Context.usePlugin(plugins, "hono"), async (c) => {
|
|
99
101
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
100
102
|
const contextData = {
|
|
101
103
|
type: "hono",
|
|
@@ -116,9 +118,11 @@ function bind(router, data, opts = {}) {
|
|
|
116
118
|
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => {
|
|
117
119
|
for (const name in headers) c.header(name, headers[name]);
|
|
118
120
|
}, "setResHeaders"),
|
|
119
|
-
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.status(status), "setResStatus")
|
|
121
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
|
|
122
|
+
getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => c.req.raw, "getRequest"),
|
|
123
|
+
getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => c.res, "getResponse")
|
|
120
124
|
};
|
|
121
|
-
const context = new (0,
|
|
125
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
|
|
122
126
|
if (http.headers) {
|
|
123
127
|
for (const name in http.headers) c.header(name, http.headers[name]);
|
|
124
128
|
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-WXFZZZRY.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
10
|
} from "../../chunk-UXD62LGG.mjs";
|
|
@@ -71,7 +71,9 @@ function bind(router, data, opts = {}) {
|
|
|
71
71
|
setResHeaders: /* @__PURE__ */ __name((headers) => {
|
|
72
72
|
for (const name in headers) c.header(name, headers[name]);
|
|
73
73
|
}, "setResHeaders"),
|
|
74
|
-
setResStatus: /* @__PURE__ */ __name((status) => c.status(status), "setResStatus")
|
|
74
|
+
setResStatus: /* @__PURE__ */ __name((status) => c.status(status), "setResStatus"),
|
|
75
|
+
getRequest: /* @__PURE__ */ __name(() => c.req.raw, "getRequest"),
|
|
76
|
+
getResponse: /* @__PURE__ */ __name(() => c.res, "getResponse")
|
|
75
77
|
};
|
|
76
78
|
const context = new Context(contextData);
|
|
77
79
|
context.run({
|
|
@@ -116,7 +118,9 @@ function bind(router, data, opts = {}) {
|
|
|
116
118
|
setResHeaders: /* @__PURE__ */ __name((headers) => {
|
|
117
119
|
for (const name in headers) c.header(name, headers[name]);
|
|
118
120
|
}, "setResHeaders"),
|
|
119
|
-
setResStatus: /* @__PURE__ */ __name((status) => c.status(status), "setResStatus")
|
|
121
|
+
setResStatus: /* @__PURE__ */ __name((status) => c.status(status), "setResStatus"),
|
|
122
|
+
getRequest: /* @__PURE__ */ __name(() => c.req.raw, "getRequest"),
|
|
123
|
+
getResponse: /* @__PURE__ */ __name(() => c.res, "getResponse")
|
|
120
124
|
};
|
|
121
125
|
const context = new Context(contextData);
|
|
122
126
|
if (http.headers) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-2SNw8m2B.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../
|
|
5
|
+
import '../../meta-KtfiBIde.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HyperExpressCtx extends HttpContext {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
|
|
2
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
|
|
3
|
+
import { F as Factory } from '../../core-BmJJLUqj.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../
|
|
5
|
+
import '../../meta-KtfiBIde.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface HyperExpressCtx extends HttpContext {
|