phecda-server 6.0.2 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-WXFZZZRY.mjs → chunk-2CFYUXPM.mjs} +1 -1
- package/dist/{chunk-HDQAT2IM.mjs → chunk-3H3T54IC.mjs} +116 -87
- package/dist/{chunk-7SYPUIBY.js → chunk-DVTBLV6I.js} +60 -60
- package/dist/{chunk-UXD62LGG.mjs → chunk-G7TD2VB7.mjs} +10 -2
- package/dist/{chunk-F3W3NN7F.mjs → chunk-J7B24YSE.mjs} +1 -1
- package/dist/{chunk-XCND2QW3.js → chunk-JDV2XJYE.js} +25 -25
- package/dist/chunk-NL6QBQAR.js +266 -0
- package/dist/{chunk-GHFSIZUO.js → chunk-TVT62GIX.js} +11 -3
- package/dist/core-BlN0Spy9.d.ts +47 -0
- package/dist/core-P1CsH6jz.d.mts +47 -0
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +49 -43
- package/dist/index.mjs +15 -9
- package/dist/rpc/bullmq/index.d.mts +1 -1
- package/dist/rpc/bullmq/index.d.ts +1 -1
- package/dist/rpc/bullmq/index.js +12 -12
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.d.mts +1 -1
- package/dist/rpc/kafka/index.d.ts +1 -1
- package/dist/rpc/kafka/index.js +12 -12
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +1 -1
- package/dist/rpc/nats/index.d.ts +1 -1
- package/dist/rpc/nats/index.js +11 -11
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.d.mts +1 -1
- package/dist/rpc/rabbitmq/index.d.ts +1 -1
- package/dist/rpc/rabbitmq/index.js +13 -13
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.d.mts +1 -1
- package/dist/rpc/redis/index.d.ts +1 -1
- package/dist/rpc/redis/index.js +11 -11
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/server/elysia/index.d.mts +1 -1
- package/dist/server/elysia/index.d.ts +1 -1
- package/dist/server/elysia/index.js +36 -36
- package/dist/server/elysia/index.mjs +3 -3
- package/dist/server/express/index.d.mts +1 -1
- package/dist/server/express/index.d.ts +1 -1
- package/dist/server/express/index.js +34 -34
- package/dist/server/express/index.mjs +2 -2
- package/dist/server/fastify/index.d.mts +1 -1
- package/dist/server/fastify/index.d.ts +1 -1
- package/dist/server/fastify/index.js +35 -35
- package/dist/server/fastify/index.mjs +3 -3
- package/dist/server/h3/index.d.mts +1 -1
- package/dist/server/h3/index.d.ts +1 -1
- package/dist/server/h3/index.js +34 -34
- package/dist/server/h3/index.mjs +2 -2
- package/dist/server/hono/index.d.mts +1 -1
- package/dist/server/hono/index.d.ts +1 -1
- package/dist/server/hono/index.js +33 -33
- package/dist/server/hono/index.mjs +2 -2
- package/dist/server/hyper-express/index.d.mts +1 -1
- package/dist/server/hyper-express/index.d.ts +1 -1
- package/dist/server/hyper-express/index.js +33 -33
- package/dist/server/hyper-express/index.mjs +2 -2
- package/dist/server/koa/index.d.mts +1 -1
- package/dist/server/koa/index.d.ts +1 -1
- package/dist/server/koa/index.js +34 -34
- package/dist/server/koa/index.mjs +2 -2
- package/dist/test.d.mts +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/package.json +2 -2
- package/dist/chunk-LYEZ6RGX.js +0 -237
- package/dist/core-2SNw8m2B.d.mts +0 -30
- package/dist/core-BmJJLUqj.d.ts +0 -30
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkDVTBLV6Ijs = require('../../chunk-DVTBLV6I.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkTVT62GIXjs = require('../../chunk-TVT62GIX.js');
|
|
12
12
|
|
|
13
13
|
// src/server/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 = _chunkDVTBLV6Ijs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
21
21
|
const { controller, http, func, tag } = meta2.data;
|
|
22
22
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
23
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
_chunkDVTBLV6Ijs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
plugins: [
|
|
29
29
|
...globalPlugins,
|
|
30
30
|
...parallelPlugins
|
|
@@ -33,29 +33,29 @@ function bind(router, data, opts = {}) {
|
|
|
33
33
|
interceptors: globalInterceptors
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
|
-
|
|
36
|
+
_chunkDVTBLV6Ijs.HMR.call(void 0, async () => {
|
|
37
37
|
router.stack = originStack;
|
|
38
38
|
registerRoute();
|
|
39
39
|
});
|
|
40
40
|
async function registerRoute() {
|
|
41
|
-
|
|
41
|
+
_chunkDVTBLV6Ijs.Context.usePlugin(globalPlugins, "express").forEach((p) => router.use(p));
|
|
42
42
|
if (parallelRoute) {
|
|
43
|
-
router.post(parallelRoute, ...
|
|
43
|
+
router.post(parallelRoute, ..._chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.Context.filterRecord.default(e);
|
|
47
47
|
return res.status(error.status).json(error);
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
49
|
+
_chunkTVT62GIXjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkDVTBLV6Ijs.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
54
|
const { tag, func } = item;
|
|
55
55
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
56
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
56
|
+
if (!metaMap.has(tag)) return resolve(await _chunkDVTBLV6Ijs.Context.filterRecord.default(new (0, _chunkDVTBLV6Ijs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
57
57
|
const meta2 = metaMap.get(tag)[func];
|
|
58
|
-
if (!meta2) return resolve(await
|
|
58
|
+
if (!meta2) return resolve(await _chunkDVTBLV6Ijs.Context.filterRecord.default(new (0, _chunkDVTBLV6Ijs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
59
|
const { data: { params } } = meta2;
|
|
60
60
|
const contextData = {
|
|
61
61
|
type: "express",
|
|
@@ -69,19 +69,19 @@ function bind(router, data, opts = {}) {
|
|
|
69
69
|
func,
|
|
70
70
|
next,
|
|
71
71
|
app: router,
|
|
72
|
-
...
|
|
73
|
-
getCookie: /* @__PURE__ */
|
|
74
|
-
setCookie: /* @__PURE__ */
|
|
75
|
-
delCookie: /* @__PURE__ */
|
|
72
|
+
..._chunkDVTBLV6Ijs.argToReq.call(void 0, params, item.args, req.headers),
|
|
73
|
+
getCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
74
|
+
setCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
|
|
75
|
+
delCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => res.cookie(key, "", {
|
|
76
76
|
expires: /* @__PURE__ */ new Date(0)
|
|
77
77
|
}), "delCookie"),
|
|
78
|
-
redirect: /* @__PURE__ */
|
|
79
|
-
setResHeaders: /* @__PURE__ */
|
|
80
|
-
setResStatus: /* @__PURE__ */
|
|
81
|
-
getRequest: /* @__PURE__ */
|
|
82
|
-
getResponse: /* @__PURE__ */
|
|
78
|
+
redirect: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
79
|
+
setResHeaders: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
80
|
+
setResStatus: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
81
|
+
getRequest: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => req, "getRequest"),
|
|
82
|
+
getResponse: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => res, "getResponse")
|
|
83
83
|
};
|
|
84
|
-
const context = new (0,
|
|
84
|
+
const context = new (0, _chunkDVTBLV6Ijs.Context)(contextData);
|
|
85
85
|
context.run({
|
|
86
86
|
globalGuards,
|
|
87
87
|
globalInterceptors,
|
|
@@ -102,7 +102,7 @@ function bind(router, data, opts = {}) {
|
|
|
102
102
|
const meta2 = metaMap.get(tag)[func];
|
|
103
103
|
const { data: { plugins, http } } = meta2;
|
|
104
104
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
105
|
-
router[http.type](http.prefix + http.route, ...
|
|
105
|
+
router[http.type](http.prefix + http.route, ..._chunkDVTBLV6Ijs.Context.usePlugin(plugins, "express"), async (req, res, next) => {
|
|
106
106
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
107
107
|
const contextData = {
|
|
108
108
|
type: "express",
|
|
@@ -118,18 +118,18 @@ function bind(router, data, opts = {}) {
|
|
|
118
118
|
headers: req.headers,
|
|
119
119
|
app: router,
|
|
120
120
|
next,
|
|
121
|
-
getCookie: /* @__PURE__ */
|
|
122
|
-
setCookie: /* @__PURE__ */
|
|
123
|
-
delCookie: /* @__PURE__ */
|
|
121
|
+
getCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
122
|
+
setCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
|
|
123
|
+
delCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => res.cookie(key, "", {
|
|
124
124
|
expires: /* @__PURE__ */ new Date(0)
|
|
125
125
|
}), "delCookie"),
|
|
126
|
-
redirect: /* @__PURE__ */
|
|
127
|
-
setResHeaders: /* @__PURE__ */
|
|
128
|
-
setResStatus: /* @__PURE__ */
|
|
129
|
-
getRequest: /* @__PURE__ */
|
|
130
|
-
getResponse: /* @__PURE__ */
|
|
126
|
+
redirect: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
127
|
+
setResHeaders: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
128
|
+
setResStatus: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
129
|
+
getRequest: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => req, "getRequest"),
|
|
130
|
+
getResponse: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => res, "getResponse")
|
|
131
131
|
};
|
|
132
|
-
const context = new (0,
|
|
132
|
+
const context = new (0, _chunkDVTBLV6Ijs.Context)(contextData);
|
|
133
133
|
if (http.headers) res.set(http.headers);
|
|
134
134
|
await context.run({
|
|
135
135
|
globalGuards,
|
|
@@ -148,9 +148,9 @@ function bind(router, data, opts = {}) {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
_chunkTVT62GIXjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
_chunkTVT62GIXjs.__name.call(void 0, bind, "bind");
|
|
154
154
|
|
|
155
155
|
|
|
156
156
|
exports.bind = bind;
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
7
|
detectAopDep
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-2CFYUXPM.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-G7TD2VB7.mjs";
|
|
12
12
|
|
|
13
13
|
// src/server/express/bind.ts
|
|
14
14
|
import Debug from "debug";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
2
|
import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { F as Factory } from '../../core-P1CsH6jz.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../meta-KtfiBIde.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
2
|
import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { F as Factory } from '../../core-BlN0Spy9.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../meta-KtfiBIde.js';
|
|
6
6
|
import 'phecda-core';
|
|
@@ -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 _chunkJDV2XJYEjs = require('../../chunk-JDV2XJYE.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkDVTBLV6Ijs = require('../../chunk-DVTBLV6I.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkTVT62GIXjs = require('../../chunk-TVT62GIX.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 = _chunkDVTBLV6Ijs.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
|
+
_chunkDVTBLV6Ijs.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
|
+
_chunkDVTBLV6Ijs.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
|
+
_chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.Context.filterRecord.default(e);
|
|
51
51
|
return res.status(error.status).send(error);
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
53
|
+
_chunkTVT62GIXjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
54
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.Context.filterRecord.default(new (0, _chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.Context.filterRecord.default(new (0, _chunkDVTBLV6Ijs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
63
63
|
const { data: { params } } = meta2;
|
|
64
64
|
const contextData = {
|
|
65
65
|
type: "fastify",
|
|
@@ -72,20 +72,20 @@ function bind(fastify, data, opts = {}) {
|
|
|
72
72
|
tag,
|
|
73
73
|
func,
|
|
74
74
|
app: fastify3,
|
|
75
|
-
...
|
|
75
|
+
..._chunkDVTBLV6Ijs.argToReq.call(void 0, params, item.args, req.headers),
|
|
76
76
|
// @ts-expect-error need @fastify/cookie
|
|
77
|
-
getCookie: /* @__PURE__ */
|
|
77
|
+
getCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
78
78
|
// @ts-expect-error need @fastify/cookie
|
|
79
|
-
setCookie: /* @__PURE__ */
|
|
79
|
+
setCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
80
80
|
// @ts-expect-error need @fastify/cookie
|
|
81
|
-
delCookie: /* @__PURE__ */
|
|
82
|
-
redirect: /* @__PURE__ */
|
|
83
|
-
setResHeaders: /* @__PURE__ */
|
|
84
|
-
setResStatus: /* @__PURE__ */
|
|
85
|
-
getRequest: /* @__PURE__ */
|
|
86
|
-
getResponse: /* @__PURE__ */
|
|
81
|
+
delCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
82
|
+
redirect: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
83
|
+
setResHeaders: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
84
|
+
setResStatus: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
85
|
+
getRequest: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => req, "getRequest"),
|
|
86
|
+
getResponse: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => res, "getResponse")
|
|
87
87
|
};
|
|
88
|
-
const context = new (0,
|
|
88
|
+
const context = new (0, _chunkDVTBLV6Ijs.Context)(contextData);
|
|
89
89
|
context.run({
|
|
90
90
|
globalGuards,
|
|
91
91
|
globalInterceptors,
|
|
@@ -109,7 +109,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
109
109
|
const { data: { plugins, define, http } } = meta2;
|
|
110
110
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
|
|
111
111
|
fastify2.register((fastify3, _opts, done2) => {
|
|
112
|
-
|
|
112
|
+
_chunkDVTBLV6Ijs.Context.usePlugin(plugins, "fastify").forEach((p) => {
|
|
113
113
|
p[Symbol.for("skip-override")] = true;
|
|
114
114
|
fastify3.register(p);
|
|
115
115
|
});
|
|
@@ -129,20 +129,20 @@ function bind(fastify, data, opts = {}) {
|
|
|
129
129
|
headers: req.headers,
|
|
130
130
|
app: fastify3,
|
|
131
131
|
// @ts-expect-error need @fastify/cookie
|
|
132
|
-
getCookie: /* @__PURE__ */
|
|
132
|
+
getCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
133
133
|
// @ts-expect-error need @fastify/cookie
|
|
134
|
-
setCookie: /* @__PURE__ */
|
|
134
|
+
setCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
135
135
|
// @ts-expect-error need @fastify/cookie
|
|
136
|
-
delCookie: /* @__PURE__ */
|
|
136
|
+
delCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => res.clearCookie(key, {
|
|
137
137
|
path: ""
|
|
138
138
|
}), "delCookie"),
|
|
139
|
-
redirect: /* @__PURE__ */
|
|
140
|
-
setResHeaders: /* @__PURE__ */
|
|
141
|
-
setResStatus: /* @__PURE__ */
|
|
142
|
-
getRequest: /* @__PURE__ */
|
|
143
|
-
getResponse: /* @__PURE__ */
|
|
139
|
+
redirect: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
140
|
+
setResHeaders: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
141
|
+
setResStatus: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
142
|
+
getRequest: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => req, "getRequest"),
|
|
143
|
+
getResponse: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => res, "getResponse")
|
|
144
144
|
};
|
|
145
|
-
const context = new (0,
|
|
145
|
+
const context = new (0, _chunkDVTBLV6Ijs.Context)(contextData);
|
|
146
146
|
if (http.headers) res.headers(http.headers);
|
|
147
147
|
return context.run({
|
|
148
148
|
globalGuards,
|
|
@@ -164,11 +164,11 @@ function bind(fastify, data, opts = {}) {
|
|
|
164
164
|
done();
|
|
165
165
|
}, fastifyOpts);
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
_chunkTVT62GIXjs.__name.call(void 0, bind, "bind");
|
|
168
168
|
function Fastify(opts) {
|
|
169
|
-
return
|
|
169
|
+
return _chunkJDV2XJYEjs.Define.call(void 0, "fastify", opts);
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
_chunkTVT62GIXjs.__name.call(void 0, Fastify, "Fastify");
|
|
172
172
|
|
|
173
173
|
|
|
174
174
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-J7B24YSE.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-2CFYUXPM.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-G7TD2VB7.mjs";
|
|
14
14
|
|
|
15
15
|
// src/server/fastify/bind.ts
|
|
16
16
|
import Debug from "debug";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { H3Event, Router, _RequestMiddleware } from 'h3';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { F as Factory } from '../../core-P1CsH6jz.mjs';
|
|
3
3
|
import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
|
|
4
4
|
import 'phecda-core';
|
|
5
5
|
import '../../meta-KtfiBIde.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { H3Event, Router, _RequestMiddleware } from 'h3';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { F as Factory } from '../../core-BlN0Spy9.js';
|
|
3
3
|
import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
5
|
import '../../meta-KtfiBIde.js';
|
package/dist/server/h3/index.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkDVTBLV6Ijs = require('../../chunk-DVTBLV6I.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkTVT62GIXjs = require('../../chunk-TVT62GIX.js');
|
|
11
11
|
|
|
12
12
|
// src/server/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 = _chunkDVTBLV6Ijs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
20
20
|
const { controller, http, func, tag } = meta2.data;
|
|
21
21
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
22
22
|
debug(`register method "${func}" in module "${tag}"`);
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
_chunkDVTBLV6Ijs.detectAopDep.call(void 0, meta, {
|
|
27
27
|
plugins: [
|
|
28
28
|
...globalPlugins,
|
|
29
29
|
...parallelPlugins
|
|
@@ -35,29 +35,29 @@ 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: _chunkDVTBLV6Ijs.Context.usePlugin([
|
|
39
39
|
...globalPlugins,
|
|
40
40
|
...parallelPlugins
|
|
41
41
|
], "h3").map(_h3.defineRequestMiddleware),
|
|
42
|
-
handler: /* @__PURE__ */
|
|
42
|
+
handler: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, async (event) => {
|
|
43
43
|
const body = await _h3.readBody.call(void 0, event, {
|
|
44
44
|
strict: true
|
|
45
45
|
});
|
|
46
46
|
async function errorHandler(e) {
|
|
47
|
-
const error = await
|
|
47
|
+
const error = await _chunkDVTBLV6Ijs.Context.filterRecord.default(e);
|
|
48
48
|
_h3.setResponseStatus.call(void 0, event, error.status);
|
|
49
49
|
return error;
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
51
|
+
_chunkTVT62GIXjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
52
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.Context.filterRecord.default(new (0, _chunkDVTBLV6Ijs.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 _chunkDVTBLV6Ijs.Context.filterRecord.default(new (0, _chunkDVTBLV6Ijs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
61
61
|
const { data: { params } } = meta2;
|
|
62
62
|
const contextData = {
|
|
63
63
|
type: "h3",
|
|
@@ -69,17 +69,17 @@ function bind(router, data, opts = {}) {
|
|
|
69
69
|
func,
|
|
70
70
|
parallel: true,
|
|
71
71
|
app: router,
|
|
72
|
-
...
|
|
73
|
-
getCookie: /* @__PURE__ */
|
|
74
|
-
setCookie: /* @__PURE__ */
|
|
75
|
-
delCookie: /* @__PURE__ */
|
|
76
|
-
redirect: /* @__PURE__ */
|
|
77
|
-
setResHeaders: /* @__PURE__ */
|
|
78
|
-
setResStatus: /* @__PURE__ */
|
|
79
|
-
getRequest: /* @__PURE__ */
|
|
80
|
-
getResponse: /* @__PURE__ */
|
|
72
|
+
..._chunkDVTBLV6Ijs.argToReq.call(void 0, params, item.args, _h3.getRequestHeaders.call(void 0, event)),
|
|
73
|
+
getCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
74
|
+
setCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
75
|
+
delCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
76
|
+
redirect: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (url, status) => _h3.sendRedirect.call(void 0, event, url, status), "redirect"),
|
|
77
|
+
setResHeaders: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
78
|
+
setResStatus: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
79
|
+
getRequest: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
80
|
+
getResponse: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
81
81
|
};
|
|
82
|
-
const context = new (0,
|
|
82
|
+
const context = new (0, _chunkDVTBLV6Ijs.Context)(contextData);
|
|
83
83
|
context.run({
|
|
84
84
|
globalGuards,
|
|
85
85
|
globalInterceptors,
|
|
@@ -101,11 +101,11 @@ function bind(router, data, opts = {}) {
|
|
|
101
101
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
102
102
|
const needBody = params.some((item) => item.type === "body");
|
|
103
103
|
router[http.type](http.prefix + http.route, _h3.eventHandler.call(void 0, {
|
|
104
|
-
onRequest:
|
|
104
|
+
onRequest: _chunkDVTBLV6Ijs.Context.usePlugin([
|
|
105
105
|
...globalPlugins,
|
|
106
106
|
...plugins
|
|
107
107
|
], "h3").map(_h3.defineRequestMiddleware),
|
|
108
|
-
handler: /* @__PURE__ */
|
|
108
|
+
handler: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, async (event) => {
|
|
109
109
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
110
110
|
const contextData = {
|
|
111
111
|
type: "h3",
|
|
@@ -121,16 +121,16 @@ function bind(router, data, opts = {}) {
|
|
|
121
121
|
body: needBody ? await _h3.readBody.call(void 0, event, {
|
|
122
122
|
strict: true
|
|
123
123
|
}) : void 0,
|
|
124
|
-
getCookie: /* @__PURE__ */
|
|
125
|
-
setCookie: /* @__PURE__ */
|
|
126
|
-
redirect: /* @__PURE__ */
|
|
127
|
-
setResHeaders: /* @__PURE__ */
|
|
128
|
-
setResStatus: /* @__PURE__ */
|
|
129
|
-
delCookie: /* @__PURE__ */
|
|
130
|
-
getRequest: /* @__PURE__ */
|
|
131
|
-
getResponse: /* @__PURE__ */
|
|
124
|
+
getCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
|
|
125
|
+
setCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
|
|
126
|
+
redirect: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (url) => _h3.sendRedirect.call(void 0, event, url), "redirect"),
|
|
127
|
+
setResHeaders: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
|
|
128
|
+
setResStatus: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
|
|
129
|
+
delCookie: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
|
|
130
|
+
getRequest: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => event.node.req, "getRequest"),
|
|
131
|
+
getResponse: /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, () => event.node.res, "getResponse")
|
|
132
132
|
};
|
|
133
|
-
const context = new (0,
|
|
133
|
+
const context = new (0, _chunkDVTBLV6Ijs.Context)(contextData);
|
|
134
134
|
_h3.setHeaders.call(void 0, event, http.headers || {});
|
|
135
135
|
return context.run({
|
|
136
136
|
globalGuards,
|
|
@@ -146,9 +146,9 @@ function bind(router, data, opts = {}) {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
_chunkTVT62GIXjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
_chunkTVT62GIXjs.__name.call(void 0, bind, "bind");
|
|
152
152
|
|
|
153
153
|
|
|
154
154
|
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-2CFYUXPM.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-G7TD2VB7.mjs";
|
|
11
11
|
|
|
12
12
|
// src/server/h3/bind.ts
|
|
13
13
|
import { defineRequestMiddleware, deleteCookie, eventHandler, getCookie, getQuery, getRequestHeaders, getRouterParams, readBody, sendRedirect, setCookie, setHeaders, setResponseHeaders, setResponseStatus } from "h3";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, Hono, MiddlewareHandler } from 'hono';
|
|
2
2
|
import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { F as Factory } from '../../core-P1CsH6jz.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../meta-KtfiBIde.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, Hono, MiddlewareHandler } from 'hono';
|
|
2
2
|
import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { F as Factory } from '../../core-BlN0Spy9.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import '../../meta-KtfiBIde.js';
|
|
6
6
|
import 'phecda-core';
|