phecda-server 8.1.0 → 8.2.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/bin/cli.mjs +17 -2
- package/dist/{chunk-BLLRB5DQ.mjs → chunk-2P2UICBC.mjs} +2 -1
- package/dist/{chunk-UYZSUBX4.js → chunk-C424F7TV.js} +27 -27
- package/dist/{chunk-NQ55PA2X.mjs → chunk-JRNXLEAU.mjs} +2 -2
- package/dist/{chunk-FI5756JX.mjs → chunk-LYLSA56Y.mjs} +1 -1
- package/dist/{chunk-HKN3AAB2.js → chunk-MPKVT4SQ.js} +55 -54
- package/dist/{chunk-4LLLQOMF.js → chunk-OUQM7GZH.js} +2 -2
- package/dist/{chunk-OLNN4U3O.js → chunk-SRPCXPAQ.js} +20 -20
- package/dist/{chunk-PFPOEZHH.mjs → chunk-YDJAOLT2.mjs} +1 -1
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +40 -40
- package/dist/http/elysia/index.mjs +3 -3
- package/dist/http/express/index.js +37 -37
- package/dist/http/express/index.mjs +2 -2
- package/dist/http/fastify/index.js +38 -38
- package/dist/http/fastify/index.mjs +3 -3
- package/dist/http/h3/index.js +38 -38
- package/dist/http/h3/index.mjs +2 -2
- package/dist/http/hono/index.js +34 -34
- package/dist/http/hono/index.mjs +2 -2
- package/dist/http/hyper-express/index.js +35 -35
- package/dist/http/hyper-express/index.mjs +2 -2
- package/dist/http/koa/index.js +37 -37
- package/dist/http/koa/index.mjs +2 -2
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +46 -44
- package/dist/index.mjs +6 -4
- package/dist/rpc/bullmq/index.js +11 -11
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/electron/index.js +8 -8
- package/dist/rpc/electron/index.mjs +2 -2
- package/dist/rpc/kafka/index.js +10 -10
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.js +11 -11
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.js +12 -12
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.js +10 -10
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/rpc/ws/index.js +7 -7
- package/dist/rpc/ws/index.mjs +2 -2
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/package.json +31 -31
- package/register/utils.mjs +1 -10
- package/register/export.mjs +0 -39
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkOUQM7GZHjs = require('./chunk-OUQM7GZH.js');
|
|
8
8
|
|
|
9
9
|
// src/meta.ts
|
|
10
10
|
var Meta = class {
|
|
11
11
|
static {
|
|
12
|
-
|
|
12
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "Meta");
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
|
|
@@ -41,11 +41,11 @@ function defaultServerInject() {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
_chunkOUQM7GZHjs.__name.call(void 0, defaultServerInject, "defaultServerInject");
|
|
45
45
|
var phecdaNamespace = /* @__PURE__ */ new Map();
|
|
46
46
|
var ServerPhecda = (_class = class {
|
|
47
47
|
static {
|
|
48
|
-
|
|
48
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "ServerPhecda");
|
|
49
49
|
}
|
|
50
50
|
__init() {this.moduleMap = /* @__PURE__ */ new Map()}
|
|
51
51
|
__init2() {this.meta = []}
|
|
@@ -57,7 +57,7 @@ var ServerPhecda = (_class = class {
|
|
|
57
57
|
|
|
58
58
|
constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);
|
|
59
59
|
defaultServerInject();
|
|
60
|
-
const { namespace = "default", parseModule = /* @__PURE__ */
|
|
60
|
+
const { namespace = "default", parseModule = /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
|
|
61
61
|
phecdaNamespace.set(namespace, this);
|
|
62
62
|
this.parseMeta = parseMeta;
|
|
63
63
|
this.parseModule = parseModule;
|
|
@@ -67,20 +67,20 @@ var ServerPhecda = (_class = class {
|
|
|
67
67
|
for (const model of models) await this.buildDepModule(model);
|
|
68
68
|
this.hmr();
|
|
69
69
|
this.generateCode().then(() => {
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
process.exit(
|
|
70
|
+
if (_chunkOUQM7GZHjs.IS_ONLY_GENERATE) {
|
|
71
|
+
_chunkOUQM7GZHjs.log.call(void 0, "Only generate code");
|
|
72
|
+
process.exit(_chunkOUQM7GZHjs.PS_EXIT_CODE.EXIT);
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
__init6() {this.generateCode = /* @__PURE__ */
|
|
76
|
+
__init6() {this.generateCode = /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, async () => {
|
|
77
77
|
return Promise.all(this.generators.map((generator) => {
|
|
78
78
|
debug(`generate "${generator.name}" code to ${generator.path}`);
|
|
79
79
|
return generator.output(this.meta);
|
|
80
80
|
}));
|
|
81
81
|
}, "generateCode")}
|
|
82
82
|
hmr() {
|
|
83
|
-
|
|
83
|
+
_chunkOUQM7GZHjs.HMR.call(void 0, async (oldModels, newModels) => {
|
|
84
84
|
debug("reload models ");
|
|
85
85
|
await this.replace(oldModels, newModels);
|
|
86
86
|
this.generateCode();
|
|
@@ -122,7 +122,7 @@ var ServerPhecda = (_class = class {
|
|
|
122
122
|
if (this.moduleMap.has(tag)) {
|
|
123
123
|
module = this.moduleMap.get(tag);
|
|
124
124
|
if (!module) {
|
|
125
|
-
|
|
125
|
+
_chunkOUQM7GZHjs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
|
|
126
126
|
return {
|
|
127
127
|
module: this.createProxyModule(tag),
|
|
128
128
|
tag
|
|
@@ -130,8 +130,8 @@ var ServerPhecda = (_class = class {
|
|
|
130
130
|
}
|
|
131
131
|
if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {
|
|
132
132
|
this.modelSet.add(Model);
|
|
133
|
-
if (module instanceof Model)
|
|
134
|
-
else
|
|
133
|
+
if (module instanceof Model) _chunkOUQM7GZHjs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
|
|
134
|
+
else _chunkOUQM7GZHjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
|
|
135
135
|
}
|
|
136
136
|
return {
|
|
137
137
|
module,
|
|
@@ -154,7 +154,7 @@ var ServerPhecda = (_class = class {
|
|
|
154
154
|
}
|
|
155
155
|
this.meta.push(...getMetaFromInstance(module, tag, Model).map(this.parseMeta).filter((item) => !!item));
|
|
156
156
|
debug(`init module "${String(tag)}"`);
|
|
157
|
-
if (!
|
|
157
|
+
if (!_chunkOUQM7GZHjs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
|
|
158
158
|
debug(`add module "${String(tag)}"`);
|
|
159
159
|
this.moduleMap.set(tag, module);
|
|
160
160
|
this.modelMap.set(module, Model);
|
|
@@ -216,7 +216,7 @@ async function Factory(models, opts = {}) {
|
|
|
216
216
|
await phecda.start(models);
|
|
217
217
|
return phecda;
|
|
218
218
|
}
|
|
219
|
-
|
|
219
|
+
_chunkOUQM7GZHjs.__name.call(void 0, Factory, "Factory");
|
|
220
220
|
function useS(nsOrModel, namespace) {
|
|
221
221
|
if (!nsOrModel) {
|
|
222
222
|
namespace = "default";
|
|
@@ -229,7 +229,7 @@ function useS(nsOrModel, namespace) {
|
|
|
229
229
|
if (nsOrModel && typeof nsOrModel !== "string") return serverPhecda.get(nsOrModel);
|
|
230
230
|
else return serverPhecda;
|
|
231
231
|
}
|
|
232
|
-
|
|
232
|
+
_chunkOUQM7GZHjs.__name.call(void 0, useS, "useS");
|
|
233
233
|
function getMetaFromInstance(instance, tag, model) {
|
|
234
234
|
const name = model.name;
|
|
235
235
|
const propertyKeys = _phecdacore.getMetaKey.call(void 0, instance).filter((item) => typeof item === "string");
|
|
@@ -244,7 +244,7 @@ function getMetaFromInstance(instance, tag, model) {
|
|
|
244
244
|
method: i
|
|
245
245
|
};
|
|
246
246
|
if (baseMeta.controller) {
|
|
247
|
-
if (typeof tag !== "string")
|
|
247
|
+
if (typeof tag !== "string") _chunkOUQM7GZHjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
|
|
248
248
|
metaData.controller = baseMeta.controller;
|
|
249
249
|
metaData[baseMeta.controller] = {
|
|
250
250
|
...baseMeta[baseMeta.controller],
|
|
@@ -286,7 +286,7 @@ function getMetaFromInstance(instance, tag, model) {
|
|
|
286
286
|
return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || [], instance, model);
|
|
287
287
|
});
|
|
288
288
|
}
|
|
289
|
-
|
|
289
|
+
_chunkOUQM7GZHjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
|
|
290
290
|
function deepFreeze(object) {
|
|
291
291
|
Object.freeze(object);
|
|
292
292
|
Object.getOwnPropertyNames(object).forEach((prop) => {
|
|
@@ -294,11 +294,11 @@ function deepFreeze(object) {
|
|
|
294
294
|
});
|
|
295
295
|
return object;
|
|
296
296
|
}
|
|
297
|
-
|
|
297
|
+
_chunkOUQM7GZHjs.__name.call(void 0, deepFreeze, "deepFreeze");
|
|
298
298
|
function getParamTypes(Model, key) {
|
|
299
299
|
return Reflect.getMetadata("design:paramtypes", Model, key);
|
|
300
300
|
}
|
|
301
|
-
|
|
301
|
+
_chunkOUQM7GZHjs.__name.call(void 0, getParamTypes, "getParamTypes");
|
|
302
302
|
|
|
303
303
|
|
|
304
304
|
|
package/dist/helper.js
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkMPKVT4SQjs = require('./chunk-MPKVT4SQ.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkOUQM7GZHjs = require('./chunk-OUQM7GZH.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -21,4 +21,4 @@ var _chunk4LLLQOMFjs = require('./chunk-4LLLQOMF.js');
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
exports.HMR =
|
|
24
|
+
exports.HMR = _chunkOUQM7GZHjs.HMR; exports.RELAUNCH = _chunkOUQM7GZHjs.RELAUNCH; exports.RELOAD = _chunkOUQM7GZHjs.RELOAD; exports.createControllerMetaMap = _chunkMPKVT4SQjs.createControllerMetaMap; exports.detectAopDep = _chunkMPKVT4SQjs.detectAopDep; exports.joinUrl = _chunkMPKVT4SQjs.joinUrl; exports.mergeObject = _chunkMPKVT4SQjs.mergeObject; exports.resolveDep = _chunkMPKVT4SQjs.resolveDep; exports.shallowClone = _chunkMPKVT4SQjs.shallowClone;
|
package/dist/helper.mjs
CHANGED
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
mergeObject,
|
|
6
6
|
resolveDep,
|
|
7
7
|
shallowClone
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-2P2UICBC.mjs";
|
|
9
9
|
import {
|
|
10
10
|
HMR,
|
|
11
11
|
RELAUNCH,
|
|
12
12
|
RELOAD
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-JRNXLEAU.mjs";
|
|
14
14
|
export {
|
|
15
15
|
HMR,
|
|
16
16
|
RELAUNCH,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Elysia as Elysia$1, Context
|
|
2
|
-
import {
|
|
1
|
+
import { Elysia as Elysia$1, Context } from 'elysia';
|
|
2
|
+
import { AnyLocalHook } from 'elysia/dist/types';
|
|
3
3
|
import { H as HttpCtx, a as HttpOptions } from '../../types-DtiHAXQB.mjs';
|
|
4
4
|
import { F as Factory } from '../../core-D1YYphEn.mjs';
|
|
5
5
|
import 'node:http';
|
|
@@ -13,6 +13,6 @@ interface ElysiaCtx extends HttpCtx {
|
|
|
13
13
|
}
|
|
14
14
|
type Addon = (app: Elysia$1<any>) => void;
|
|
15
15
|
declare function bind(app: Elysia$1<any>, data: Awaited<ReturnType<typeof Factory>>, opts?: HttpOptions): void;
|
|
16
|
-
declare function Elysia(opts:
|
|
16
|
+
declare function Elysia(opts: AnyLocalHook): any;
|
|
17
17
|
|
|
18
18
|
export { type Addon, Elysia, type ElysiaCtx, bind };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Elysia as Elysia$1, Context
|
|
2
|
-
import {
|
|
1
|
+
import { Elysia as Elysia$1, Context } from 'elysia';
|
|
2
|
+
import { AnyLocalHook } from 'elysia/dist/types';
|
|
3
3
|
import { H as HttpCtx, a as HttpOptions } from '../../types-Cosv4nol.js';
|
|
4
4
|
import { F as Factory } from '../../core-BTSHIAyB.js';
|
|
5
5
|
import 'node:http';
|
|
@@ -13,6 +13,6 @@ interface ElysiaCtx extends HttpCtx {
|
|
|
13
13
|
}
|
|
14
14
|
type Addon = (app: Elysia$1<any>) => void;
|
|
15
15
|
declare function bind(app: Elysia$1<any>, data: Awaited<ReturnType<typeof Factory>>, opts?: HttpOptions): void;
|
|
16
|
-
declare function Elysia(opts:
|
|
16
|
+
declare function Elysia(opts: AnyLocalHook): any;
|
|
17
17
|
|
|
18
18
|
export { type Addon, Elysia, type ElysiaCtx, bind };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkC424F7TVjs = require('../../chunk-C424F7TV.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkMPKVT4SQjs = require('../../chunk-MPKVT4SQ.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkOUQM7GZHjs = require('../../chunk-OUQM7GZH.js');
|
|
14
14
|
|
|
15
15
|
// src/http/elysia/bind.ts
|
|
16
16
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -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 = _chunkMPKVT4SQjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
23
23
|
const { controller, http, method, tag } = meta2.data;
|
|
24
24
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
25
25
|
debug(`register method "${method}" in module "${tag}"`);
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
-
|
|
29
|
+
_chunkMPKVT4SQjs.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
|
+
_chunkMPKVT4SQjs.Context.applyAddons(globalAddons, app, "elysia");
|
|
39
39
|
if (parallelRoute) {
|
|
40
40
|
const parallelRouter = new (0, _elysia.Elysia)();
|
|
41
|
-
|
|
41
|
+
_chunkMPKVT4SQjs.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 _chunkMPKVT4SQjs.Context.filterRecord.default(e);
|
|
46
46
|
c.set.status = error.status;
|
|
47
47
|
return error;
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
49
|
+
_chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkMPKVT4SQjs.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, method } = item;
|
|
56
56
|
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
57
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
57
|
+
if (!metaMap.has(tag)) return resolve(await _chunkMPKVT4SQjs.Context.filterRecord.default(new (0, _chunkMPKVT4SQjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
58
58
|
const meta2 = metaMap.get(tag)[method];
|
|
59
|
-
if (!meta2) return resolve(await
|
|
60
|
-
const aop =
|
|
59
|
+
if (!meta2) return resolve(await _chunkMPKVT4SQjs.Context.filterRecord.default(new (0, _chunkMPKVT4SQjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
60
|
+
const aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
61
61
|
globalGuards,
|
|
62
62
|
globalFilter,
|
|
63
63
|
globalPipe
|
|
@@ -72,23 +72,23 @@ function bind(app, data, opts = {}) {
|
|
|
72
72
|
moduleMap,
|
|
73
73
|
app,
|
|
74
74
|
...item,
|
|
75
|
-
getCookie: /* @__PURE__ */
|
|
76
|
-
setCookie: /* @__PURE__ */
|
|
75
|
+
getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
|
|
76
|
+
setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
|
|
77
77
|
...opts2,
|
|
78
78
|
value
|
|
79
79
|
}), "setCookie"),
|
|
80
|
-
delCookie: /* @__PURE__ */
|
|
81
|
-
redirect: /* @__PURE__ */
|
|
82
|
-
setResHeaders: /* @__PURE__ */
|
|
83
|
-
setResStatus: /* @__PURE__ */
|
|
84
|
-
getRequest: /* @__PURE__ */
|
|
80
|
+
delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
|
|
81
|
+
redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
82
|
+
setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
|
|
83
|
+
setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (status) => c.set.status = status, "setResStatus"),
|
|
84
|
+
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => {
|
|
85
85
|
throw new Error("elysia can't support getRequest");
|
|
86
86
|
}, "getRequest"),
|
|
87
|
-
getResponse: /* @__PURE__ */
|
|
87
|
+
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => {
|
|
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, _chunkMPKVT4SQjs.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.method])) continue;
|
|
111
111
|
let aop;
|
|
112
112
|
if (!dynamic) {
|
|
113
|
-
aop =
|
|
113
|
+
aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
114
114
|
globalFilter,
|
|
115
115
|
globalGuards,
|
|
116
116
|
globalPipe
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
subApp[http.method](
|
|
119
|
+
_chunkMPKVT4SQjs.Context.applyAddons(addons, subApp, "elysia");
|
|
120
|
+
subApp[http.method](_chunkMPKVT4SQjs.joinUrl.call(void 0, http.prefix, http.route), async (c) => {
|
|
121
121
|
debug(`invoke method "${method}" in module "${tag}"`);
|
|
122
122
|
const contextData = {
|
|
123
123
|
type: "elysia",
|
|
@@ -132,33 +132,33 @@ function bind(app, data, opts = {}) {
|
|
|
132
132
|
params: c.params,
|
|
133
133
|
headers: c.headers,
|
|
134
134
|
app,
|
|
135
|
-
getCookie: /* @__PURE__ */
|
|
136
|
-
setCookie: /* @__PURE__ */
|
|
135
|
+
getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
|
|
136
|
+
setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
|
|
137
137
|
...opts2,
|
|
138
138
|
value
|
|
139
139
|
}), "setCookie"),
|
|
140
|
-
delCookie: /* @__PURE__ */
|
|
141
|
-
redirect: /* @__PURE__ */
|
|
142
|
-
setResHeaders: /* @__PURE__ */
|
|
143
|
-
setResStatus: /* @__PURE__ */
|
|
144
|
-
getRequest: /* @__PURE__ */
|
|
140
|
+
delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
|
|
141
|
+
redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
142
|
+
setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
|
|
143
|
+
setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (status) => c.set.status = status, "setResStatus"),
|
|
144
|
+
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => {
|
|
145
145
|
throw new Error("elysia can't support getRequest");
|
|
146
146
|
}, "getRequest"),
|
|
147
|
-
getResponse: /* @__PURE__ */
|
|
147
|
+
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => {
|
|
148
148
|
throw new Error("elysia can't support getResponse");
|
|
149
149
|
}, "getResponse")
|
|
150
150
|
};
|
|
151
151
|
if (dynamic) {
|
|
152
|
-
aop =
|
|
152
|
+
aop = _chunkMPKVT4SQjs.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, _chunkMPKVT4SQjs.Context)(contextData);
|
|
159
159
|
if (http.headers) c.set.headers = http.headers;
|
|
160
160
|
if (dynamic) {
|
|
161
|
-
aop =
|
|
161
|
+
aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
162
162
|
globalFilter,
|
|
163
163
|
globalGuards,
|
|
164
164
|
globalPipe
|
|
@@ -173,13 +173,13 @@ function bind(app, data, opts = {}) {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
_chunkOUQM7GZHjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
_chunkOUQM7GZHjs.__name.call(void 0, bind, "bind");
|
|
179
179
|
function Elysia(opts) {
|
|
180
|
-
return
|
|
180
|
+
return _chunkC424F7TVjs.Define.call(void 0, "elysia", opts);
|
|
181
181
|
}
|
|
182
|
-
|
|
182
|
+
_chunkOUQM7GZHjs.__name.call(void 0, Elysia, "Elysia");
|
|
183
183
|
|
|
184
184
|
|
|
185
185
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-LYLSA56Y.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-2P2UICBC.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-JRNXLEAU.mjs";
|
|
14
14
|
|
|
15
15
|
// src/http/elysia/bind.ts
|
|
16
16
|
import Debug from "debug";
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkMPKVT4SQjs = require('../../chunk-MPKVT4SQ.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkOUQM7GZHjs = require('../../chunk-OUQM7GZH.js');
|
|
12
12
|
|
|
13
13
|
// src/http/express/bind.ts
|
|
14
14
|
var _express = require('express');
|
|
@@ -18,14 +18,14 @@ function bind(router, data, opts = {}) {
|
|
|
18
18
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
19
19
|
const { moduleMap, meta } = data;
|
|
20
20
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkMPKVT4SQjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
22
|
const { controller, http, method, tag } = meta2.data;
|
|
23
23
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
|
|
24
24
|
debug(`register method "${method}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunkMPKVT4SQjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -33,33 +33,33 @@ function bind(router, data, opts = {}) {
|
|
|
33
33
|
guards: globalGuards
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
|
-
|
|
36
|
+
_chunkOUQM7GZHjs.HMR.call(void 0, async () => {
|
|
37
37
|
router.stack = originStack;
|
|
38
38
|
registerRoute();
|
|
39
39
|
});
|
|
40
40
|
function registerRoute() {
|
|
41
|
-
|
|
41
|
+
_chunkMPKVT4SQjs.Context.applyAddons(globalAddons, router, "express");
|
|
42
42
|
if (parallelRoute) {
|
|
43
43
|
const subRouter = _express.Router.call(void 0, );
|
|
44
|
-
|
|
44
|
+
_chunkMPKVT4SQjs.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 _chunkMPKVT4SQjs.Context.filterRecord.default(e);
|
|
49
49
|
return res.status(error.status).json(error);
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
51
|
+
_chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
52
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkMPKVT4SQjs.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, method } = item;
|
|
58
58
|
debug(`(parallel)invoke method "${method}" in module "${tag}"`);
|
|
59
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
59
|
+
if (!metaMap.has(tag)) return resolve(await _chunkMPKVT4SQjs.Context.filterRecord.default(new (0, _chunkMPKVT4SQjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
60
60
|
const meta2 = metaMap.get(tag)[method];
|
|
61
|
-
if (!meta2) return resolve(await
|
|
62
|
-
const aop =
|
|
61
|
+
if (!meta2) return resolve(await _chunkMPKVT4SQjs.Context.filterRecord.default(new (0, _chunkMPKVT4SQjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
|
|
62
|
+
const aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
63
63
|
globalFilter,
|
|
64
64
|
globalGuards,
|
|
65
65
|
globalPipe
|
|
@@ -76,18 +76,18 @@ function bind(router, data, opts = {}) {
|
|
|
76
76
|
next,
|
|
77
77
|
app: router,
|
|
78
78
|
...item,
|
|
79
|
-
getCookie: /* @__PURE__ */
|
|
80
|
-
setCookie: /* @__PURE__ */
|
|
81
|
-
delCookie: /* @__PURE__ */
|
|
79
|
+
getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
80
|
+
setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
|
|
81
|
+
delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => res.cookie(key, "", {
|
|
82
82
|
expires: /* @__PURE__ */ new Date(0)
|
|
83
83
|
}), "delCookie"),
|
|
84
|
-
redirect: /* @__PURE__ */
|
|
85
|
-
setResHeaders: /* @__PURE__ */
|
|
86
|
-
setResStatus: /* @__PURE__ */
|
|
87
|
-
getRequest: /* @__PURE__ */
|
|
88
|
-
getResponse: /* @__PURE__ */
|
|
84
|
+
redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
85
|
+
setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
86
|
+
setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
87
|
+
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => req, "getRequest"),
|
|
88
|
+
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => res, "getResponse")
|
|
89
89
|
};
|
|
90
|
-
const context = new (0,
|
|
90
|
+
const context = new (0, _chunkMPKVT4SQjs.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.method])) continue;
|
|
107
107
|
let aop;
|
|
108
108
|
if (!dynamic) {
|
|
109
|
-
aop =
|
|
109
|
+
aop = _chunkMPKVT4SQjs.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.method](
|
|
116
|
+
_chunkMPKVT4SQjs.Context.applyAddons(addons, subRouter, "express");
|
|
117
|
+
subRouter[http.method](_chunkMPKVT4SQjs.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
|
|
118
118
|
debug(`invoke method "${method}" in module "${tag}"`);
|
|
119
119
|
const contextData = {
|
|
120
120
|
type: "express",
|
|
@@ -131,21 +131,21 @@ function bind(router, data, opts = {}) {
|
|
|
131
131
|
headers: req.headers,
|
|
132
132
|
app: router,
|
|
133
133
|
next,
|
|
134
|
-
getCookie: /* @__PURE__ */
|
|
135
|
-
setCookie: /* @__PURE__ */
|
|
136
|
-
delCookie: /* @__PURE__ */
|
|
134
|
+
getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
135
|
+
setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
|
|
136
|
+
delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => res.cookie(key, "", {
|
|
137
137
|
expires: /* @__PURE__ */ new Date(0)
|
|
138
138
|
}), "delCookie"),
|
|
139
|
-
redirect: /* @__PURE__ */
|
|
140
|
-
setResHeaders: /* @__PURE__ */
|
|
141
|
-
setResStatus: /* @__PURE__ */
|
|
142
|
-
getRequest: /* @__PURE__ */
|
|
143
|
-
getResponse: /* @__PURE__ */
|
|
139
|
+
redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
140
|
+
setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
141
|
+
setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
142
|
+
getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => req, "getRequest"),
|
|
143
|
+
getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => res, "getResponse")
|
|
144
144
|
};
|
|
145
|
-
const context = new (0,
|
|
145
|
+
const context = new (0, _chunkMPKVT4SQjs.Context)(contextData);
|
|
146
146
|
if (http.headers) res.set(http.headers);
|
|
147
147
|
if (dynamic) {
|
|
148
|
-
aop =
|
|
148
|
+
aop = _chunkMPKVT4SQjs.Context.getAop(meta2, {
|
|
149
149
|
globalFilter,
|
|
150
150
|
globalGuards,
|
|
151
151
|
globalPipe
|
|
@@ -164,9 +164,9 @@ function bind(router, data, opts = {}) {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
_chunkOUQM7GZHjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
_chunkOUQM7GZHjs.__name.call(void 0, bind, "bind");
|
|
170
170
|
|
|
171
171
|
|
|
172
172
|
exports.bind = bind;
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
joinUrl
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-2P2UICBC.mjs";
|
|
8
8
|
import {
|
|
9
9
|
HMR,
|
|
10
10
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-JRNXLEAU.mjs";
|
|
12
12
|
|
|
13
13
|
// src/http/express/bind.ts
|
|
14
14
|
import { Router } from "express";
|