phecda-server 7.0.2 → 7.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-ZWPOWMZP.js → chunk-JTSD2LIG.js} +10 -6
- package/dist/{chunk-XKK2SQ7W.js → chunk-OV3UJLGP.js} +20 -6
- package/dist/{chunk-E7EAPAGM.mjs → chunk-P3CS65OP.mjs} +20 -6
- package/dist/{chunk-AIAO6SV6.mjs → chunk-TQSHE4PZ.mjs} +10 -6
- package/dist/{core-DbqWh47p.d.mts → core-B5yKYkMJ.d.mts} +1 -1
- package/dist/{core-Rq7BhPHE.d.ts → core-BRuvL6hY.d.ts} +1 -1
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +2 -2
- package/dist/helper.mjs +1 -1
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +17 -17
- package/dist/http/elysia/index.mjs +1 -1
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +16 -16
- package/dist/http/express/index.mjs +1 -1
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +16 -16
- package/dist/http/fastify/index.mjs +1 -1
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +17 -17
- package/dist/http/h3/index.mjs +1 -1
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +14 -14
- package/dist/http/hono/index.mjs +1 -1
- 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 +15 -15
- package/dist/http/hyper-express/index.mjs +1 -1
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +16 -16
- package/dist/http/koa/index.mjs +1 -1
- package/dist/index.d.mts +27 -9
- package/dist/index.d.ts +27 -9
- package/dist/index.js +60 -24
- package/dist/index.mjs +38 -2
- package/dist/{meta-BoS1E-Nz.d.mts → meta-C_eDyXnK.d.mts} +2 -0
- package/dist/{meta-BoS1E-Nz.d.ts → meta-C_eDyXnK.d.ts} +2 -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 +6 -6
- package/dist/rpc/bullmq/index.mjs +1 -1
- package/dist/rpc/electron/index.d.mts +3 -3
- package/dist/rpc/electron/index.d.ts +3 -3
- package/dist/rpc/electron/index.js +5 -5
- package/dist/rpc/electron/index.mjs +1 -1
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +6 -6
- package/dist/rpc/kafka/index.mjs +1 -1
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +6 -6
- package/dist/rpc/nats/index.mjs +1 -1
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +6 -6
- package/dist/rpc/rabbitmq/index.mjs +1 -1
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +6 -6
- package/dist/rpc/redis/index.mjs +1 -1
- package/dist/rpc/ws/index.d.mts +3 -3
- package/dist/rpc/ws/index.d.ts +3 -3
- package/dist/rpc/ws/index.js +5 -5
- package/dist/rpc/ws/index.mjs +1 -1
- package/dist/test.d.mts +2 -2
- package/dist/test.d.ts +2 -2
- package/dist/test.js +2 -2
- package/dist/test.mjs +1 -1
- package/dist/{types-E-rqlg3-.d.mts → types-7-m2wEkP.d.mts} +1 -1
- package/dist/{types-CInz3bD0.d.ts → types-B6aU8oT-.d.ts} +1 -1
- package/dist/{types-SCJZFCYt.d.mts → types-BKHBmSQN.d.mts} +1 -1
- package/dist/{types-xruyYmyu.d.ts → types-BuvMT1ta.d.ts} +1 -1
- package/package.json +2 -2
- package/register/export.mjs +5 -1
|
@@ -247,13 +247,17 @@ function getMetaFromInstance(instance, tag, name) {
|
|
|
247
247
|
...meta[baseMeta.controller]
|
|
248
248
|
};
|
|
249
249
|
const params = _phecdacore.getMetaParams.call(void 0, instance, i).map((item) => _phecdacore.getMergedMeta.call(void 0, instance, i, item));
|
|
250
|
-
|
|
251
|
-
if (!item.pipe) item.pipe = meta.pipe || baseMeta.pipe;
|
|
252
|
-
if (!item.define) item.define = {};
|
|
253
|
-
item.index = index;
|
|
254
|
-
});
|
|
250
|
+
metaData.rawMeta = meta;
|
|
255
251
|
metaData.ctxs = ctxs;
|
|
256
|
-
metaData.params = params
|
|
252
|
+
metaData.params = params.map((item, index) => {
|
|
253
|
+
return {
|
|
254
|
+
...item,
|
|
255
|
+
pipe: item.pipe || meta.pipe || baseMeta.pipe,
|
|
256
|
+
define: item.define || {},
|
|
257
|
+
index,
|
|
258
|
+
rawMeta: item
|
|
259
|
+
};
|
|
260
|
+
});
|
|
257
261
|
metaData.filter = meta.filter || baseMeta.filter;
|
|
258
262
|
metaData.define = {
|
|
259
263
|
...baseMeta.define,
|
|
@@ -16,11 +16,6 @@ var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefau
|
|
|
16
16
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
// src/pipe.ts
|
|
20
|
-
var defaultPipe = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, ({ arg }) => {
|
|
21
|
-
return arg;
|
|
22
|
-
}, "defaultPipe");
|
|
23
|
-
|
|
24
19
|
// src/exception/base.ts
|
|
25
20
|
var Exception = class extends Error {
|
|
26
21
|
static {
|
|
@@ -202,6 +197,25 @@ var WorkerException = class extends Exception {
|
|
|
202
197
|
}
|
|
203
198
|
};
|
|
204
199
|
|
|
200
|
+
// src/pipe.ts
|
|
201
|
+
var defaultPipe = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, async ({ arg, reflect, rawMeta, index }) => {
|
|
202
|
+
if (arg !== void 0 && [
|
|
203
|
+
Number,
|
|
204
|
+
Boolean,
|
|
205
|
+
String
|
|
206
|
+
].includes(reflect)) arg = reflect(arg);
|
|
207
|
+
if (rawMeta.required && arg === void 0) throw new ValidateException(`param ${index} is required`);
|
|
208
|
+
if (rawMeta.rules) {
|
|
209
|
+
for (const rule of rawMeta.rules) {
|
|
210
|
+
let res = rule(arg);
|
|
211
|
+
if (res instanceof Promise) res = await res;
|
|
212
|
+
if (typeof res === "string") throw new ValidateException(res);
|
|
213
|
+
if (res === false) throw new ValidateException(`validation failed for param ${index}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return arg;
|
|
217
|
+
}, "defaultPipe");
|
|
218
|
+
|
|
205
219
|
// src/filter.ts
|
|
206
220
|
var defaultFilter = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (e) => {
|
|
207
221
|
if (!(e instanceof Exception)) {
|
|
@@ -530,4 +544,4 @@ _chunk4LLLQOMFjs.__name.call(void 0, joinUrl, "joinUrl");
|
|
|
530
544
|
|
|
531
545
|
|
|
532
546
|
|
|
533
|
-
exports.
|
|
547
|
+
exports.Exception = Exception; exports.UndefinedException = UndefinedException; exports.ValidateException = ValidateException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.TimerException = TimerException; exports.WorkerException = WorkerException; exports.defaultPipe = defaultPipe; exports.Context = Context; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addAddon = addAddon; exports.resolveDep = resolveDep; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep; exports.joinUrl = joinUrl;
|
|
@@ -16,11 +16,6 @@ import pc2 from "picocolors";
|
|
|
16
16
|
import Debug from "debug";
|
|
17
17
|
import pc from "picocolors";
|
|
18
18
|
|
|
19
|
-
// src/pipe.ts
|
|
20
|
-
var defaultPipe = /* @__PURE__ */ __name(({ arg }) => {
|
|
21
|
-
return arg;
|
|
22
|
-
}, "defaultPipe");
|
|
23
|
-
|
|
24
19
|
// src/exception/base.ts
|
|
25
20
|
var Exception = class extends Error {
|
|
26
21
|
static {
|
|
@@ -202,6 +197,25 @@ var WorkerException = class extends Exception {
|
|
|
202
197
|
}
|
|
203
198
|
};
|
|
204
199
|
|
|
200
|
+
// src/pipe.ts
|
|
201
|
+
var defaultPipe = /* @__PURE__ */ __name(async ({ arg, reflect, rawMeta, index }) => {
|
|
202
|
+
if (arg !== void 0 && [
|
|
203
|
+
Number,
|
|
204
|
+
Boolean,
|
|
205
|
+
String
|
|
206
|
+
].includes(reflect)) arg = reflect(arg);
|
|
207
|
+
if (rawMeta.required && arg === void 0) throw new ValidateException(`param ${index} is required`);
|
|
208
|
+
if (rawMeta.rules) {
|
|
209
|
+
for (const rule of rawMeta.rules) {
|
|
210
|
+
let res = rule(arg);
|
|
211
|
+
if (res instanceof Promise) res = await res;
|
|
212
|
+
if (typeof res === "string") throw new ValidateException(res);
|
|
213
|
+
if (res === false) throw new ValidateException(`validation failed for param ${index}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return arg;
|
|
217
|
+
}, "defaultPipe");
|
|
218
|
+
|
|
205
219
|
// src/filter.ts
|
|
206
220
|
var defaultFilter = /* @__PURE__ */ __name((e) => {
|
|
207
221
|
if (!(e instanceof Exception)) {
|
|
@@ -501,7 +515,6 @@ function joinUrl(base, ...paths) {
|
|
|
501
515
|
__name(joinUrl, "joinUrl");
|
|
502
516
|
|
|
503
517
|
export {
|
|
504
|
-
defaultPipe,
|
|
505
518
|
Exception,
|
|
506
519
|
UndefinedException,
|
|
507
520
|
ValidateException,
|
|
@@ -519,6 +532,7 @@ export {
|
|
|
519
532
|
FrameworkException,
|
|
520
533
|
TimerException,
|
|
521
534
|
WorkerException,
|
|
535
|
+
defaultPipe,
|
|
522
536
|
Context,
|
|
523
537
|
addPipe,
|
|
524
538
|
addFilter,
|
|
@@ -247,13 +247,17 @@ function getMetaFromInstance(instance, tag, name) {
|
|
|
247
247
|
...meta[baseMeta.controller]
|
|
248
248
|
};
|
|
249
249
|
const params = getMetaParams(instance, i).map((item) => getMergedMeta(instance, i, item));
|
|
250
|
-
|
|
251
|
-
if (!item.pipe) item.pipe = meta.pipe || baseMeta.pipe;
|
|
252
|
-
if (!item.define) item.define = {};
|
|
253
|
-
item.index = index;
|
|
254
|
-
});
|
|
250
|
+
metaData.rawMeta = meta;
|
|
255
251
|
metaData.ctxs = ctxs;
|
|
256
|
-
metaData.params = params
|
|
252
|
+
metaData.params = params.map((item, index) => {
|
|
253
|
+
return {
|
|
254
|
+
...item,
|
|
255
|
+
pipe: item.pipe || meta.pipe || baseMeta.pipe,
|
|
256
|
+
define: item.define || {},
|
|
257
|
+
index,
|
|
258
|
+
rawMeta: item
|
|
259
|
+
};
|
|
260
|
+
});
|
|
257
261
|
metaData.filter = meta.filter || baseMeta.filter;
|
|
258
262
|
metaData.define = {
|
|
259
263
|
...baseMeta.define,
|
package/dist/helper.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Meta, a as ControllerMeta } from './meta-
|
|
1
|
+
import { M as Meta, a as ControllerMeta } from './meta-C_eDyXnK.mjs';
|
|
2
2
|
import { Construct } from 'phecda-core';
|
|
3
3
|
|
|
4
4
|
declare function HMR(cb: (oldModels: Construct[], newModels: Construct[]) => any): void;
|
package/dist/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Meta, a as ControllerMeta } from './meta-
|
|
1
|
+
import { M as Meta, a as ControllerMeta } from './meta-C_eDyXnK.js';
|
|
2
2
|
import { Construct } from 'phecda-core';
|
|
3
3
|
|
|
4
4
|
declare function HMR(cb: (oldModels: Construct[], newModels: Construct[]) => any): void;
|
package/dist/helper.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkOV3UJLGPjs = require('./chunk-OV3UJLGP.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -21,4 +21,4 @@ var _chunk4LLLQOMFjs = require('./chunk-4LLLQOMF.js');
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
exports.HMR = _chunk4LLLQOMFjs.HMR; exports.RELAUNCH = _chunk4LLLQOMFjs.RELAUNCH; exports.RELOAD = _chunk4LLLQOMFjs.RELOAD; exports.createControllerMetaMap =
|
|
24
|
+
exports.HMR = _chunk4LLLQOMFjs.HMR; exports.RELAUNCH = _chunk4LLLQOMFjs.RELAUNCH; exports.RELOAD = _chunk4LLLQOMFjs.RELOAD; exports.createControllerMetaMap = _chunkOV3UJLGPjs.createControllerMetaMap; exports.detectAopDep = _chunkOV3UJLGPjs.detectAopDep; exports.joinUrl = _chunkOV3UJLGPjs.joinUrl; exports.mergeObject = _chunkOV3UJLGPjs.mergeObject; exports.resolveDep = _chunkOV3UJLGPjs.resolveDep; exports.shallowClone = _chunkOV3UJLGPjs.shallowClone;
|
package/dist/helper.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
|
|
2
2
|
import { BaseMacro } from 'elysia/dist/types';
|
|
3
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-BKHBmSQN.mjs';
|
|
4
|
+
import { F as Factory } from '../../core-B5yKYkMJ.mjs';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-C_eDyXnK.mjs';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
9
|
interface ElysiaCtx extends HttpCtx {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
|
|
2
2
|
import { BaseMacro } from 'elysia/dist/types';
|
|
3
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-BuvMT1ta.js';
|
|
4
|
+
import { F as Factory } from '../../core-BRuvL6hY.js';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-C_eDyXnK.js';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
9
|
interface ElysiaCtx extends HttpCtx {
|
|
@@ -7,7 +7,7 @@ var _chunkDPPDWBYOjs = require('../../chunk-DPPDWBYO.js');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkOV3UJLGPjs = require('../../chunk-OV3UJLGP.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 =
|
|
22
|
+
const metaMap = _chunkOV3UJLGPjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
23
23
|
const { controller, http, func, tag } = meta2.data;
|
|
24
24
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
25
25
|
debug(`register method "${func}" in module "${tag}"`);
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
-
|
|
29
|
+
_chunkOV3UJLGPjs.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
|
+
_chunkOV3UJLGPjs.Context.applyAddons(globalAddons, app, "elysia");
|
|
39
39
|
if (parallelRoute) {
|
|
40
40
|
const parallelRouter = new (0, _elysia.Elysia)();
|
|
41
|
-
|
|
41
|
+
_chunkOV3UJLGPjs.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 _chunkOV3UJLGPjs.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, _chunkOV3UJLGPjs.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
55
|
const { tag, func } = item;
|
|
56
56
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
57
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
57
|
+
if (!metaMap.has(tag)) return resolve(await _chunkOV3UJLGPjs.Context.filterRecord.default(new (0, _chunkOV3UJLGPjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
58
58
|
const meta2 = metaMap.get(tag)[func];
|
|
59
|
-
if (!meta2) return resolve(await
|
|
60
|
-
const aop =
|
|
59
|
+
if (!meta2) return resolve(await _chunkOV3UJLGPjs.Context.filterRecord.default(new (0, _chunkOV3UJLGPjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
60
|
+
const aop = _chunkOV3UJLGPjs.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, _chunkOV3UJLGPjs.Context)(contextData);
|
|
92
92
|
context.run(aop, resolve, resolve);
|
|
93
93
|
});
|
|
94
94
|
})).then((ret) => {
|
|
@@ -110,14 +110,14 @@ function bind(app, data, opts = {}) {
|
|
|
110
110
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
111
111
|
let aop;
|
|
112
112
|
if (!dynamic) {
|
|
113
|
-
aop =
|
|
113
|
+
aop = _chunkOV3UJLGPjs.Context.getAop(meta2, {
|
|
114
114
|
globalFilter,
|
|
115
115
|
globalGuards,
|
|
116
116
|
globalPipe
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
subApp[http.type](
|
|
119
|
+
_chunkOV3UJLGPjs.Context.applyAddons(addons, subApp, "elysia");
|
|
120
|
+
subApp[http.type](_chunkOV3UJLGPjs.joinUrl.call(void 0, http.prefix, http.route), async (c) => {
|
|
121
121
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
122
122
|
const contextData = {
|
|
123
123
|
type: "elysia",
|
|
@@ -149,16 +149,16 @@ function bind(app, data, opts = {}) {
|
|
|
149
149
|
}, "getResponse")
|
|
150
150
|
};
|
|
151
151
|
if (dynamic) {
|
|
152
|
-
aop =
|
|
152
|
+
aop = _chunkOV3UJLGPjs.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, _chunkOV3UJLGPjs.Context)(contextData);
|
|
159
159
|
if (http.headers) c.set.headers = http.headers;
|
|
160
160
|
if (dynamic) {
|
|
161
|
-
aop =
|
|
161
|
+
aop = _chunkOV3UJLGPjs.Context.getAop(meta2, {
|
|
162
162
|
globalFilter,
|
|
163
163
|
globalGuards,
|
|
164
164
|
globalPipe
|
|
@@ -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-BKHBmSQN.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-B5yKYkMJ.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-C_eDyXnK.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-BuvMT1ta.js';
|
|
3
|
+
import { F as Factory } from '../../core-BRuvL6hY.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-C_eDyXnK.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 _chunkOV3UJLGPjs = require('../../chunk-OV3UJLGP.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 =
|
|
21
|
+
const metaMap = _chunkOV3UJLGPjs.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
|
+
_chunkOV3UJLGPjs.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
|
+
_chunkOV3UJLGPjs.Context.applyAddons(globalAddons, router, "express");
|
|
42
42
|
if (parallelRoute) {
|
|
43
43
|
const subRouter = _express.Router.call(void 0, );
|
|
44
|
-
|
|
44
|
+
_chunkOV3UJLGPjs.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 _chunkOV3UJLGPjs.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, _chunkOV3UJLGPjs.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
57
|
const { tag, func } = item;
|
|
58
58
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
59
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
59
|
+
if (!metaMap.has(tag)) return resolve(await _chunkOV3UJLGPjs.Context.filterRecord.default(new (0, _chunkOV3UJLGPjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
60
60
|
const meta2 = metaMap.get(tag)[func];
|
|
61
|
-
if (!meta2) return resolve(await
|
|
62
|
-
const aop =
|
|
61
|
+
if (!meta2) return resolve(await _chunkOV3UJLGPjs.Context.filterRecord.default(new (0, _chunkOV3UJLGPjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
62
|
+
const aop = _chunkOV3UJLGPjs.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, _chunkOV3UJLGPjs.Context)(contextData);
|
|
91
91
|
context.run(aop, resolve, resolve);
|
|
92
92
|
});
|
|
93
93
|
})).then((ret) => {
|
|
@@ -106,15 +106,15 @@ function bind(router, data, opts = {}) {
|
|
|
106
106
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
107
107
|
let aop;
|
|
108
108
|
if (!dynamic) {
|
|
109
|
-
aop =
|
|
109
|
+
aop = _chunkOV3UJLGPjs.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.type](
|
|
116
|
+
_chunkOV3UJLGPjs.Context.applyAddons(addons, subRouter, "express");
|
|
117
|
+
subRouter[http.type](_chunkOV3UJLGPjs.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
|
|
118
118
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
119
119
|
const contextData = {
|
|
120
120
|
type: "express",
|
|
@@ -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, _chunkOV3UJLGPjs.Context)(contextData);
|
|
146
146
|
if (http.headers) res.set(http.headers);
|
|
147
147
|
if (dynamic) {
|
|
148
|
-
aop =
|
|
148
|
+
aop = _chunkOV3UJLGPjs.Context.getAop(meta2, {
|
|
149
149
|
globalFilter,
|
|
150
150
|
globalGuards,
|
|
151
151
|
globalPipe
|
|
@@ -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-BKHBmSQN.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-B5yKYkMJ.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-C_eDyXnK.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-BuvMT1ta.js';
|
|
3
|
+
import { F as Factory } from '../../core-BRuvL6hY.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-C_eDyXnK.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface FastifyCtx extends HttpCtx {
|
|
@@ -7,7 +7,7 @@ var _chunkDPPDWBYOjs = require('../../chunk-DPPDWBYO.js');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkOV3UJLGPjs = require('../../chunk-OV3UJLGP.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 =
|
|
21
|
+
const metaMap = _chunkOV3UJLGPjs.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
|
+
_chunkOV3UJLGPjs.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
|
+
_chunkOV3UJLGPjs.Context.applyAddons(globalAddons, fastify2, "fastify");
|
|
37
37
|
if (parallelRoute) {
|
|
38
38
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
39
|
-
|
|
39
|
+
_chunkOV3UJLGPjs.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 _chunkOV3UJLGPjs.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, _chunkOV3UJLGPjs.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
52
|
const { tag, func } = item;
|
|
53
53
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
54
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
54
|
+
if (!metaMap.has(tag)) return resolve(await _chunkOV3UJLGPjs.Context.filterRecord.default(new (0, _chunkOV3UJLGPjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
55
55
|
const meta2 = metaMap.get(tag)[func];
|
|
56
|
-
if (!meta2) return resolve(await
|
|
57
|
-
const aop =
|
|
56
|
+
if (!meta2) return resolve(await _chunkOV3UJLGPjs.Context.filterRecord.default(new (0, _chunkOV3UJLGPjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
57
|
+
const aop = _chunkOV3UJLGPjs.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, _chunkOV3UJLGPjs.Context)(contextData);
|
|
86
86
|
context.run(aop, resolve, resolve);
|
|
87
87
|
});
|
|
88
88
|
})).then((ret) => {
|
|
@@ -101,16 +101,16 @@ function bind(fastify, data, opts = {}) {
|
|
|
101
101
|
const { data: { addons, define, http } } = meta2;
|
|
102
102
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
|
|
103
103
|
fastify2.register(async (fastify3, _opts, done2) => {
|
|
104
|
-
|
|
104
|
+
_chunkOV3UJLGPjs.Context.applyAddons(addons, fastify3, "fastify");
|
|
105
105
|
let aop;
|
|
106
106
|
if (!dynamic) {
|
|
107
|
-
aop =
|
|
107
|
+
aop = _chunkOV3UJLGPjs.Context.getAop(meta2, {
|
|
108
108
|
globalFilter,
|
|
109
109
|
globalGuards,
|
|
110
110
|
globalPipe
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
fastify3[http.type](
|
|
113
|
+
fastify3[http.type](_chunkOV3UJLGPjs.joinUrl.call(void 0, http.prefix, http.route), _optionalChain([define, 'optionalAccess', _4 => _4.fastify]) || {}, async (req, res) => {
|
|
114
114
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
115
115
|
const contextData = {
|
|
116
116
|
type: "fastify",
|
|
@@ -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, _chunkOV3UJLGPjs.Context)(contextData);
|
|
144
144
|
if (http.headers) res.headers(http.headers);
|
|
145
145
|
if (dynamic) {
|
|
146
|
-
aop =
|
|
146
|
+
aop = _chunkOV3UJLGPjs.Context.getAop(meta2, {
|
|
147
147
|
globalFilter,
|
|
148
148
|
globalGuards,
|
|
149
149
|
globalPipe
|