phecda-server 7.0.0-alpha.7 → 7.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +10 -1
- package/dist/{chunk-MENRZSGW.js → chunk-7EMAZGYO.js} +86 -56
- package/dist/{chunk-JPSXNDXP.mjs → chunk-7NWDKK7D.mjs} +1 -1
- package/dist/{chunk-RGSKKTHD.mjs → chunk-B45BN7LY.mjs} +4 -4
- package/dist/{chunk-VYMSCWXC.js → chunk-BBNJVYVX.js} +24 -24
- package/dist/{chunk-XSMUJ77A.js → chunk-QJIAXSLZ.js} +19 -19
- package/dist/{chunk-IRXNF6ZE.mjs → chunk-SGMQZRP6.mjs} +39 -9
- package/dist/{chunk-M5HGFUCV.js → chunk-VSGYTGHY.js} +2 -2
- package/dist/{chunk-C5BVKEGW.mjs → chunk-YKP4ODZA.mjs} +2 -2
- package/dist/{core-CzElxZoF.d.ts → core-BGEsBtTG.d.ts} +1 -1
- package/dist/{core-DU7gQKSk.d.mts → core-BcKywWLd.d.mts} +1 -1
- package/dist/helper.d.mts +3 -2
- package/dist/helper.d.ts +3 -2
- package/dist/helper.js +5 -3
- package/dist/helper.mjs +4 -2
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +42 -41
- package/dist/http/elysia/index.mjs +6 -5
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +39 -38
- package/dist/http/express/index.mjs +5 -4
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +40 -39
- package/dist/http/fastify/index.mjs +6 -5
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +40 -39
- package/dist/http/h3/index.mjs +6 -5
- package/dist/http/hono/index.d.mts +4 -4
- package/dist/http/hono/index.d.ts +4 -4
- package/dist/http/hono/index.js +35 -35
- package/dist/http/hono/index.mjs +2 -2
- package/dist/http/hyper-express/index.d.mts +4 -4
- package/dist/http/hyper-express/index.d.ts +4 -4
- package/dist/http/hyper-express/index.js +37 -36
- package/dist/http/hyper-express/index.mjs +5 -4
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +39 -38
- package/dist/http/koa/index.mjs +5 -4
- package/dist/index.d.mts +35 -33
- package/dist/index.d.ts +35 -33
- package/dist/index.js +43 -42
- package/dist/index.mjs +15 -14
- package/dist/{meta-BTnLXuCa.d.ts → meta-B_HW7cWh.d.mts} +3 -3
- package/dist/{meta-BTnLXuCa.d.mts → meta-B_HW7cWh.d.ts} +3 -3
- package/dist/rpc/bullmq/index.d.mts +4 -4
- package/dist/rpc/bullmq/index.d.ts +4 -4
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.d.mts +4 -4
- package/dist/rpc/kafka/index.d.ts +4 -4
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +4 -4
- package/dist/rpc/nats/index.d.ts +4 -4
- package/dist/rpc/nats/index.js +13 -13
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.d.mts +4 -4
- package/dist/rpc/rabbitmq/index.d.ts +4 -4
- package/dist/rpc/rabbitmq/index.js +15 -15
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.d.mts +4 -4
- package/dist/rpc/redis/index.d.ts +4 -4
- package/dist/rpc/redis/index.js +13 -13
- package/dist/rpc/redis/index.mjs +2 -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--E-OCZhC.d.ts → types-C2SQ9U9V.d.mts} +3 -3
- package/dist/{types-CbfaGkPA.d.ts → types-CYF0vha6.d.ts} +3 -3
- package/dist/{types-BYqBeqrs.d.mts → types-DEQb_e59.d.mts} +3 -3
- package/dist/{types-BxlzVoRv.d.mts → types-PFPIQWVF.d.ts} +3 -3
- package/package.json +3 -2
- package/register/loader.mjs +2 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Request, Response, Router, RequestHandler } from 'express';
|
|
2
|
-
import { H as
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-PFPIQWVF.js';
|
|
3
|
+
import { F as Factory } from '../../core-BGEsBtTG.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-B_HW7cWh.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
|
-
interface ExpressCtx extends
|
|
8
|
+
interface ExpressCtx extends HttpCtx {
|
|
9
9
|
type: 'express';
|
|
10
10
|
request: Request;
|
|
11
11
|
response: Response;
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var _chunkMENRZSGWjs = require('../../chunk-MENRZSGW.js');
|
|
9
8
|
|
|
9
|
+
var _chunk7EMAZGYOjs = require('../../chunk-7EMAZGYO.js');
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
var _chunkVSGYTGHYjs = require('../../chunk-VSGYTGHY.js');
|
|
12
13
|
|
|
13
14
|
// src/http/express/bind.ts
|
|
14
15
|
var _express = require('express');
|
|
@@ -18,14 +19,14 @@ function bind(router, data, opts = {}) {
|
|
|
18
19
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
19
20
|
const { moduleMap, meta } = data;
|
|
20
21
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
21
|
-
const metaMap =
|
|
22
|
+
const metaMap = _chunk7EMAZGYOjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
23
|
const { controller, http, func, tag } = meta2.data;
|
|
23
24
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
24
25
|
debug(`register method "${func}" in module "${tag}"`);
|
|
25
26
|
return true;
|
|
26
27
|
}
|
|
27
28
|
});
|
|
28
|
-
|
|
29
|
+
_chunk7EMAZGYOjs.detectAopDep.call(void 0, meta, {
|
|
29
30
|
addons: [
|
|
30
31
|
...globalAddons,
|
|
31
32
|
...parallelAddons
|
|
@@ -33,33 +34,33 @@ function bind(router, data, opts = {}) {
|
|
|
33
34
|
guards: globalGuards
|
|
34
35
|
});
|
|
35
36
|
registerRoute();
|
|
36
|
-
|
|
37
|
+
_chunk7EMAZGYOjs.HMR.call(void 0, async () => {
|
|
37
38
|
router.stack = originStack;
|
|
38
39
|
registerRoute();
|
|
39
40
|
});
|
|
40
41
|
function registerRoute() {
|
|
41
|
-
|
|
42
|
+
_chunk7EMAZGYOjs.Context.applyAddons(globalAddons, router, "express");
|
|
42
43
|
if (parallelRoute) {
|
|
43
44
|
const subRouter = _express.Router.call(void 0, );
|
|
44
|
-
|
|
45
|
+
_chunk7EMAZGYOjs.Context.applyAddons(parallelAddons, subRouter, "express");
|
|
45
46
|
subRouter.use(async (req, res, next) => {
|
|
46
47
|
const { body } = req;
|
|
47
48
|
async function errorHandler(e) {
|
|
48
|
-
const error = await
|
|
49
|
+
const error = await _chunk7EMAZGYOjs.Context.filterRecord.default(e);
|
|
49
50
|
return res.status(error.status).json(error);
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
52
|
+
_chunkVSGYTGHYjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
53
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk7EMAZGYOjs.BadRequestException)("data format should be an array"));
|
|
53
54
|
try {
|
|
54
55
|
return Promise.all(body.map((item, i) => {
|
|
55
56
|
return new Promise(async (resolve) => {
|
|
56
57
|
const { tag, func } = item;
|
|
57
58
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
58
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
59
|
+
if (!metaMap.has(tag)) return resolve(await _chunk7EMAZGYOjs.Context.filterRecord.default(new (0, _chunk7EMAZGYOjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
59
60
|
const meta2 = metaMap.get(tag)[func];
|
|
60
|
-
if (!meta2) return resolve(await
|
|
61
|
+
if (!meta2) return resolve(await _chunk7EMAZGYOjs.Context.filterRecord.default(new (0, _chunk7EMAZGYOjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
61
62
|
const { data: { params } } = meta2;
|
|
62
|
-
const aop =
|
|
63
|
+
const aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
63
64
|
globalFilter,
|
|
64
65
|
globalGuards,
|
|
65
66
|
globalPipe
|
|
@@ -77,19 +78,19 @@ function bind(router, data, opts = {}) {
|
|
|
77
78
|
func,
|
|
78
79
|
next,
|
|
79
80
|
app: router,
|
|
80
|
-
...
|
|
81
|
-
getCookie: /* @__PURE__ */
|
|
82
|
-
setCookie: /* @__PURE__ */
|
|
83
|
-
delCookie: /* @__PURE__ */
|
|
81
|
+
..._chunk7EMAZGYOjs.argToReq.call(void 0, params, item.args, req.headers),
|
|
82
|
+
getCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
83
|
+
setCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
|
|
84
|
+
delCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => res.cookie(key, "", {
|
|
84
85
|
expires: /* @__PURE__ */ new Date(0)
|
|
85
86
|
}), "delCookie"),
|
|
86
|
-
redirect: /* @__PURE__ */
|
|
87
|
-
setResHeaders: /* @__PURE__ */
|
|
88
|
-
setResStatus: /* @__PURE__ */
|
|
89
|
-
getRequest: /* @__PURE__ */
|
|
90
|
-
getResponse: /* @__PURE__ */
|
|
87
|
+
redirect: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
88
|
+
setResHeaders: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
89
|
+
setResStatus: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
90
|
+
getRequest: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => req, "getRequest"),
|
|
91
|
+
getResponse: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => res, "getResponse")
|
|
91
92
|
};
|
|
92
|
-
const context = new (0,
|
|
93
|
+
const context = new (0, _chunk7EMAZGYOjs.Context)(contextData);
|
|
93
94
|
context.run(aop, resolve, resolve);
|
|
94
95
|
});
|
|
95
96
|
})).then((ret) => {
|
|
@@ -108,15 +109,15 @@ function bind(router, data, opts = {}) {
|
|
|
108
109
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
109
110
|
let aop;
|
|
110
111
|
if (!dynamic) {
|
|
111
|
-
aop =
|
|
112
|
+
aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
112
113
|
globalFilter,
|
|
113
114
|
globalGuards,
|
|
114
115
|
globalPipe
|
|
115
116
|
});
|
|
116
117
|
}
|
|
117
118
|
const subRouter = _express.Router.call(void 0, );
|
|
118
|
-
|
|
119
|
-
subRouter[http.type](http.prefix
|
|
119
|
+
_chunk7EMAZGYOjs.Context.applyAddons(addons, subRouter, "express");
|
|
120
|
+
subRouter[http.type](_chunk7EMAZGYOjs.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
|
|
120
121
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
121
122
|
const contextData = {
|
|
122
123
|
type: "express",
|
|
@@ -133,21 +134,21 @@ function bind(router, data, opts = {}) {
|
|
|
133
134
|
headers: req.headers,
|
|
134
135
|
app: router,
|
|
135
136
|
next,
|
|
136
|
-
getCookie: /* @__PURE__ */
|
|
137
|
-
setCookie: /* @__PURE__ */
|
|
138
|
-
delCookie: /* @__PURE__ */
|
|
137
|
+
getCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
138
|
+
setCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
|
|
139
|
+
delCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => res.cookie(key, "", {
|
|
139
140
|
expires: /* @__PURE__ */ new Date(0)
|
|
140
141
|
}), "delCookie"),
|
|
141
|
-
redirect: /* @__PURE__ */
|
|
142
|
-
setResHeaders: /* @__PURE__ */
|
|
143
|
-
setResStatus: /* @__PURE__ */
|
|
144
|
-
getRequest: /* @__PURE__ */
|
|
145
|
-
getResponse: /* @__PURE__ */
|
|
142
|
+
redirect: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
143
|
+
setResHeaders: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
144
|
+
setResStatus: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
145
|
+
getRequest: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => req, "getRequest"),
|
|
146
|
+
getResponse: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => res, "getResponse")
|
|
146
147
|
};
|
|
147
|
-
const context = new (0,
|
|
148
|
+
const context = new (0, _chunk7EMAZGYOjs.Context)(contextData);
|
|
148
149
|
if (http.headers) res.set(http.headers);
|
|
149
150
|
if (dynamic) {
|
|
150
|
-
aop =
|
|
151
|
+
aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
151
152
|
globalFilter,
|
|
152
153
|
globalGuards,
|
|
153
154
|
globalPipe
|
|
@@ -166,9 +167,9 @@ function bind(router, data, opts = {}) {
|
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
|
-
|
|
170
|
+
_chunkVSGYTGHYjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
170
171
|
}
|
|
171
|
-
|
|
172
|
+
_chunkVSGYTGHYjs.__name.call(void 0, bind, "bind");
|
|
172
173
|
|
|
173
174
|
|
|
174
175
|
exports.bind = bind;
|
|
@@ -4,11 +4,12 @@ import {
|
|
|
4
4
|
HMR,
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
|
-
detectAopDep
|
|
8
|
-
|
|
7
|
+
detectAopDep,
|
|
8
|
+
joinUrl
|
|
9
|
+
} from "../../chunk-SGMQZRP6.mjs";
|
|
9
10
|
import {
|
|
10
11
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-YKP4ODZA.mjs";
|
|
12
13
|
|
|
13
14
|
// src/http/express/bind.ts
|
|
14
15
|
import { Router } from "express";
|
|
@@ -116,7 +117,7 @@ function bind(router, data, opts = {}) {
|
|
|
116
117
|
}
|
|
117
118
|
const subRouter = Router();
|
|
118
119
|
Context.applyAddons(addons, subRouter, "express");
|
|
119
|
-
subRouter[http.type](http.prefix
|
|
120
|
+
subRouter[http.type](joinUrl(http.prefix, http.route), async (req, res, next) => {
|
|
120
121
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
121
122
|
const contextData = {
|
|
122
123
|
type: "express",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
|
-
import { H as
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-C2SQ9U9V.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-BcKywWLd.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-B_HW7cWh.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
|
-
interface FastifyCtx extends
|
|
8
|
+
interface FastifyCtx extends HttpCtx {
|
|
9
9
|
type: 'fastify';
|
|
10
10
|
request: FastifyRequest;
|
|
11
11
|
response: FastifyReply;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
|
-
import { H as
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-PFPIQWVF.js';
|
|
3
|
+
import { F as Factory } from '../../core-BGEsBtTG.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-B_HW7cWh.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
|
-
interface FastifyCtx extends
|
|
8
|
+
interface FastifyCtx extends HttpCtx {
|
|
9
9
|
type: 'fastify';
|
|
10
10
|
request: FastifyRequest;
|
|
11
11
|
response: FastifyReply;
|
|
@@ -1,16 +1,17 @@
|
|
|
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 _chunkBBNJVYVXjs = require('../../chunk-BBNJVYVX.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var _chunkMENRZSGWjs = require('../../chunk-MENRZSGW.js');
|
|
11
10
|
|
|
11
|
+
var _chunk7EMAZGYOjs = require('../../chunk-7EMAZGYO.js');
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
var _chunkVSGYTGHYjs = require('../../chunk-VSGYTGHY.js');
|
|
14
15
|
|
|
15
16
|
// src/http/fastify/bind.ts
|
|
16
17
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -18,14 +19,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/fastify");
|
|
|
18
19
|
function bind(fastify, data, opts = {}) {
|
|
19
20
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, fastifyOpts, dynamic = false } = opts;
|
|
20
21
|
const { moduleMap, meta } = data;
|
|
21
|
-
const metaMap =
|
|
22
|
+
const metaMap = _chunk7EMAZGYOjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
23
|
const { controller, http, func, tag } = meta2.data;
|
|
23
24
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _2 => _2.type])) {
|
|
24
25
|
debug(`register method "${func}" in module "${tag}"`);
|
|
25
26
|
return true;
|
|
26
27
|
}
|
|
27
28
|
});
|
|
28
|
-
|
|
29
|
+
_chunk7EMAZGYOjs.detectAopDep.call(void 0, meta, {
|
|
29
30
|
addons: [
|
|
30
31
|
...globalAddons,
|
|
31
32
|
...parallelAddons
|
|
@@ -33,28 +34,28 @@ function bind(fastify, data, opts = {}) {
|
|
|
33
34
|
guards: globalGuards
|
|
34
35
|
});
|
|
35
36
|
fastify.register(async (fastify2, _, done) => {
|
|
36
|
-
|
|
37
|
+
_chunk7EMAZGYOjs.Context.applyAddons(globalAddons, fastify2, "fastify");
|
|
37
38
|
if (parallelRoute) {
|
|
38
39
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
39
|
-
|
|
40
|
+
_chunk7EMAZGYOjs.Context.applyAddons(parallelAddons, fastify3, "fastify");
|
|
40
41
|
fastify3.post(parallelRoute, async (req, res) => {
|
|
41
42
|
const { body } = req;
|
|
42
43
|
async function errorHandler(e) {
|
|
43
|
-
const error = await
|
|
44
|
+
const error = await _chunk7EMAZGYOjs.Context.filterRecord.default(e);
|
|
44
45
|
return res.status(error.status).send(error);
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
47
|
+
_chunkVSGYTGHYjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
48
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk7EMAZGYOjs.BadRequestException)("data format should be an array"));
|
|
48
49
|
try {
|
|
49
50
|
return Promise.all(body.map((item, i) => {
|
|
50
51
|
return new Promise(async (resolve) => {
|
|
51
52
|
const { tag, func } = item;
|
|
52
53
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
53
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
54
|
+
if (!metaMap.has(tag)) return resolve(await _chunk7EMAZGYOjs.Context.filterRecord.default(new (0, _chunk7EMAZGYOjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
54
55
|
const meta2 = metaMap.get(tag)[func];
|
|
55
|
-
if (!meta2) return resolve(await
|
|
56
|
+
if (!meta2) return resolve(await _chunk7EMAZGYOjs.Context.filterRecord.default(new (0, _chunk7EMAZGYOjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
56
57
|
const { data: { params } } = meta2;
|
|
57
|
-
const aop =
|
|
58
|
+
const aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
58
59
|
globalFilter,
|
|
59
60
|
globalGuards,
|
|
60
61
|
globalPipe
|
|
@@ -71,20 +72,20 @@ function bind(fastify, data, opts = {}) {
|
|
|
71
72
|
tag,
|
|
72
73
|
func,
|
|
73
74
|
app: fastify3,
|
|
74
|
-
...
|
|
75
|
+
..._chunk7EMAZGYOjs.argToReq.call(void 0, params, item.args, req.headers),
|
|
75
76
|
// @ts-expect-error need @fastify/cookie
|
|
76
|
-
getCookie: /* @__PURE__ */
|
|
77
|
+
getCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
77
78
|
// @ts-expect-error need @fastify/cookie
|
|
78
|
-
setCookie: /* @__PURE__ */
|
|
79
|
+
setCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
79
80
|
// @ts-expect-error need @fastify/cookie
|
|
80
|
-
delCookie: /* @__PURE__ */
|
|
81
|
-
redirect: /* @__PURE__ */
|
|
82
|
-
setResHeaders: /* @__PURE__ */
|
|
83
|
-
setResStatus: /* @__PURE__ */
|
|
84
|
-
getRequest: /* @__PURE__ */
|
|
85
|
-
getResponse: /* @__PURE__ */
|
|
81
|
+
delCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
82
|
+
redirect: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
83
|
+
setResHeaders: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
84
|
+
setResStatus: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
85
|
+
getRequest: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => req.raw, "getRequest"),
|
|
86
|
+
getResponse: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => res.raw, "getResponse")
|
|
86
87
|
};
|
|
87
|
-
const context = new (0,
|
|
88
|
+
const context = new (0, _chunk7EMAZGYOjs.Context)(contextData);
|
|
88
89
|
context.run(aop, resolve, resolve);
|
|
89
90
|
});
|
|
90
91
|
})).then((ret) => {
|
|
@@ -103,16 +104,16 @@ function bind(fastify, data, opts = {}) {
|
|
|
103
104
|
const { data: { addons, define, http } } = meta2;
|
|
104
105
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
|
|
105
106
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
106
|
-
|
|
107
|
+
_chunk7EMAZGYOjs.Context.applyAddons(addons, fastify3, "fastify");
|
|
107
108
|
let aop;
|
|
108
109
|
if (!dynamic) {
|
|
109
|
-
aop =
|
|
110
|
+
aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
110
111
|
globalFilter,
|
|
111
112
|
globalGuards,
|
|
112
113
|
globalPipe
|
|
113
114
|
});
|
|
114
115
|
}
|
|
115
|
-
fastify3[http.type](http.prefix
|
|
116
|
+
fastify3[http.type](_chunk7EMAZGYOjs.joinUrl.call(void 0, http.prefix, http.route), _optionalChain([define, 'optionalAccess', _4 => _4.fastify]) || {}, async (req, res) => {
|
|
116
117
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
117
118
|
const contextData = {
|
|
118
119
|
type: "fastify",
|
|
@@ -129,23 +130,23 @@ function bind(fastify, data, opts = {}) {
|
|
|
129
130
|
headers: req.headers,
|
|
130
131
|
app: fastify3,
|
|
131
132
|
// @ts-expect-error need @fastify/cookie
|
|
132
|
-
getCookie: /* @__PURE__ */
|
|
133
|
+
getCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
133
134
|
// @ts-expect-error need @fastify/cookie
|
|
134
|
-
setCookie: /* @__PURE__ */
|
|
135
|
+
setCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
|
|
135
136
|
// @ts-expect-error need @fastify/cookie
|
|
136
|
-
delCookie: /* @__PURE__ */
|
|
137
|
+
delCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => res.clearCookie(key, {
|
|
137
138
|
url: ""
|
|
138
139
|
}), "delCookie"),
|
|
139
|
-
redirect: /* @__PURE__ */
|
|
140
|
-
setResHeaders: /* @__PURE__ */
|
|
141
|
-
setResStatus: /* @__PURE__ */
|
|
142
|
-
getRequest: /* @__PURE__ */
|
|
143
|
-
getResponse: /* @__PURE__ */
|
|
140
|
+
redirect: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
|
|
141
|
+
setResHeaders: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
|
|
142
|
+
setResStatus: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
143
|
+
getRequest: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => req.raw, "getRequest"),
|
|
144
|
+
getResponse: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => res.raw, "getResponse")
|
|
144
145
|
};
|
|
145
|
-
const context = new (0,
|
|
146
|
+
const context = new (0, _chunk7EMAZGYOjs.Context)(contextData);
|
|
146
147
|
if (http.headers) res.headers(http.headers);
|
|
147
148
|
if (dynamic) {
|
|
148
|
-
aop =
|
|
149
|
+
aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
|
|
149
150
|
globalFilter,
|
|
150
151
|
globalGuards,
|
|
151
152
|
globalPipe
|
|
@@ -166,11 +167,11 @@ function bind(fastify, data, opts = {}) {
|
|
|
166
167
|
done();
|
|
167
168
|
}, fastifyOpts);
|
|
168
169
|
}
|
|
169
|
-
|
|
170
|
+
_chunkVSGYTGHYjs.__name.call(void 0, bind, "bind");
|
|
170
171
|
function Fastify(opts) {
|
|
171
|
-
return
|
|
172
|
+
return _chunkBBNJVYVXjs.Define.call(void 0, "fastify", opts);
|
|
172
173
|
}
|
|
173
|
-
|
|
174
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Fastify, "Fastify");
|
|
174
175
|
|
|
175
176
|
|
|
176
177
|
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-7NWDKK7D.mjs";
|
|
4
4
|
import {
|
|
5
5
|
BadRequestException,
|
|
6
6
|
Context,
|
|
7
7
|
argToReq,
|
|
8
8
|
createControllerMetaMap,
|
|
9
|
-
detectAopDep
|
|
10
|
-
|
|
9
|
+
detectAopDep,
|
|
10
|
+
joinUrl
|
|
11
|
+
} from "../../chunk-SGMQZRP6.mjs";
|
|
11
12
|
import {
|
|
12
13
|
__name
|
|
13
|
-
} from "../../chunk-
|
|
14
|
+
} from "../../chunk-YKP4ODZA.mjs";
|
|
14
15
|
|
|
15
16
|
// src/http/fastify/bind.ts
|
|
16
17
|
import Debug from "debug";
|
|
@@ -112,7 +113,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
112
113
|
globalPipe
|
|
113
114
|
});
|
|
114
115
|
}
|
|
115
|
-
fastify3[http.type](http.prefix
|
|
116
|
+
fastify3[http.type](joinUrl(http.prefix, http.route), define?.fastify || {}, async (req, res) => {
|
|
116
117
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
117
118
|
const contextData = {
|
|
118
119
|
type: "fastify",
|
package/dist/http/h3/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { H3Event, Router, _RequestMiddleware } from 'h3';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { H as
|
|
2
|
+
import { F as Factory } from '../../core-BcKywWLd.mjs';
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-C2SQ9U9V.mjs';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-B_HW7cWh.mjs';
|
|
6
6
|
import 'node:http';
|
|
7
7
|
|
|
8
|
-
interface H3Ctx extends
|
|
8
|
+
interface H3Ctx extends HttpCtx {
|
|
9
9
|
type: 'h3';
|
|
10
10
|
event: H3Event;
|
|
11
11
|
app: Router;
|
package/dist/http/h3/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { H3Event, Router, _RequestMiddleware } from 'h3';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { H as
|
|
2
|
+
import { F as Factory } from '../../core-BGEsBtTG.js';
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-PFPIQWVF.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-B_HW7cWh.js';
|
|
6
6
|
import 'node:http';
|
|
7
7
|
|
|
8
|
-
interface H3Ctx extends
|
|
8
|
+
interface H3Ctx extends HttpCtx {
|
|
9
9
|
type: 'h3';
|
|
10
10
|
event: H3Event;
|
|
11
11
|
app: Router;
|