phecda-server 7.1.4 → 8.0.1
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-MKRHYZCL.mjs → chunk-FI5756JX.mjs} +2 -2
- package/dist/{chunk-P3CS65OP.mjs → chunk-G5IH3TP7.mjs} +81 -21
- package/dist/{chunk-OV3UJLGP.js → chunk-LD7YMHIE.js} +81 -21
- package/dist/{chunk-YRS4ECPT.js → chunk-OLNN4U3O.js} +12 -8
- package/dist/{chunk-5MAGRSEM.mjs → chunk-PFPOEZHH.mjs} +12 -8
- package/dist/{chunk-DPPDWBYO.js → chunk-UYZSUBX4.js} +2 -2
- package/dist/{core-B5yKYkMJ.d.mts → core-BTSHIAyB.d.ts} +2 -1
- package/dist/{core-BRuvL6hY.d.ts → core-D1YYphEn.d.mts} +2 -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/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +30 -30
- package/dist/http/elysia/index.mjs +15 -15
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +27 -27
- package/dist/http/express/index.mjs +14 -14
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +29 -29
- package/dist/http/fastify/index.mjs +15 -15
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +28 -28
- package/dist/http/h3/index.mjs +14 -14
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +26 -26
- package/dist/http/hono/index.mjs +14 -14
- 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 +26 -26
- package/dist/http/hyper-express/index.mjs +14 -14
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +27 -27
- package/dist/http/koa/index.mjs +14 -14
- package/dist/index.d.mts +20 -13
- package/dist/index.d.ts +20 -13
- package/dist/index.js +112 -71
- package/dist/index.mjs +69 -28
- package/dist/{meta-C_eDyXnK.d.ts → meta-DNF6Fl27.d.mts} +11 -9
- package/dist/{meta-C_eDyXnK.d.mts → meta-DNF6Fl27.d.ts} +11 -9
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +16 -16
- package/dist/rpc/bullmq/index.mjs +11 -11
- package/dist/rpc/electron/index.d.mts +3 -3
- package/dist/rpc/electron/index.d.ts +3 -3
- package/dist/rpc/electron/index.js +11 -11
- package/dist/rpc/electron/index.mjs +7 -7
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +9 -9
- 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 -14
- package/dist/rpc/nats/index.mjs +9 -9
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +14 -14
- package/dist/rpc/rabbitmq/index.mjs +9 -9
- 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 -14
- package/dist/rpc/redis/index.mjs +9 -9
- package/dist/rpc/ws/index.d.mts +3 -3
- package/dist/rpc/ws/index.d.ts +3 -3
- package/dist/rpc/ws/index.js +10 -10
- package/dist/rpc/ws/index.mjs +6 -6
- package/dist/test.d.mts +2 -2
- package/dist/test.d.ts +2 -2
- package/dist/test.js +5 -5
- package/dist/test.mjs +4 -4
- package/dist/{types-7-m2wEkP.d.mts → types-BOZ8yE2L.d.mts} +1 -1
- package/dist/{types-BuvMT1ta.d.ts → types-Cosv4nol.d.ts} +1 -1
- package/dist/{types-BKHBmSQN.d.mts → types-DtiHAXQB.d.mts} +1 -1
- package/dist/{types-B6aU8oT-.d.ts → types-YJ55P7A_.d.ts} +1 -1
- package/package.json +3 -4
- package/register/export.mjs +5 -1
- package/register/utils.mjs +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
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 _chunkUYZSUBX4js = require('../../chunk-UYZSUBX4.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkLD7YMHIEjs = require('../../chunk-LD7YMHIE.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
@@ -19,14 +19,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/elysia");
|
|
|
19
19
|
function bind(app, data, opts = {}) {
|
|
20
20
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
21
21
|
const { moduleMap, meta } = data;
|
|
22
|
-
const metaMap =
|
|
23
|
-
const { controller, http,
|
|
24
|
-
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.
|
|
25
|
-
debug(`register method "${
|
|
22
|
+
const metaMap = _chunkLD7YMHIEjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
23
|
+
const { controller, http, method, tag } = meta2.data;
|
|
24
|
+
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
25
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
-
|
|
29
|
+
_chunkLD7YMHIEjs.detectAopDep.call(void 0, meta, {
|
|
30
30
|
addons: [
|
|
31
31
|
...globalAddons,
|
|
32
32
|
...parallelAddons
|
|
@@ -35,29 +35,29 @@ function bind(app, data, opts = {}) {
|
|
|
35
35
|
});
|
|
36
36
|
registerRoute();
|
|
37
37
|
function registerRoute() {
|
|
38
|
-
|
|
38
|
+
_chunkLD7YMHIEjs.Context.applyAddons(globalAddons, app, "elysia");
|
|
39
39
|
if (parallelRoute) {
|
|
40
40
|
const parallelRouter = new (0, _elysia.Elysia)();
|
|
41
|
-
|
|
41
|
+
_chunkLD7YMHIEjs.Context.applyAddons(parallelAddons, app, "elysia");
|
|
42
42
|
parallelRouter.post(parallelRoute, async (c) => {
|
|
43
43
|
const { body } = c;
|
|
44
44
|
async function errorHandler(e) {
|
|
45
|
-
const error = await
|
|
45
|
+
const error = await _chunkLD7YMHIEjs.Context.filterRecord.default(e);
|
|
46
46
|
c.set.status = error.status;
|
|
47
47
|
return error;
|
|
48
48
|
}
|
|
49
49
|
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkLD7YMHIEjs.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
|
if (!item) return resolve(null);
|
|
55
|
-
const { tag,
|
|
56
|
-
debug(`(parallel)invoke method "${
|
|
57
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
58
|
-
const meta2 = metaMap.get(tag)[
|
|
59
|
-
if (!meta2) return resolve(await
|
|
60
|
-
const aop =
|
|
55
|
+
const { tag, method } = item;
|
|
56
|
+
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
57
|
+
if (!metaMap.has(tag)) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
58
|
+
const meta2 = metaMap.get(tag)[method];
|
|
59
|
+
if (!meta2) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
60
|
+
const aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
61
61
|
globalGuards,
|
|
62
62
|
globalFilter,
|
|
63
63
|
globalPipe
|
|
@@ -88,7 +88,7 @@ function bind(app, data, opts = {}) {
|
|
|
88
88
|
throw new Error("elysia can't support getResponse");
|
|
89
89
|
}, "getResponse")
|
|
90
90
|
};
|
|
91
|
-
const context = new (0,
|
|
91
|
+
const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
|
|
92
92
|
context.run(aop, resolve, resolve);
|
|
93
93
|
});
|
|
94
94
|
})).then((ret) => {
|
|
@@ -101,24 +101,24 @@ function bind(app, data, opts = {}) {
|
|
|
101
101
|
app.use(parallelRouter);
|
|
102
102
|
}
|
|
103
103
|
for (const [tag, record] of metaMap) {
|
|
104
|
-
for (const
|
|
105
|
-
const meta2 = metaMap.get(tag)[
|
|
104
|
+
for (const method in record) {
|
|
105
|
+
const meta2 = metaMap.get(tag)[method];
|
|
106
106
|
const { data: { define, addons, http } } = meta2;
|
|
107
107
|
const subApp = new (0, _elysia.Elysia)({
|
|
108
108
|
prefix: ""
|
|
109
109
|
});
|
|
110
|
-
if (!_optionalChain([http, 'optionalAccess', _2 => _2.
|
|
110
|
+
if (!_optionalChain([http, 'optionalAccess', _2 => _2.method])) continue;
|
|
111
111
|
let aop;
|
|
112
112
|
if (!dynamic) {
|
|
113
|
-
aop =
|
|
113
|
+
aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
114
114
|
globalFilter,
|
|
115
115
|
globalGuards,
|
|
116
116
|
globalPipe
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
subApp[http.
|
|
121
|
-
debug(`invoke method "${
|
|
119
|
+
_chunkLD7YMHIEjs.Context.applyAddons(addons, subApp, "elysia");
|
|
120
|
+
subApp[http.method](_chunkLD7YMHIEjs.joinUrl.call(void 0, http.prefix, http.route), async (c) => {
|
|
121
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
122
122
|
const contextData = {
|
|
123
123
|
type: "elysia",
|
|
124
124
|
category: "http",
|
|
@@ -126,7 +126,7 @@ function bind(app, data, opts = {}) {
|
|
|
126
126
|
meta: meta2,
|
|
127
127
|
moduleMap,
|
|
128
128
|
tag,
|
|
129
|
-
|
|
129
|
+
method,
|
|
130
130
|
query: c.query,
|
|
131
131
|
body: c.body,
|
|
132
132
|
params: c.params,
|
|
@@ -149,16 +149,16 @@ function bind(app, data, opts = {}) {
|
|
|
149
149
|
}, "getResponse")
|
|
150
150
|
};
|
|
151
151
|
if (dynamic) {
|
|
152
|
-
aop =
|
|
152
|
+
aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
153
153
|
globalFilter,
|
|
154
154
|
globalGuards,
|
|
155
155
|
globalPipe
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
-
const context = new (0,
|
|
158
|
+
const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
|
|
159
159
|
if (http.headers) c.set.headers = http.headers;
|
|
160
160
|
if (dynamic) {
|
|
161
|
-
aop =
|
|
161
|
+
aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
162
162
|
globalFilter,
|
|
163
163
|
globalGuards,
|
|
164
164
|
globalPipe
|
|
@@ -177,7 +177,7 @@ function bind(app, data, opts = {}) {
|
|
|
177
177
|
}
|
|
178
178
|
_chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
|
|
179
179
|
function Elysia(opts) {
|
|
180
|
-
return
|
|
180
|
+
return _chunkUYZSUBX4js.Define.call(void 0, "elysia", opts);
|
|
181
181
|
}
|
|
182
182
|
_chunk4LLLQOMFjs.__name.call(void 0, Elysia, "Elysia");
|
|
183
183
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-FI5756JX.mjs";
|
|
4
4
|
import {
|
|
5
5
|
BadRequestException,
|
|
6
6
|
Context,
|
|
7
7
|
createControllerMetaMap,
|
|
8
8
|
detectAopDep,
|
|
9
9
|
joinUrl
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-G5IH3TP7.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
13
|
} from "../../chunk-NQ55PA2X.mjs";
|
|
@@ -20,9 +20,9 @@ function bind(app, data, opts = {}) {
|
|
|
20
20
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
21
21
|
const { moduleMap, meta } = data;
|
|
22
22
|
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
23
|
-
const { controller, http,
|
|
24
|
-
if (controller === "http" && http?.
|
|
25
|
-
debug(`register method "${
|
|
23
|
+
const { controller, http, method, tag } = meta2.data;
|
|
24
|
+
if (controller === "http" && http?.method) {
|
|
25
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
@@ -52,11 +52,11 @@ function bind(app, data, opts = {}) {
|
|
|
52
52
|
return Promise.all(body.map((item, i) => {
|
|
53
53
|
return new Promise(async (resolve) => {
|
|
54
54
|
if (!item) return resolve(null);
|
|
55
|
-
const { tag,
|
|
56
|
-
debug(`(parallel)invoke method "${
|
|
55
|
+
const { tag, method } = item;
|
|
56
|
+
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
57
57
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
58
|
-
const meta2 = metaMap.get(tag)[
|
|
59
|
-
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${
|
|
58
|
+
const meta2 = metaMap.get(tag)[method];
|
|
59
|
+
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${method}" in "${tag}" doesn't exist`)));
|
|
60
60
|
const aop = Context.getAop(meta2, {
|
|
61
61
|
globalGuards,
|
|
62
62
|
globalFilter,
|
|
@@ -101,13 +101,13 @@ function bind(app, data, opts = {}) {
|
|
|
101
101
|
app.use(parallelRouter);
|
|
102
102
|
}
|
|
103
103
|
for (const [tag, record] of metaMap) {
|
|
104
|
-
for (const
|
|
105
|
-
const meta2 = metaMap.get(tag)[
|
|
104
|
+
for (const method in record) {
|
|
105
|
+
const meta2 = metaMap.get(tag)[method];
|
|
106
106
|
const { data: { define, addons, http } } = meta2;
|
|
107
107
|
const subApp = new App({
|
|
108
108
|
prefix: ""
|
|
109
109
|
});
|
|
110
|
-
if (!http?.
|
|
110
|
+
if (!http?.method) continue;
|
|
111
111
|
let aop;
|
|
112
112
|
if (!dynamic) {
|
|
113
113
|
aop = Context.getAop(meta2, {
|
|
@@ -117,8 +117,8 @@ function bind(app, data, opts = {}) {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
Context.applyAddons(addons, subApp, "elysia");
|
|
120
|
-
subApp[http.
|
|
121
|
-
debug(`invoke method "${
|
|
120
|
+
subApp[http.method](joinUrl(http.prefix, http.route), async (c) => {
|
|
121
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
122
122
|
const contextData = {
|
|
123
123
|
type: "elysia",
|
|
124
124
|
category: "http",
|
|
@@ -126,7 +126,7 @@ function bind(app, data, opts = {}) {
|
|
|
126
126
|
meta: meta2,
|
|
127
127
|
moduleMap,
|
|
128
128
|
tag,
|
|
129
|
-
|
|
129
|
+
method,
|
|
130
130
|
query: c.query,
|
|
131
131
|
body: c.body,
|
|
132
132
|
params: c.params,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, RequestHandler } from 'express';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-DtiHAXQB.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-D1YYphEn.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface ExpressCtx extends HttpCtx {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, RequestHandler } from 'express';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-Cosv4nol.js';
|
|
3
|
+
import { F as Factory } from '../../core-BTSHIAyB.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface ExpressCtx extends HttpCtx {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkLD7YMHIEjs = require('../../chunk-LD7YMHIE.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -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 =
|
|
22
|
-
const { controller, http,
|
|
23
|
-
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.
|
|
24
|
-
debug(`register method "${
|
|
21
|
+
const metaMap = _chunkLD7YMHIEjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
|
+
const { controller, http, method, tag } = meta2.data;
|
|
23
|
+
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
24
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunkLD7YMHIEjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -38,28 +38,28 @@ function bind(router, data, opts = {}) {
|
|
|
38
38
|
registerRoute();
|
|
39
39
|
});
|
|
40
40
|
function registerRoute() {
|
|
41
|
-
|
|
41
|
+
_chunkLD7YMHIEjs.Context.applyAddons(globalAddons, router, "express");
|
|
42
42
|
if (parallelRoute) {
|
|
43
43
|
const subRouter = _express.Router.call(void 0, );
|
|
44
|
-
|
|
44
|
+
_chunkLD7YMHIEjs.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 _chunkLD7YMHIEjs.Context.filterRecord.default(e);
|
|
49
49
|
return res.status(error.status).json(error);
|
|
50
50
|
}
|
|
51
51
|
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
52
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
52
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkLD7YMHIEjs.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
|
if (!item) return resolve(null);
|
|
57
|
-
const { tag,
|
|
58
|
-
debug(`(parallel)invoke method "${
|
|
59
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
60
|
-
const meta2 = metaMap.get(tag)[
|
|
61
|
-
if (!meta2) return resolve(await
|
|
62
|
-
const aop =
|
|
57
|
+
const { tag, method } = item;
|
|
58
|
+
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
59
|
+
if (!metaMap.has(tag)) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
60
|
+
const meta2 = metaMap.get(tag)[method];
|
|
61
|
+
if (!meta2) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
62
|
+
const aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
63
63
|
globalFilter,
|
|
64
64
|
globalGuards,
|
|
65
65
|
globalPipe
|
|
@@ -87,7 +87,7 @@ function bind(router, data, opts = {}) {
|
|
|
87
87
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req, "getRequest"),
|
|
88
88
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res, "getResponse")
|
|
89
89
|
};
|
|
90
|
-
const context = new (0,
|
|
90
|
+
const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
|
|
91
91
|
context.run(aop, resolve, resolve);
|
|
92
92
|
});
|
|
93
93
|
})).then((ret) => {
|
|
@@ -100,22 +100,22 @@ function bind(router, data, opts = {}) {
|
|
|
100
100
|
router.post(parallelRoute, subRouter);
|
|
101
101
|
}
|
|
102
102
|
for (const [tag, record] of metaMap) {
|
|
103
|
-
for (const
|
|
104
|
-
const meta2 = metaMap.get(tag)[
|
|
103
|
+
for (const method in record) {
|
|
104
|
+
const meta2 = metaMap.get(tag)[method];
|
|
105
105
|
const { data: { addons, http } } = meta2;
|
|
106
|
-
if (!_optionalChain([http, 'optionalAccess', _2 => _2.
|
|
106
|
+
if (!_optionalChain([http, 'optionalAccess', _2 => _2.method])) continue;
|
|
107
107
|
let aop;
|
|
108
108
|
if (!dynamic) {
|
|
109
|
-
aop =
|
|
109
|
+
aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
110
110
|
globalFilter,
|
|
111
111
|
globalGuards,
|
|
112
112
|
globalPipe
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
const subRouter = _express.Router.call(void 0, );
|
|
116
|
-
|
|
117
|
-
subRouter[http.
|
|
118
|
-
debug(`invoke method "${
|
|
116
|
+
_chunkLD7YMHIEjs.Context.applyAddons(addons, subRouter, "express");
|
|
117
|
+
subRouter[http.method](_chunkLD7YMHIEjs.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
|
|
118
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
119
119
|
const contextData = {
|
|
120
120
|
type: "express",
|
|
121
121
|
category: "http",
|
|
@@ -124,7 +124,7 @@ function bind(router, data, opts = {}) {
|
|
|
124
124
|
response: res,
|
|
125
125
|
moduleMap,
|
|
126
126
|
tag,
|
|
127
|
-
|
|
127
|
+
method,
|
|
128
128
|
query: req.query,
|
|
129
129
|
body: req.body,
|
|
130
130
|
params: req.params,
|
|
@@ -142,10 +142,10 @@ function bind(router, data, opts = {}) {
|
|
|
142
142
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req, "getRequest"),
|
|
143
143
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res, "getResponse")
|
|
144
144
|
};
|
|
145
|
-
const context = new (0,
|
|
145
|
+
const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
|
|
146
146
|
if (http.headers) res.set(http.headers);
|
|
147
147
|
if (dynamic) {
|
|
148
|
-
aop =
|
|
148
|
+
aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
149
149
|
globalFilter,
|
|
150
150
|
globalGuards,
|
|
151
151
|
globalPipe
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
joinUrl
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-G5IH3TP7.mjs";
|
|
8
8
|
import {
|
|
9
9
|
HMR,
|
|
10
10
|
__name
|
|
@@ -19,9 +19,9 @@ function bind(router, data, opts = {}) {
|
|
|
19
19
|
const { moduleMap, meta } = data;
|
|
20
20
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
21
21
|
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
22
|
-
const { controller, http,
|
|
23
|
-
if (controller === "http" && http?.
|
|
24
|
-
debug(`register method "${
|
|
22
|
+
const { controller, http, method, tag } = meta2.data;
|
|
23
|
+
if (controller === "http" && http?.method) {
|
|
24
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
@@ -54,11 +54,11 @@ function bind(router, data, opts = {}) {
|
|
|
54
54
|
return Promise.all(body.map((item, i) => {
|
|
55
55
|
return new Promise(async (resolve) => {
|
|
56
56
|
if (!item) return resolve(null);
|
|
57
|
-
const { tag,
|
|
58
|
-
debug(`(parallel)invoke method "${
|
|
57
|
+
const { tag, method } = item;
|
|
58
|
+
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
59
59
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
60
|
-
const meta2 = metaMap.get(tag)[
|
|
61
|
-
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${
|
|
60
|
+
const meta2 = metaMap.get(tag)[method];
|
|
61
|
+
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${method}" in "${tag}" doesn't exist`)));
|
|
62
62
|
const aop = Context.getAop(meta2, {
|
|
63
63
|
globalFilter,
|
|
64
64
|
globalGuards,
|
|
@@ -100,10 +100,10 @@ function bind(router, data, opts = {}) {
|
|
|
100
100
|
router.post(parallelRoute, subRouter);
|
|
101
101
|
}
|
|
102
102
|
for (const [tag, record] of metaMap) {
|
|
103
|
-
for (const
|
|
104
|
-
const meta2 = metaMap.get(tag)[
|
|
103
|
+
for (const method in record) {
|
|
104
|
+
const meta2 = metaMap.get(tag)[method];
|
|
105
105
|
const { data: { addons, http } } = meta2;
|
|
106
|
-
if (!http?.
|
|
106
|
+
if (!http?.method) continue;
|
|
107
107
|
let aop;
|
|
108
108
|
if (!dynamic) {
|
|
109
109
|
aop = Context.getAop(meta2, {
|
|
@@ -114,8 +114,8 @@ function bind(router, data, opts = {}) {
|
|
|
114
114
|
}
|
|
115
115
|
const subRouter = Router();
|
|
116
116
|
Context.applyAddons(addons, subRouter, "express");
|
|
117
|
-
subRouter[http.
|
|
118
|
-
debug(`invoke method "${
|
|
117
|
+
subRouter[http.method](joinUrl(http.prefix, http.route), async (req, res, next) => {
|
|
118
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
119
119
|
const contextData = {
|
|
120
120
|
type: "express",
|
|
121
121
|
category: "http",
|
|
@@ -124,7 +124,7 @@ function bind(router, data, opts = {}) {
|
|
|
124
124
|
response: res,
|
|
125
125
|
moduleMap,
|
|
126
126
|
tag,
|
|
127
|
-
|
|
127
|
+
method,
|
|
128
128
|
query: req.query,
|
|
129
129
|
body: req.body,
|
|
130
130
|
params: req.params,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-DtiHAXQB.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-D1YYphEn.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface FastifyCtx extends HttpCtx {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-Cosv4nol.js';
|
|
3
|
+
import { F as Factory } from '../../core-BTSHIAyB.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface FastifyCtx extends HttpCtx {
|
|
@@ -1,13 +1,13 @@
|
|
|
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 _chunkUYZSUBX4js = require('../../chunk-UYZSUBX4.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkLD7YMHIEjs = require('../../chunk-LD7YMHIE.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.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, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, fastifyOpts, dynamic = false } = opts;
|
|
20
20
|
const { moduleMap, meta } = data;
|
|
21
|
-
const metaMap =
|
|
22
|
-
const { controller, http,
|
|
23
|
-
if (controller === "http" && _optionalChain([http, 'optionalAccess', _2 => _2.
|
|
24
|
-
debug(`register method "${
|
|
21
|
+
const metaMap = _chunkLD7YMHIEjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
|
+
const { controller, http, method, tag } = meta2.data;
|
|
23
|
+
if (controller === "http" && _optionalChain([http, 'optionalAccess', _2 => _2.method])) {
|
|
24
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunkLD7YMHIEjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -33,28 +33,28 @@ function bind(fastify, data, opts = {}) {
|
|
|
33
33
|
guards: globalGuards
|
|
34
34
|
});
|
|
35
35
|
fastify.register(async (fastify2, _, done) => {
|
|
36
|
-
|
|
36
|
+
_chunkLD7YMHIEjs.Context.applyAddons(globalAddons, fastify2, "fastify");
|
|
37
37
|
if (parallelRoute) {
|
|
38
38
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
39
|
-
|
|
39
|
+
_chunkLD7YMHIEjs.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 _chunkLD7YMHIEjs.Context.filterRecord.default(e);
|
|
44
44
|
return res.status(error.status).send(error);
|
|
45
45
|
}
|
|
46
46
|
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
47
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkLD7YMHIEjs.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
|
if (!item) return resolve(null);
|
|
52
|
-
const { tag,
|
|
53
|
-
debug(`(parallel)invoke method "${
|
|
54
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
55
|
-
const meta2 = metaMap.get(tag)[
|
|
56
|
-
if (!meta2) return resolve(await
|
|
57
|
-
const aop =
|
|
52
|
+
const { tag, method } = item;
|
|
53
|
+
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
54
|
+
if (!metaMap.has(tag)) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
55
|
+
const meta2 = metaMap.get(tag)[method];
|
|
56
|
+
if (!meta2) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
57
|
+
const aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
58
58
|
globalFilter,
|
|
59
59
|
globalGuards,
|
|
60
60
|
globalPipe
|
|
@@ -82,7 +82,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
82
82
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req.raw, "getRequest"),
|
|
83
83
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res.raw, "getResponse")
|
|
84
84
|
};
|
|
85
|
-
const context = new (0,
|
|
85
|
+
const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
|
|
86
86
|
context.run(aop, resolve, resolve);
|
|
87
87
|
});
|
|
88
88
|
})).then((ret) => {
|
|
@@ -96,22 +96,22 @@ function bind(fastify, data, opts = {}) {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
for (const [tag, record] of metaMap) {
|
|
99
|
-
for (const
|
|
100
|
-
const meta2 = metaMap.get(tag)[
|
|
99
|
+
for (const method in record) {
|
|
100
|
+
const meta2 = metaMap.get(tag)[method];
|
|
101
101
|
const { data: { addons, define, http } } = meta2;
|
|
102
|
-
if (!_optionalChain([http, 'optionalAccess', _3 => _3.
|
|
102
|
+
if (!_optionalChain([http, 'optionalAccess', _3 => _3.method])) continue;
|
|
103
103
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
104
|
-
|
|
104
|
+
_chunkLD7YMHIEjs.Context.applyAddons(addons, fastify3, "fastify");
|
|
105
105
|
let aop;
|
|
106
106
|
if (!dynamic) {
|
|
107
|
-
aop =
|
|
107
|
+
aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
108
108
|
globalFilter,
|
|
109
109
|
globalGuards,
|
|
110
110
|
globalPipe
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
fastify3[http.
|
|
114
|
-
debug(`invoke method "${
|
|
113
|
+
fastify3[http.method](_chunkLD7YMHIEjs.joinUrl.call(void 0, http.prefix, http.route), _optionalChain([define, 'optionalAccess', _4 => _4.fastify]) || {}, async (req, res) => {
|
|
114
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
115
115
|
const contextData = {
|
|
116
116
|
type: "fastify",
|
|
117
117
|
category: "http",
|
|
@@ -120,7 +120,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
120
120
|
response: res,
|
|
121
121
|
moduleMap,
|
|
122
122
|
tag,
|
|
123
|
-
|
|
123
|
+
method,
|
|
124
124
|
query: req.query,
|
|
125
125
|
body: req.body,
|
|
126
126
|
params: req.params,
|
|
@@ -140,10 +140,10 @@ function bind(fastify, data, opts = {}) {
|
|
|
140
140
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req.raw, "getRequest"),
|
|
141
141
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res.raw, "getResponse")
|
|
142
142
|
};
|
|
143
|
-
const context = new (0,
|
|
143
|
+
const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
|
|
144
144
|
if (http.headers) res.headers(http.headers);
|
|
145
145
|
if (dynamic) {
|
|
146
|
-
aop =
|
|
146
|
+
aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
147
147
|
globalFilter,
|
|
148
148
|
globalGuards,
|
|
149
149
|
globalPipe
|
|
@@ -166,7 +166,7 @@ function bind(fastify, data, opts = {}) {
|
|
|
166
166
|
}
|
|
167
167
|
_chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
|
|
168
168
|
function Fastify(opts) {
|
|
169
|
-
return
|
|
169
|
+
return _chunkUYZSUBX4js.Define.call(void 0, "fastify", opts);
|
|
170
170
|
}
|
|
171
171
|
_chunk4LLLQOMFjs.__name.call(void 0, Fastify, "Fastify");
|
|
172
172
|
|