phecda-server 7.0.0-alpha.1 → 7.0.0-alpha.3
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/assets/ps.json +1 -1
- package/bin/cli.mjs +8 -7
- package/dist/{chunk-GSPBHZBH.js → chunk-6EBEME3I.js} +52 -52
- package/dist/{chunk-XYVMNY2X.mjs → chunk-A53KNKY4.mjs} +1 -1
- package/dist/{chunk-HMVLXNV3.mjs → chunk-KUGFI6SC.mjs} +1 -1
- package/dist/{chunk-V7EI76QQ.mjs → chunk-MMG73S64.mjs} +2 -2
- package/dist/{chunk-7YQ57BQS.js → chunk-PKSWGQLW.js} +18 -18
- package/dist/{chunk-MBCHNDAY.js → chunk-QCOBXM7F.js} +24 -24
- package/dist/{chunk-WHJ5FALK.mjs → chunk-QD3QR3NW.mjs} +3 -3
- package/dist/{chunk-J5CFUN4V.js → chunk-RQSQRZL4.js} +3 -3
- package/dist/{core-CYwEPfN4.d.ts → core-C1kHRqU9.d.ts} +1 -1
- package/dist/{core-BIcUwV18.d.mts → core-CSiaRU7r.d.mts} +1 -1
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +42 -40
- package/dist/http/elysia/index.mjs +5 -3
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +39 -37
- package/dist/http/express/index.mjs +4 -2
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +40 -38
- package/dist/http/fastify/index.mjs +5 -3
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +39 -37
- package/dist/http/h3/index.mjs +4 -2
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +37 -35
- package/dist/http/hono/index.mjs +4 -2
- package/dist/http/hyper-express/index.d.mts +3 -3
- package/dist/http/hyper-express/index.d.ts +3 -3
- package/dist/http/hyper-express/index.js +37 -35
- package/dist/http/hyper-express/index.mjs +4 -2
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +39 -37
- package/dist/http/koa/index.mjs +4 -2
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +39 -39
- package/dist/index.mjs +5 -5
- package/dist/{meta-BXKLFTgG.d.mts → meta-D1M85Hef.d.mts} +1 -0
- package/dist/{meta-BXKLFTgG.d.ts → meta-D1M85Hef.d.ts} +1 -0
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +15 -14
- package/dist/rpc/bullmq/index.mjs +3 -2
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +15 -14
- package/dist/rpc/kafka/index.mjs +3 -2
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +14 -13
- package/dist/rpc/nats/index.mjs +3 -2
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +16 -15
- package/dist/rpc/rabbitmq/index.mjs +3 -2
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +14 -13
- package/dist/rpc/redis/index.mjs +3 -2
- package/dist/test.d.mts +2 -2
- package/dist/test.d.ts +2 -2
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types-BtbL49Zs.d.mts → types-C9Remkup.d.ts} +2 -1
- package/dist/{types-m3IEDKjP.d.ts → types-JMhFVp-Z.d.mts} +2 -1
- package/dist/{types-h40T3cRG.d.mts → types-ee1FBodH.d.ts} +2 -1
- package/dist/{types-VFzEM7LL.d.ts → types-wbHHC93P.d.mts} +2 -1
- package/package.json +1 -1
- package/register/loader.mjs +2 -2
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk6EBEME3Ijs = require('../../chunk-6EBEME3I.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkRQSQRZL4js = require('../../chunk-RQSQRZL4.js');
|
|
12
12
|
|
|
13
13
|
// src/http/express/bind.ts
|
|
14
14
|
var _express = require('express');
|
|
@@ -18,14 +18,14 @@ function bind(router, data, opts = {}) {
|
|
|
18
18
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
19
19
|
const { moduleMap, meta } = data;
|
|
20
20
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunk6EBEME3Ijs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
22
|
const { controller, http, func, tag } = meta2.data;
|
|
23
23
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
24
24
|
debug(`register method "${func}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunk6EBEME3Ijs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -33,39 +33,40 @@ function bind(router, data, opts = {}) {
|
|
|
33
33
|
guards: globalGuards
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
|
-
|
|
36
|
+
_chunk6EBEME3Ijs.HMR.call(void 0, async () => {
|
|
37
37
|
router.stack = originStack;
|
|
38
38
|
registerRoute();
|
|
39
39
|
});
|
|
40
40
|
function registerRoute() {
|
|
41
|
-
|
|
41
|
+
_chunk6EBEME3Ijs.Context.applyAddons(globalAddons, router, "express");
|
|
42
42
|
if (parallelRoute) {
|
|
43
43
|
const subRouter = _express.Router.call(void 0, );
|
|
44
|
-
|
|
44
|
+
_chunk6EBEME3Ijs.Context.applyAddons(parallelAddons, subRouter, "express");
|
|
45
45
|
subRouter.use(async (req, res, next) => {
|
|
46
46
|
const { body } = req;
|
|
47
47
|
async function errorHandler(e) {
|
|
48
|
-
const error = await
|
|
48
|
+
const error = await _chunk6EBEME3Ijs.Context.filterRecord.default(e);
|
|
49
49
|
return res.status(error.status).json(error);
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
51
|
+
_chunkRQSQRZL4js.__name.call(void 0, errorHandler, "errorHandler");
|
|
52
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk6EBEME3Ijs.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 _chunk6EBEME3Ijs.Context.filterRecord.default(new (0, _chunk6EBEME3Ijs.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 _chunk6EBEME3Ijs.Context.filterRecord.default(new (0, _chunk6EBEME3Ijs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
61
61
|
const { data: { params } } = meta2;
|
|
62
|
-
const aop =
|
|
62
|
+
const aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
63
63
|
globalFilter,
|
|
64
64
|
globalGuards,
|
|
65
65
|
globalPipe
|
|
66
66
|
});
|
|
67
67
|
const contextData = {
|
|
68
68
|
type: "express",
|
|
69
|
+
category: "http",
|
|
69
70
|
parallel: true,
|
|
70
71
|
request: req,
|
|
71
72
|
index: i,
|
|
@@ -76,19 +77,19 @@ function bind(router, data, opts = {}) {
|
|
|
76
77
|
func,
|
|
77
78
|
next,
|
|
78
79
|
app: router,
|
|
79
|
-
...
|
|
80
|
-
getCookie: /* @__PURE__ */
|
|
81
|
-
setCookie: /* @__PURE__ */
|
|
82
|
-
delCookie: /* @__PURE__ */
|
|
80
|
+
..._chunk6EBEME3Ijs.argToReq.call(void 0, params, item.args, req.headers),
|
|
81
|
+
getCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
82
|
+
setCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
|
|
83
|
+
delCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => res.cookie(key, "", {
|
|
83
84
|
expires: /* @__PURE__ */ new Date(0)
|
|
84
85
|
}), "delCookie"),
|
|
85
|
-
redirect: /* @__PURE__ */
|
|
86
|
-
setResHeaders: /* @__PURE__ */
|
|
87
|
-
setResStatus: /* @__PURE__ */
|
|
88
|
-
getRequest: /* @__PURE__ */
|
|
89
|
-
getResponse: /* @__PURE__ */
|
|
86
|
+
redirect: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
87
|
+
setResHeaders: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
88
|
+
setResStatus: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
89
|
+
getRequest: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => req, "getRequest"),
|
|
90
|
+
getResponse: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => res, "getResponse")
|
|
90
91
|
};
|
|
91
|
-
const context = new (0,
|
|
92
|
+
const context = new (0, _chunk6EBEME3Ijs.Context)(contextData);
|
|
92
93
|
context.run(aop, resolve, resolve);
|
|
93
94
|
});
|
|
94
95
|
})).then((ret) => {
|
|
@@ -107,18 +108,19 @@ function bind(router, data, opts = {}) {
|
|
|
107
108
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
108
109
|
let aop;
|
|
109
110
|
if (!dynamic) {
|
|
110
|
-
aop =
|
|
111
|
+
aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
111
112
|
globalFilter,
|
|
112
113
|
globalGuards,
|
|
113
114
|
globalPipe
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
117
|
const subRouter = _express.Router.call(void 0, );
|
|
117
|
-
|
|
118
|
+
_chunk6EBEME3Ijs.Context.applyAddons(addons, subRouter, "express");
|
|
118
119
|
subRouter[http.type](http.prefix + http.route, async (req, res, next) => {
|
|
119
120
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
120
121
|
const contextData = {
|
|
121
122
|
type: "express",
|
|
123
|
+
category: "http",
|
|
122
124
|
request: req,
|
|
123
125
|
meta: meta2,
|
|
124
126
|
response: res,
|
|
@@ -131,21 +133,21 @@ function bind(router, data, opts = {}) {
|
|
|
131
133
|
headers: req.headers,
|
|
132
134
|
app: router,
|
|
133
135
|
next,
|
|
134
|
-
getCookie: /* @__PURE__ */
|
|
135
|
-
setCookie: /* @__PURE__ */
|
|
136
|
-
delCookie: /* @__PURE__ */
|
|
136
|
+
getCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
137
|
+
setCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
|
|
138
|
+
delCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => res.cookie(key, "", {
|
|
137
139
|
expires: /* @__PURE__ */ new Date(0)
|
|
138
140
|
}), "delCookie"),
|
|
139
|
-
redirect: /* @__PURE__ */
|
|
140
|
-
setResHeaders: /* @__PURE__ */
|
|
141
|
-
setResStatus: /* @__PURE__ */
|
|
142
|
-
getRequest: /* @__PURE__ */
|
|
143
|
-
getResponse: /* @__PURE__ */
|
|
141
|
+
redirect: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
142
|
+
setResHeaders: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
143
|
+
setResStatus: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
144
|
+
getRequest: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => req, "getRequest"),
|
|
145
|
+
getResponse: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => res, "getResponse")
|
|
144
146
|
};
|
|
145
|
-
const context = new (0,
|
|
147
|
+
const context = new (0, _chunk6EBEME3Ijs.Context)(contextData);
|
|
146
148
|
if (http.headers) res.set(http.headers);
|
|
147
149
|
if (dynamic) {
|
|
148
|
-
aop =
|
|
150
|
+
aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
149
151
|
globalFilter,
|
|
150
152
|
globalGuards,
|
|
151
153
|
globalPipe
|
|
@@ -164,9 +166,9 @@ function bind(router, data, opts = {}) {
|
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
168
|
}
|
|
167
|
-
|
|
169
|
+
_chunkRQSQRZL4js.__name.call(void 0, registerRoute, "registerRoute");
|
|
168
170
|
}
|
|
169
|
-
|
|
171
|
+
_chunkRQSQRZL4js.__name.call(void 0, bind, "bind");
|
|
170
172
|
|
|
171
173
|
|
|
172
174
|
exports.bind = bind;
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
7
|
detectAopDep
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-MMG73S64.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-QD3QR3NW.mjs";
|
|
12
12
|
|
|
13
13
|
// src/http/express/bind.ts
|
|
14
14
|
import { Router } from "express";
|
|
@@ -66,6 +66,7 @@ function bind(router, data, opts = {}) {
|
|
|
66
66
|
});
|
|
67
67
|
const contextData = {
|
|
68
68
|
type: "express",
|
|
69
|
+
category: "http",
|
|
69
70
|
parallel: true,
|
|
70
71
|
request: req,
|
|
71
72
|
index: i,
|
|
@@ -119,6 +120,7 @@ function bind(router, data, opts = {}) {
|
|
|
119
120
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
120
121
|
const contextData = {
|
|
121
122
|
type: "express",
|
|
123
|
+
category: "http",
|
|
122
124
|
request: req,
|
|
123
125
|
meta: meta2,
|
|
124
126
|
response: res,
|
|
@@ -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-wbHHC93P.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-CSiaRU7r.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-D1M85Hef.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-ee1FBodH.js';
|
|
3
|
+
import { F as Factory } from '../../core-C1kHRqU9.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-D1M85Hef.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface FastifyCtx extends HttpContext {
|
|
@@ -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 _chunkQCOBXM7Fjs = require('../../chunk-QCOBXM7F.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk6EBEME3Ijs = require('../../chunk-6EBEME3I.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkRQSQRZL4js = require('../../chunk-RQSQRZL4.js');
|
|
14
14
|
|
|
15
15
|
// src/http/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, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, fastifyOpts, dynamic = false } = opts;
|
|
20
20
|
const { moduleMap, meta } = data;
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunk6EBEME3Ijs.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
|
+
_chunk6EBEME3Ijs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -33,34 +33,35 @@ function bind(fastify, data, opts = {}) {
|
|
|
33
33
|
guards: globalGuards
|
|
34
34
|
});
|
|
35
35
|
fastify.register(async (fastify2, _, done) => {
|
|
36
|
-
|
|
36
|
+
_chunk6EBEME3Ijs.Context.applyAddons(globalAddons, fastify2, "fastify");
|
|
37
37
|
if (parallelRoute) {
|
|
38
38
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
39
|
-
|
|
39
|
+
_chunk6EBEME3Ijs.Context.applyAddons(parallelAddons, fastify3, "fastify");
|
|
40
40
|
fastify3.post(parallelRoute, async (req, res) => {
|
|
41
41
|
const { body } = req;
|
|
42
42
|
async function errorHandler(e) {
|
|
43
|
-
const error = await
|
|
43
|
+
const error = await _chunk6EBEME3Ijs.Context.filterRecord.default(e);
|
|
44
44
|
return res.status(error.status).send(error);
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
46
|
+
_chunkRQSQRZL4js.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk6EBEME3Ijs.BadRequestException)("data format should be an array"));
|
|
48
48
|
try {
|
|
49
49
|
return Promise.all(body.map((item, i) => {
|
|
50
50
|
return new Promise(async (resolve) => {
|
|
51
51
|
const { tag, func } = item;
|
|
52
52
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
53
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
53
|
+
if (!metaMap.has(tag)) return resolve(await _chunk6EBEME3Ijs.Context.filterRecord.default(new (0, _chunk6EBEME3Ijs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
54
54
|
const meta2 = metaMap.get(tag)[func];
|
|
55
|
-
if (!meta2) return resolve(await
|
|
55
|
+
if (!meta2) return resolve(await _chunk6EBEME3Ijs.Context.filterRecord.default(new (0, _chunk6EBEME3Ijs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
56
56
|
const { data: { params } } = meta2;
|
|
57
|
-
const aop =
|
|
57
|
+
const aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
58
58
|
globalFilter,
|
|
59
59
|
globalGuards,
|
|
60
60
|
globalPipe
|
|
61
61
|
});
|
|
62
62
|
const contextData = {
|
|
63
63
|
type: "fastify",
|
|
64
|
+
category: "http",
|
|
64
65
|
parallel: true,
|
|
65
66
|
request: req,
|
|
66
67
|
index: i,
|
|
@@ -70,20 +71,20 @@ function bind(fastify, data, opts = {}) {
|
|
|
70
71
|
tag,
|
|
71
72
|
func,
|
|
72
73
|
app: fastify3,
|
|
73
|
-
...
|
|
74
|
+
..._chunk6EBEME3Ijs.argToReq.call(void 0, params, item.args, req.headers),
|
|
74
75
|
// @ts-expect-error need @fastify/cookie
|
|
75
|
-
getCookie: /* @__PURE__ */
|
|
76
|
+
getCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
76
77
|
// @ts-expect-error need @fastify/cookie
|
|
77
|
-
setCookie: /* @__PURE__ */
|
|
78
|
+
setCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
78
79
|
// @ts-expect-error need @fastify/cookie
|
|
79
|
-
delCookie: /* @__PURE__ */
|
|
80
|
-
redirect: /* @__PURE__ */
|
|
81
|
-
setResHeaders: /* @__PURE__ */
|
|
82
|
-
setResStatus: /* @__PURE__ */
|
|
83
|
-
getRequest: /* @__PURE__ */
|
|
84
|
-
getResponse: /* @__PURE__ */
|
|
80
|
+
delCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
81
|
+
redirect: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
82
|
+
setResHeaders: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
83
|
+
setResStatus: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
84
|
+
getRequest: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => req.raw, "getRequest"),
|
|
85
|
+
getResponse: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => res.raw, "getResponse")
|
|
85
86
|
};
|
|
86
|
-
const context = new (0,
|
|
87
|
+
const context = new (0, _chunk6EBEME3Ijs.Context)(contextData);
|
|
87
88
|
context.run(aop, resolve, resolve);
|
|
88
89
|
});
|
|
89
90
|
})).then((ret) => {
|
|
@@ -102,10 +103,10 @@ function bind(fastify, data, opts = {}) {
|
|
|
102
103
|
const { data: { addons, define, http } } = meta2;
|
|
103
104
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
|
|
104
105
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
105
|
-
|
|
106
|
+
_chunk6EBEME3Ijs.Context.applyAddons(addons, fastify3, "fastify");
|
|
106
107
|
let aop;
|
|
107
108
|
if (!dynamic) {
|
|
108
|
-
aop =
|
|
109
|
+
aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
109
110
|
globalFilter,
|
|
110
111
|
globalGuards,
|
|
111
112
|
globalPipe
|
|
@@ -115,6 +116,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
115
116
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
116
117
|
const contextData = {
|
|
117
118
|
type: "fastify",
|
|
119
|
+
category: "http",
|
|
118
120
|
request: req,
|
|
119
121
|
meta: meta2,
|
|
120
122
|
response: res,
|
|
@@ -127,23 +129,23 @@ function bind(fastify, data, opts = {}) {
|
|
|
127
129
|
headers: req.headers,
|
|
128
130
|
app: fastify3,
|
|
129
131
|
// @ts-expect-error need @fastify/cookie
|
|
130
|
-
getCookie: /* @__PURE__ */
|
|
132
|
+
getCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
131
133
|
// @ts-expect-error need @fastify/cookie
|
|
132
|
-
setCookie: /* @__PURE__ */
|
|
134
|
+
setCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
133
135
|
// @ts-expect-error need @fastify/cookie
|
|
134
|
-
delCookie: /* @__PURE__ */
|
|
136
|
+
delCookie: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (key) => res.clearCookie(key, {
|
|
135
137
|
url: ""
|
|
136
138
|
}), "delCookie"),
|
|
137
|
-
redirect: /* @__PURE__ */
|
|
138
|
-
setResHeaders: /* @__PURE__ */
|
|
139
|
-
setResStatus: /* @__PURE__ */
|
|
140
|
-
getRequest: /* @__PURE__ */
|
|
141
|
-
getResponse: /* @__PURE__ */
|
|
139
|
+
redirect: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
140
|
+
setResHeaders: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
141
|
+
setResStatus: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
142
|
+
getRequest: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => req.raw, "getRequest"),
|
|
143
|
+
getResponse: /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, () => res.raw, "getResponse")
|
|
142
144
|
};
|
|
143
|
-
const context = new (0,
|
|
145
|
+
const context = new (0, _chunk6EBEME3Ijs.Context)(contextData);
|
|
144
146
|
if (http.headers) res.headers(http.headers);
|
|
145
147
|
if (dynamic) {
|
|
146
|
-
aop =
|
|
148
|
+
aop = _chunk6EBEME3Ijs.Context.getAop(meta2, {
|
|
147
149
|
globalFilter,
|
|
148
150
|
globalGuards,
|
|
149
151
|
globalPipe
|
|
@@ -164,11 +166,11 @@ function bind(fastify, data, opts = {}) {
|
|
|
164
166
|
done();
|
|
165
167
|
}, fastifyOpts);
|
|
166
168
|
}
|
|
167
|
-
|
|
169
|
+
_chunkRQSQRZL4js.__name.call(void 0, bind, "bind");
|
|
168
170
|
function Fastify(opts) {
|
|
169
|
-
return
|
|
171
|
+
return _chunkQCOBXM7Fjs.Define.call(void 0, "fastify", opts);
|
|
170
172
|
}
|
|
171
|
-
|
|
173
|
+
_chunkRQSQRZL4js.__name.call(void 0, Fastify, "Fastify");
|
|
172
174
|
|
|
173
175
|
|
|
174
176
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-KUGFI6SC.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-MMG73S64.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-QD3QR3NW.mjs";
|
|
14
14
|
|
|
15
15
|
// src/http/fastify/bind.ts
|
|
16
16
|
import Debug from "debug";
|
|
@@ -61,6 +61,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
61
61
|
});
|
|
62
62
|
const contextData = {
|
|
63
63
|
type: "fastify",
|
|
64
|
+
category: "http",
|
|
64
65
|
parallel: true,
|
|
65
66
|
request: req,
|
|
66
67
|
index: i,
|
|
@@ -115,6 +116,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
115
116
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
116
117
|
const contextData = {
|
|
117
118
|
type: "fastify",
|
|
119
|
+
category: "http",
|
|
118
120
|
request: req,
|
|
119
121
|
meta: meta2,
|
|
120
122
|
response: res,
|
package/dist/http/h3/index.d.mts
CHANGED
|
@@ -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-CSiaRU7r.mjs';
|
|
3
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-wbHHC93P.mjs';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-D1M85Hef.mjs';
|
|
6
6
|
import 'node:http';
|
|
7
7
|
|
|
8
8
|
interface H3Ctx extends HttpContext {
|
package/dist/http/h3/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { H3Event, Router, _RequestMiddleware } from 'h3';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-C1kHRqU9.js';
|
|
3
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-ee1FBodH.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-D1M85Hef.js';
|
|
6
6
|
import 'node:http';
|
|
7
7
|
|
|
8
8
|
interface H3Ctx extends HttpContext {
|