phecda-server 7.0.0-alpha.6 → 7.0.0-alpha.7
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-KSDE5G57.mjs → chunk-C5BVKEGW.mjs} +22 -1
- package/dist/{chunk-3C7Z3IJN.mjs → chunk-IRXNF6ZE.mjs} +1 -1
- package/dist/{chunk-ICI5KUDX.mjs → chunk-JPSXNDXP.mjs} +1 -1
- package/dist/{chunk-62FBZWGW.js → chunk-M5HGFUCV.js} +22 -1
- package/dist/{chunk-JF4YU32E.js → chunk-MENRZSGW.js} +51 -51
- package/dist/{chunk-HTY3H33L.mjs → chunk-RGSKKTHD.mjs} +1 -1
- package/dist/{chunk-UKRQVTEY.js → chunk-VYMSCWXC.js} +24 -24
- package/dist/{chunk-WYI2F7LD.js → chunk-XSMUJ77A.js} +19 -19
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- 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 +37 -37
- package/dist/http/h3/index.mjs +2 -2
- package/dist/http/hono/index.js +35 -35
- 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 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +40 -40
- package/dist/index.mjs +5 -5
- package/dist/rpc/bullmq/index.d.mts +1 -1
- package/dist/rpc/bullmq/index.d.ts +1 -1
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.js +13 -13
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.js +15 -15
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.js +13 -13
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/test.d.mts +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/package.json +1 -1
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkM5HGFUCVjs = require('./chunk-M5HGFUCV.js');
|
|
7
7
|
|
|
8
8
|
// src/meta.ts
|
|
9
9
|
var Meta = class {
|
|
10
10
|
static {
|
|
11
|
-
|
|
11
|
+
_chunkM5HGFUCVjs.__name.call(void 0, this, "Meta");
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
|
|
@@ -37,11 +37,11 @@ function defaultServerInject() {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
_chunkM5HGFUCVjs.__name.call(void 0, defaultServerInject, "defaultServerInject");
|
|
41
41
|
var phecdaNamespace = /* @__PURE__ */ new Map();
|
|
42
42
|
var ServerPhecda = (_class = class {
|
|
43
43
|
static {
|
|
44
|
-
|
|
44
|
+
_chunkM5HGFUCVjs.__name.call(void 0, this, "ServerPhecda");
|
|
45
45
|
}
|
|
46
46
|
__init() {this.moduleMap = /* @__PURE__ */ new Map()}
|
|
47
47
|
__init2() {this.meta = []}
|
|
@@ -53,7 +53,7 @@ var ServerPhecda = (_class = class {
|
|
|
53
53
|
|
|
54
54
|
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);
|
|
55
55
|
defaultServerInject();
|
|
56
|
-
const { namespace = "default", parseModule = /* @__PURE__ */
|
|
56
|
+
const { namespace = "default", parseModule = /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
|
|
57
57
|
phecdaNamespace.set(namespace, this);
|
|
58
58
|
this.parseMeta = parseMeta;
|
|
59
59
|
this.parseModule = parseModule;
|
|
@@ -61,8 +61,8 @@ var ServerPhecda = (_class = class {
|
|
|
61
61
|
}
|
|
62
62
|
async start(models) {
|
|
63
63
|
for (const model of models) await this.buildDepModule(model);
|
|
64
|
-
const generateCode = /* @__PURE__ */
|
|
65
|
-
if (
|
|
64
|
+
const generateCode = /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, async () => {
|
|
65
|
+
if (_chunkM5HGFUCVjs.IS_HMR) {
|
|
66
66
|
return Promise.all(this.generators.map((generator) => {
|
|
67
67
|
debug(`generate "${generator.name}" code to ${generator.path}`);
|
|
68
68
|
return generator.output(this.meta);
|
|
@@ -70,9 +70,9 @@ var ServerPhecda = (_class = class {
|
|
|
70
70
|
}
|
|
71
71
|
}, "generateCode");
|
|
72
72
|
generateCode().then(() => {
|
|
73
|
-
if (
|
|
73
|
+
if (_chunkM5HGFUCVjs.IS_ONLY_GENERATE) process.exit(4);
|
|
74
74
|
});
|
|
75
|
-
if (
|
|
75
|
+
if (_chunkM5HGFUCVjs.IS_HMR) {
|
|
76
76
|
if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
|
|
77
77
|
_optionalChain([globalThis, 'access', _2 => _2.__PS_HMR__, 'optionalAccess', _3 => _3.push, 'call', _4 => _4(async (files) => {
|
|
78
78
|
debug("reload files ");
|
|
@@ -148,7 +148,7 @@ var ServerPhecda = (_class = class {
|
|
|
148
148
|
if (this.moduleMap.has(tag)) {
|
|
149
149
|
module = this.moduleMap.get(tag);
|
|
150
150
|
if (!module) {
|
|
151
|
-
|
|
151
|
+
_chunkM5HGFUCVjs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
|
|
152
152
|
return {
|
|
153
153
|
module: this.createProxyModule(tag),
|
|
154
154
|
tag
|
|
@@ -156,8 +156,8 @@ var ServerPhecda = (_class = class {
|
|
|
156
156
|
}
|
|
157
157
|
if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {
|
|
158
158
|
this.modelSet.add(Model);
|
|
159
|
-
if (module instanceof Model)
|
|
160
|
-
else
|
|
159
|
+
if (module instanceof Model) _chunkM5HGFUCVjs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
|
|
160
|
+
else _chunkM5HGFUCVjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
|
|
161
161
|
}
|
|
162
162
|
return {
|
|
163
163
|
module,
|
|
@@ -180,7 +180,7 @@ var ServerPhecda = (_class = class {
|
|
|
180
180
|
}
|
|
181
181
|
this.meta.push(...getMetaFromInstance(module, tag, Model.name).map(this.parseMeta).filter((item) => !!item));
|
|
182
182
|
debug(`init module "${String(tag)}"`);
|
|
183
|
-
if (!
|
|
183
|
+
if (!_chunkM5HGFUCVjs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
|
|
184
184
|
debug(`add module "${String(tag)}"`);
|
|
185
185
|
this.moduleMap.set(tag, module);
|
|
186
186
|
this.modelMap.set(module, Model);
|
|
@@ -203,7 +203,7 @@ async function Factory(models, opts = {}) {
|
|
|
203
203
|
await phecda.start(models);
|
|
204
204
|
return phecda;
|
|
205
205
|
}
|
|
206
|
-
|
|
206
|
+
_chunkM5HGFUCVjs.__name.call(void 0, Factory, "Factory");
|
|
207
207
|
function useS(nsOrModel, namespace) {
|
|
208
208
|
if (!nsOrModel) {
|
|
209
209
|
namespace = "default";
|
|
@@ -216,7 +216,7 @@ function useS(nsOrModel, namespace) {
|
|
|
216
216
|
if (nsOrModel && typeof nsOrModel !== "string") return serverPhecda.get(nsOrModel);
|
|
217
217
|
else return serverPhecda;
|
|
218
218
|
}
|
|
219
|
-
|
|
219
|
+
_chunkM5HGFUCVjs.__name.call(void 0, useS, "useS");
|
|
220
220
|
function getMetaFromInstance(instance, tag, name) {
|
|
221
221
|
const propertyKeys = _phecdacore.getMetaKey.call(void 0, instance).filter((item) => typeof item === "string");
|
|
222
222
|
const baseMeta = _phecdacore.getMergedMeta.call(void 0, instance, void 0);
|
|
@@ -230,7 +230,7 @@ function getMetaFromInstance(instance, tag, name) {
|
|
|
230
230
|
func: i
|
|
231
231
|
};
|
|
232
232
|
if (baseMeta.controller) {
|
|
233
|
-
if (typeof tag !== "string")
|
|
233
|
+
if (typeof tag !== "string") _chunkM5HGFUCVjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
|
|
234
234
|
metaData.controller = baseMeta.controller;
|
|
235
235
|
metaData[baseMeta.controller] = {
|
|
236
236
|
...baseMeta[baseMeta.controller],
|
|
@@ -268,7 +268,7 @@ function getMetaFromInstance(instance, tag, name) {
|
|
|
268
268
|
return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || []);
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
|
-
|
|
271
|
+
_chunkM5HGFUCVjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
|
|
272
272
|
function deepFreeze(object) {
|
|
273
273
|
Object.freeze(object);
|
|
274
274
|
Object.getOwnPropertyNames(object).forEach((prop) => {
|
|
@@ -276,13 +276,13 @@ function deepFreeze(object) {
|
|
|
276
276
|
});
|
|
277
277
|
return object;
|
|
278
278
|
}
|
|
279
|
-
|
|
279
|
+
_chunkM5HGFUCVjs.__name.call(void 0, deepFreeze, "deepFreeze");
|
|
280
280
|
function getParamTypes(Model, key) {
|
|
281
281
|
const paramTypes = Reflect.getMetadata("design:paramtypes", Model, key);
|
|
282
282
|
if (typeof paramTypes === "function") return paramTypes();
|
|
283
283
|
else return paramTypes;
|
|
284
284
|
}
|
|
285
|
-
|
|
285
|
+
_chunkM5HGFUCVjs.__name.call(void 0, getParamTypes, "getParamTypes");
|
|
286
286
|
|
|
287
287
|
|
|
288
288
|
|
package/dist/helper.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
require('./chunk-
|
|
10
|
+
var _chunkMENRZSGWjs = require('./chunk-MENRZSGW.js');
|
|
11
|
+
require('./chunk-M5HGFUCV.js');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -18,4 +18,4 @@ require('./chunk-62FBZWGW.js');
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
exports.HMR =
|
|
21
|
+
exports.HMR = _chunkMENRZSGWjs.HMR; exports.argToReq = _chunkMENRZSGWjs.argToReq; exports.createControllerMetaMap = _chunkMENRZSGWjs.createControllerMetaMap; exports.detectAopDep = _chunkMENRZSGWjs.detectAopDep; exports.genClientQueue = _chunkMENRZSGWjs.genClientQueue; exports.mergeObject = _chunkMENRZSGWjs.mergeObject; exports.resolveDep = _chunkMENRZSGWjs.resolveDep; exports.shallowClone = _chunkMENRZSGWjs.shallowClone;
|
package/dist/helper.mjs
CHANGED
|
@@ -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 _chunkVYMSCWXCjs = require('../../chunk-VYMSCWXC.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkMENRZSGWjs = require('../../chunk-MENRZSGW.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkM5HGFUCVjs = require('../../chunk-M5HGFUCV.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 = _chunkMENRZSGWjs.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
|
+
_chunkMENRZSGWjs.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
|
+
_chunkMENRZSGWjs.Context.applyAddons(globalAddons, app, "elysia");
|
|
39
39
|
if (parallelRoute) {
|
|
40
40
|
const parallelRouter = new (0, _elysia.Elysia)();
|
|
41
|
-
|
|
41
|
+
_chunkMENRZSGWjs.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 _chunkMENRZSGWjs.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
|
+
_chunkM5HGFUCVjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkMENRZSGWjs.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
|
const { tag, func } = item;
|
|
55
55
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
56
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
56
|
+
if (!metaMap.has(tag)) return resolve(await _chunkMENRZSGWjs.Context.filterRecord.default(new (0, _chunkMENRZSGWjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
57
57
|
const meta2 = metaMap.get(tag)[func];
|
|
58
|
-
if (!meta2) return resolve(await
|
|
58
|
+
if (!meta2) return resolve(await _chunkMENRZSGWjs.Context.filterRecord.default(new (0, _chunkMENRZSGWjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
59
|
const { data: { params } } = meta2;
|
|
60
|
-
const aop =
|
|
60
|
+
const aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
|
|
61
61
|
globalGuards,
|
|
62
62
|
globalFilter,
|
|
63
63
|
globalPipe
|
|
@@ -73,24 +73,24 @@ function bind(app, data, opts = {}) {
|
|
|
73
73
|
tag,
|
|
74
74
|
func,
|
|
75
75
|
app,
|
|
76
|
-
...
|
|
77
|
-
getCookie: /* @__PURE__ */
|
|
78
|
-
setCookie: /* @__PURE__ */
|
|
76
|
+
..._chunkMENRZSGWjs.argToReq.call(void 0, params, item.args, c.headers),
|
|
77
|
+
getCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
|
|
78
|
+
setCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
|
|
79
79
|
...opts2,
|
|
80
80
|
value
|
|
81
81
|
}), "setCookie"),
|
|
82
|
-
delCookie: /* @__PURE__ */
|
|
83
|
-
redirect: /* @__PURE__ */
|
|
84
|
-
setResHeaders: /* @__PURE__ */
|
|
85
|
-
setResStatus: /* @__PURE__ */
|
|
86
|
-
getRequest: /* @__PURE__ */
|
|
82
|
+
delCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
|
|
83
|
+
redirect: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
84
|
+
setResHeaders: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
|
|
85
|
+
setResStatus: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (status) => c.set.status = status, "setResStatus"),
|
|
86
|
+
getRequest: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => {
|
|
87
87
|
throw new Error("elysia can't support getRequest");
|
|
88
88
|
}, "getRequest"),
|
|
89
|
-
getResponse: /* @__PURE__ */
|
|
89
|
+
getResponse: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => {
|
|
90
90
|
throw new Error("elysia can't support getResponse");
|
|
91
91
|
}, "getResponse")
|
|
92
92
|
};
|
|
93
|
-
const context = new (0,
|
|
93
|
+
const context = new (0, _chunkMENRZSGWjs.Context)(contextData);
|
|
94
94
|
context.run(aop, resolve, resolve);
|
|
95
95
|
});
|
|
96
96
|
})).then((ret) => {
|
|
@@ -112,13 +112,13 @@ function bind(app, data, opts = {}) {
|
|
|
112
112
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
113
113
|
let aop;
|
|
114
114
|
if (!dynamic) {
|
|
115
|
-
aop =
|
|
115
|
+
aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
|
|
116
116
|
globalFilter,
|
|
117
117
|
globalGuards,
|
|
118
118
|
globalPipe
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
_chunkMENRZSGWjs.Context.applyAddons(addons, subApp, "elysia");
|
|
122
122
|
subApp[http.type](http.prefix + http.route, async (c) => {
|
|
123
123
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
124
124
|
const contextData = {
|
|
@@ -134,33 +134,33 @@ function bind(app, data, opts = {}) {
|
|
|
134
134
|
params: c.params,
|
|
135
135
|
headers: c.headers,
|
|
136
136
|
app,
|
|
137
|
-
getCookie: /* @__PURE__ */
|
|
138
|
-
setCookie: /* @__PURE__ */
|
|
137
|
+
getCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
|
|
138
|
+
setCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
|
|
139
139
|
...opts2,
|
|
140
140
|
value
|
|
141
141
|
}), "setCookie"),
|
|
142
|
-
delCookie: /* @__PURE__ */
|
|
143
|
-
redirect: /* @__PURE__ */
|
|
144
|
-
setResHeaders: /* @__PURE__ */
|
|
145
|
-
setResStatus: /* @__PURE__ */
|
|
146
|
-
getRequest: /* @__PURE__ */
|
|
142
|
+
delCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
|
|
143
|
+
redirect: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
144
|
+
setResHeaders: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
|
|
145
|
+
setResStatus: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (status) => c.set.status = status, "setResStatus"),
|
|
146
|
+
getRequest: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => {
|
|
147
147
|
throw new Error("elysia can't support getRequest");
|
|
148
148
|
}, "getRequest"),
|
|
149
|
-
getResponse: /* @__PURE__ */
|
|
149
|
+
getResponse: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => {
|
|
150
150
|
throw new Error("elysia can't support getResponse");
|
|
151
151
|
}, "getResponse")
|
|
152
152
|
};
|
|
153
153
|
if (dynamic) {
|
|
154
|
-
aop =
|
|
154
|
+
aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
|
|
155
155
|
globalFilter,
|
|
156
156
|
globalGuards,
|
|
157
157
|
globalPipe
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
|
-
const context = new (0,
|
|
160
|
+
const context = new (0, _chunkMENRZSGWjs.Context)(contextData);
|
|
161
161
|
if (http.headers) c.set.headers = http.headers;
|
|
162
162
|
if (dynamic) {
|
|
163
|
-
aop =
|
|
163
|
+
aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
|
|
164
164
|
globalFilter,
|
|
165
165
|
globalGuards,
|
|
166
166
|
globalPipe
|
|
@@ -175,13 +175,13 @@ function bind(app, data, opts = {}) {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
_chunkM5HGFUCVjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
179
179
|
}
|
|
180
|
-
|
|
180
|
+
_chunkM5HGFUCVjs.__name.call(void 0, bind, "bind");
|
|
181
181
|
function Elysia(opts) {
|
|
182
|
-
return
|
|
182
|
+
return _chunkVYMSCWXCjs.Define.call(void 0, "elysia", opts);
|
|
183
183
|
}
|
|
184
|
-
|
|
184
|
+
_chunkM5HGFUCVjs.__name.call(void 0, Elysia, "Elysia");
|
|
185
185
|
|
|
186
186
|
|
|
187
187
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Define
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-JPSXNDXP.mjs";
|
|
4
4
|
import {
|
|
5
5
|
BadRequestException,
|
|
6
6
|
Context,
|
|
7
7
|
argToReq,
|
|
8
8
|
createControllerMetaMap,
|
|
9
9
|
detectAopDep
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-IRXNF6ZE.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-C5BVKEGW.mjs";
|
|
14
14
|
|
|
15
15
|
// src/http/elysia/bind.ts
|
|
16
16
|
import Debug from "debug";
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkMENRZSGWjs = require('../../chunk-MENRZSGW.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkM5HGFUCVjs = require('../../chunk-M5HGFUCV.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 = _chunkMENRZSGWjs.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
|
+
_chunkMENRZSGWjs.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
|
+
_chunkMENRZSGWjs.HMR.call(void 0, async () => {
|
|
37
37
|
router.stack = originStack;
|
|
38
38
|
registerRoute();
|
|
39
39
|
});
|
|
40
40
|
function registerRoute() {
|
|
41
|
-
|
|
41
|
+
_chunkMENRZSGWjs.Context.applyAddons(globalAddons, router, "express");
|
|
42
42
|
if (parallelRoute) {
|
|
43
43
|
const subRouter = _express.Router.call(void 0, );
|
|
44
|
-
|
|
44
|
+
_chunkMENRZSGWjs.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 _chunkMENRZSGWjs.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
|
+
_chunkM5HGFUCVjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
52
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkMENRZSGWjs.BadRequestException)("data format should be an array"));
|
|
53
53
|
try {
|
|
54
54
|
return Promise.all(body.map((item, i) => {
|
|
55
55
|
return new Promise(async (resolve) => {
|
|
56
56
|
const { tag, func } = item;
|
|
57
57
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
58
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
58
|
+
if (!metaMap.has(tag)) return resolve(await _chunkMENRZSGWjs.Context.filterRecord.default(new (0, _chunkMENRZSGWjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
59
59
|
const meta2 = metaMap.get(tag)[func];
|
|
60
|
-
if (!meta2) return resolve(await
|
|
60
|
+
if (!meta2) return resolve(await _chunkMENRZSGWjs.Context.filterRecord.default(new (0, _chunkMENRZSGWjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
61
61
|
const { data: { params } } = meta2;
|
|
62
|
-
const aop =
|
|
62
|
+
const aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
|
|
63
63
|
globalFilter,
|
|
64
64
|
globalGuards,
|
|
65
65
|
globalPipe
|
|
@@ -77,19 +77,19 @@ function bind(router, data, opts = {}) {
|
|
|
77
77
|
func,
|
|
78
78
|
next,
|
|
79
79
|
app: router,
|
|
80
|
-
...
|
|
81
|
-
getCookie: /* @__PURE__ */
|
|
82
|
-
setCookie: /* @__PURE__ */
|
|
83
|
-
delCookie: /* @__PURE__ */
|
|
80
|
+
..._chunkMENRZSGWjs.argToReq.call(void 0, params, item.args, req.headers),
|
|
81
|
+
getCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
82
|
+
setCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
|
|
83
|
+
delCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => res.cookie(key, "", {
|
|
84
84
|
expires: /* @__PURE__ */ new Date(0)
|
|
85
85
|
}), "delCookie"),
|
|
86
|
-
redirect: /* @__PURE__ */
|
|
87
|
-
setResHeaders: /* @__PURE__ */
|
|
88
|
-
setResStatus: /* @__PURE__ */
|
|
89
|
-
getRequest: /* @__PURE__ */
|
|
90
|
-
getResponse: /* @__PURE__ */
|
|
86
|
+
redirect: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
87
|
+
setResHeaders: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
88
|
+
setResStatus: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
89
|
+
getRequest: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => req, "getRequest"),
|
|
90
|
+
getResponse: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => res, "getResponse")
|
|
91
91
|
};
|
|
92
|
-
const context = new (0,
|
|
92
|
+
const context = new (0, _chunkMENRZSGWjs.Context)(contextData);
|
|
93
93
|
context.run(aop, resolve, resolve);
|
|
94
94
|
});
|
|
95
95
|
})).then((ret) => {
|
|
@@ -108,14 +108,14 @@ function bind(router, data, opts = {}) {
|
|
|
108
108
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
109
109
|
let aop;
|
|
110
110
|
if (!dynamic) {
|
|
111
|
-
aop =
|
|
111
|
+
aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
|
|
112
112
|
globalFilter,
|
|
113
113
|
globalGuards,
|
|
114
114
|
globalPipe
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
const subRouter = _express.Router.call(void 0, );
|
|
118
|
-
|
|
118
|
+
_chunkMENRZSGWjs.Context.applyAddons(addons, subRouter, "express");
|
|
119
119
|
subRouter[http.type](http.prefix + http.route, async (req, res, next) => {
|
|
120
120
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
121
121
|
const contextData = {
|
|
@@ -133,21 +133,21 @@ function bind(router, data, opts = {}) {
|
|
|
133
133
|
headers: req.headers,
|
|
134
134
|
app: router,
|
|
135
135
|
next,
|
|
136
|
-
getCookie: /* @__PURE__ */
|
|
137
|
-
setCookie: /* @__PURE__ */
|
|
138
|
-
delCookie: /* @__PURE__ */
|
|
136
|
+
getCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
137
|
+
setCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
|
|
138
|
+
delCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => res.cookie(key, "", {
|
|
139
139
|
expires: /* @__PURE__ */ new Date(0)
|
|
140
140
|
}), "delCookie"),
|
|
141
|
-
redirect: /* @__PURE__ */
|
|
142
|
-
setResHeaders: /* @__PURE__ */
|
|
143
|
-
setResStatus: /* @__PURE__ */
|
|
144
|
-
getRequest: /* @__PURE__ */
|
|
145
|
-
getResponse: /* @__PURE__ */
|
|
141
|
+
redirect: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (url, status) => status ? res.redirect(status, url) : res.redirect(url), "redirect"),
|
|
142
|
+
setResHeaders: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
143
|
+
setResStatus: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
144
|
+
getRequest: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => req, "getRequest"),
|
|
145
|
+
getResponse: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => res, "getResponse")
|
|
146
146
|
};
|
|
147
|
-
const context = new (0,
|
|
147
|
+
const context = new (0, _chunkMENRZSGWjs.Context)(contextData);
|
|
148
148
|
if (http.headers) res.set(http.headers);
|
|
149
149
|
if (dynamic) {
|
|
150
|
-
aop =
|
|
150
|
+
aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
|
|
151
151
|
globalFilter,
|
|
152
152
|
globalGuards,
|
|
153
153
|
globalPipe
|
|
@@ -166,9 +166,9 @@ function bind(router, data, opts = {}) {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
_chunkM5HGFUCVjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
_chunkM5HGFUCVjs.__name.call(void 0, bind, "bind");
|
|
172
172
|
|
|
173
173
|
|
|
174
174
|
exports.bind = bind;
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
7
|
detectAopDep
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-IRXNF6ZE.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-C5BVKEGW.mjs";
|
|
12
12
|
|
|
13
13
|
// src/http/express/bind.ts
|
|
14
14
|
import { Router } from "express";
|