phecda-server 8.0.2 → 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 +35 -5
- 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/index.mjs +27 -0
- package/register/loader.mjs +65 -65
- package/register/utils.mjs +10 -15
- package/register/export.mjs +0 -39
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkOUQM7GZHjs = require('./chunk-OUQM7GZH.js');
|
|
11
11
|
|
|
12
12
|
// src/helper.ts
|
|
13
13
|
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
@@ -22,7 +22,7 @@ var _phecdacore = require('phecda-core');
|
|
|
22
22
|
// src/exception/base.ts
|
|
23
23
|
var Exception = class extends Error {
|
|
24
24
|
static {
|
|
25
|
-
|
|
25
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "Exception");
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
|
|
@@ -35,7 +35,7 @@ var Exception = class extends Error {
|
|
|
35
35
|
message: this.message,
|
|
36
36
|
description: this.description,
|
|
37
37
|
status: this.status,
|
|
38
|
-
[
|
|
38
|
+
[_chunkOUQM7GZHjs.ERROR_SYMBOL]: true
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
};
|
|
@@ -43,7 +43,7 @@ var Exception = class extends Error {
|
|
|
43
43
|
// src/exception/undefine.ts
|
|
44
44
|
var UndefinedException = class extends Exception {
|
|
45
45
|
static {
|
|
46
|
-
|
|
46
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "UndefinedException");
|
|
47
47
|
}
|
|
48
48
|
constructor(message) {
|
|
49
49
|
super(message, 500, "Undefined error");
|
|
@@ -53,7 +53,7 @@ var UndefinedException = class extends Exception {
|
|
|
53
53
|
// src/exception/validate.ts
|
|
54
54
|
var ValidateException = class extends Exception {
|
|
55
55
|
static {
|
|
56
|
-
|
|
56
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "ValidateException");
|
|
57
57
|
}
|
|
58
58
|
constructor(message) {
|
|
59
59
|
super(message, 400, "Validate exception");
|
|
@@ -63,7 +63,7 @@ var ValidateException = class extends Exception {
|
|
|
63
63
|
// src/exception/forbidden.ts
|
|
64
64
|
var ForbiddenException = class extends Exception {
|
|
65
65
|
static {
|
|
66
|
-
|
|
66
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "ForbiddenException");
|
|
67
67
|
}
|
|
68
68
|
constructor(message) {
|
|
69
69
|
super(message, 403, "Forbidden resource");
|
|
@@ -73,7 +73,7 @@ var ForbiddenException = class extends Exception {
|
|
|
73
73
|
// src/exception/bad-request.ts
|
|
74
74
|
var BadRequestException = class extends Exception {
|
|
75
75
|
static {
|
|
76
|
-
|
|
76
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "BadRequestException");
|
|
77
77
|
}
|
|
78
78
|
constructor(message) {
|
|
79
79
|
super(message, 400, "Bad Request");
|
|
@@ -83,7 +83,7 @@ var BadRequestException = class extends Exception {
|
|
|
83
83
|
// src/exception/not-found.ts
|
|
84
84
|
var NotFoundException = class extends Exception {
|
|
85
85
|
static {
|
|
86
|
-
|
|
86
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "NotFoundException");
|
|
87
87
|
}
|
|
88
88
|
constructor(message) {
|
|
89
89
|
super(message, 404, "Not Found");
|
|
@@ -93,7 +93,7 @@ var NotFoundException = class extends Exception {
|
|
|
93
93
|
// src/exception/conflict.ts
|
|
94
94
|
var ConflictException = class extends Exception {
|
|
95
95
|
static {
|
|
96
|
-
|
|
96
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "ConflictException");
|
|
97
97
|
}
|
|
98
98
|
constructor(message) {
|
|
99
99
|
super(message, 409, "Conflict");
|
|
@@ -103,7 +103,7 @@ var ConflictException = class extends Exception {
|
|
|
103
103
|
// src/exception/bad-gateway.ts
|
|
104
104
|
var BadGatewayException = class extends Exception {
|
|
105
105
|
static {
|
|
106
|
-
|
|
106
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "BadGatewayException");
|
|
107
107
|
}
|
|
108
108
|
constructor(message) {
|
|
109
109
|
super(message, 502, "Bad Gatrway");
|
|
@@ -113,7 +113,7 @@ var BadGatewayException = class extends Exception {
|
|
|
113
113
|
// src/exception/invalid-input.ts
|
|
114
114
|
var InvalidInputException = class extends Exception {
|
|
115
115
|
static {
|
|
116
|
-
|
|
116
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "InvalidInputException");
|
|
117
117
|
}
|
|
118
118
|
constructor(message) {
|
|
119
119
|
super(message, 502, "Invalid Input");
|
|
@@ -123,7 +123,7 @@ var InvalidInputException = class extends Exception {
|
|
|
123
123
|
// src/exception/media-type.ts
|
|
124
124
|
var UnsupportedMediaTypeException = class extends Exception {
|
|
125
125
|
static {
|
|
126
|
-
|
|
126
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "UnsupportedMediaTypeException");
|
|
127
127
|
}
|
|
128
128
|
constructor(message) {
|
|
129
129
|
super(message, 415, "Unsupported Media Type");
|
|
@@ -133,7 +133,7 @@ var UnsupportedMediaTypeException = class extends Exception {
|
|
|
133
133
|
// src/exception/payload-large.ts
|
|
134
134
|
var PayloadLargeException = class extends Exception {
|
|
135
135
|
static {
|
|
136
|
-
|
|
136
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "PayloadLargeException");
|
|
137
137
|
}
|
|
138
138
|
constructor(message) {
|
|
139
139
|
super(message, 413, "Payload Too Large");
|
|
@@ -143,7 +143,7 @@ var PayloadLargeException = class extends Exception {
|
|
|
143
143
|
// src/exception/timeout.ts
|
|
144
144
|
var TimeoutException = class extends Exception {
|
|
145
145
|
static {
|
|
146
|
-
|
|
146
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "TimeoutException");
|
|
147
147
|
}
|
|
148
148
|
constructor(message) {
|
|
149
149
|
super(message, 408, "Request Timeout");
|
|
@@ -153,7 +153,7 @@ var TimeoutException = class extends Exception {
|
|
|
153
153
|
// src/exception/unauthorized.ts
|
|
154
154
|
var UnauthorizedException = class extends Exception {
|
|
155
155
|
static {
|
|
156
|
-
|
|
156
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "UnauthorizedException");
|
|
157
157
|
}
|
|
158
158
|
constructor(message) {
|
|
159
159
|
super(message, 401, "Unauthorized");
|
|
@@ -163,7 +163,7 @@ var UnauthorizedException = class extends Exception {
|
|
|
163
163
|
// src/exception/unavailable-service.ts
|
|
164
164
|
var ServiceUnavailableException = class extends Exception {
|
|
165
165
|
static {
|
|
166
|
-
|
|
166
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "ServiceUnavailableException");
|
|
167
167
|
}
|
|
168
168
|
constructor(message) {
|
|
169
169
|
super(message, 503, "Service Unavailable");
|
|
@@ -173,7 +173,7 @@ var ServiceUnavailableException = class extends Exception {
|
|
|
173
173
|
// src/exception/framework.ts
|
|
174
174
|
var FrameworkException = class extends Exception {
|
|
175
175
|
static {
|
|
176
|
-
|
|
176
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "FrameworkException");
|
|
177
177
|
}
|
|
178
178
|
constructor(message) {
|
|
179
179
|
super(`[phecda-server] ${message}`, 500, "Framework Error");
|
|
@@ -183,7 +183,7 @@ var FrameworkException = class extends Exception {
|
|
|
183
183
|
// src/exception/timer.ts
|
|
184
184
|
var TimerException = class extends Exception {
|
|
185
185
|
static {
|
|
186
|
-
|
|
186
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "TimerException");
|
|
187
187
|
}
|
|
188
188
|
constructor(message) {
|
|
189
189
|
super(message, 0, "Timer Error");
|
|
@@ -193,7 +193,7 @@ var TimerException = class extends Exception {
|
|
|
193
193
|
// src/exception/worker.ts
|
|
194
194
|
var WorkerException = class extends Exception {
|
|
195
195
|
static {
|
|
196
|
-
|
|
196
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "WorkerException");
|
|
197
197
|
}
|
|
198
198
|
constructor(message) {
|
|
199
199
|
super(message, 0, "Worker Error");
|
|
@@ -201,7 +201,7 @@ var WorkerException = class extends Exception {
|
|
|
201
201
|
};
|
|
202
202
|
|
|
203
203
|
// src/pipe.ts
|
|
204
|
-
var defaultPipe = /* @__PURE__ */
|
|
204
|
+
var defaultPipe = /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, async ({ arg, reflect, meta, index, type }, { method }) => {
|
|
205
205
|
if (meta.const) {
|
|
206
206
|
if (arg !== meta.const) throw new ValidateException(`param ${index + 1} must be ${meta.const}`);
|
|
207
207
|
}
|
|
@@ -285,14 +285,14 @@ var defaultPipe = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, async ({
|
|
|
285
285
|
}, "defaultPipe");
|
|
286
286
|
|
|
287
287
|
// src/filter.ts
|
|
288
|
-
var defaultFilter = /* @__PURE__ */
|
|
288
|
+
var defaultFilter = /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (e) => {
|
|
289
289
|
if (!(e instanceof Exception)) {
|
|
290
|
-
|
|
291
|
-
if (
|
|
290
|
+
_chunkOUQM7GZHjs.log.call(void 0, e.message, "error");
|
|
291
|
+
if (_chunkOUQM7GZHjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
292
292
|
e = new UndefinedException(e.message || e);
|
|
293
293
|
} else {
|
|
294
|
-
|
|
295
|
-
if (
|
|
294
|
+
_chunkOUQM7GZHjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
|
|
295
|
+
if (_chunkOUQM7GZHjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
296
296
|
}
|
|
297
297
|
return e.data;
|
|
298
298
|
}, "defaultFilter");
|
|
@@ -301,7 +301,7 @@ var defaultFilter = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (e) =>
|
|
|
301
301
|
var debug = _debug2.default.call(void 0, "phecda-server(Context)");
|
|
302
302
|
var Context = (_class = class _Context {
|
|
303
303
|
static {
|
|
304
|
-
|
|
304
|
+
_chunkOUQM7GZHjs.__name.call(void 0, this, "Context");
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
|
|
@@ -318,11 +318,11 @@ var Context = (_class = class _Context {
|
|
|
318
318
|
// protected canGetCtx = true
|
|
319
319
|
constructor(data) {
|
|
320
320
|
this.data = data;
|
|
321
|
-
if (
|
|
321
|
+
if (_chunkOUQM7GZHjs.IS_DEV)
|
|
322
322
|
data._context = this;
|
|
323
323
|
this.ctx = new Proxy(data, {
|
|
324
324
|
get(target, p) {
|
|
325
|
-
if (!(p in target))
|
|
325
|
+
if (!(p in target)) _chunkOUQM7GZHjs.log.call(void 0, `attribute "${p}" does not exist on ctx, which might be due to a missing AOP role (such as a guard).`, "warn", data.tag);
|
|
326
326
|
return target[p];
|
|
327
327
|
},
|
|
328
328
|
set(target, p, newValue) {
|
|
@@ -360,7 +360,7 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
360
360
|
const { paramsType, data: { ctxs, tag, params, method } } = meta;
|
|
361
361
|
try {
|
|
362
362
|
let res;
|
|
363
|
-
const nextHandler = /* @__PURE__ */
|
|
363
|
+
const nextHandler = /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (index) => {
|
|
364
364
|
return async () => {
|
|
365
365
|
if (index === guards.length) {
|
|
366
366
|
const instance = moduleMap.get(tag);
|
|
@@ -384,7 +384,7 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
384
384
|
return res;
|
|
385
385
|
});
|
|
386
386
|
}
|
|
387
|
-
|
|
387
|
+
_chunkOUQM7GZHjs.__name.call(void 0, next, "next");
|
|
388
388
|
const ret = await guards[index](this.ctx, next);
|
|
389
389
|
if (ret !== void 0) {
|
|
390
390
|
res = ret;
|
|
@@ -429,12 +429,12 @@ function addPipe(key, pipe) {
|
|
|
429
429
|
if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) debug(`overwrite Pipe "${String(key)}"`, "warn");
|
|
430
430
|
Context.pipeRecord[key] = pipe;
|
|
431
431
|
}
|
|
432
|
-
|
|
432
|
+
_chunkOUQM7GZHjs.__name.call(void 0, addPipe, "addPipe");
|
|
433
433
|
function addFilter(key, filter) {
|
|
434
434
|
if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) debug(`overwrite Filter "${String(key)}"`, "warn");
|
|
435
435
|
Context.filterRecord[key] = filter;
|
|
436
436
|
}
|
|
437
|
-
|
|
437
|
+
_chunkOUQM7GZHjs.__name.call(void 0, addFilter, "addFilter");
|
|
438
438
|
function addGuard(key, guard, priority = 0) {
|
|
439
439
|
if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) debug(`overwrite Guard "${String(key)}"`, "warn");
|
|
440
440
|
Context.guardRecord[key] = {
|
|
@@ -442,7 +442,7 @@ function addGuard(key, guard, priority = 0) {
|
|
|
442
442
|
priority
|
|
443
443
|
};
|
|
444
444
|
}
|
|
445
|
-
|
|
445
|
+
_chunkOUQM7GZHjs.__name.call(void 0, addGuard, "addGuard");
|
|
446
446
|
function addAddon(key, addon, priority = 0) {
|
|
447
447
|
if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) debug(`overwrite Addon "${String(key)}"`, "warn");
|
|
448
448
|
Context.addonRecord[key] = {
|
|
@@ -450,14 +450,14 @@ function addAddon(key, addon, priority = 0) {
|
|
|
450
450
|
priority
|
|
451
451
|
};
|
|
452
452
|
}
|
|
453
|
-
|
|
453
|
+
_chunkOUQM7GZHjs.__name.call(void 0, addAddon, "addAddon");
|
|
454
454
|
|
|
455
455
|
// src/http/helper.ts
|
|
456
456
|
function resolveDep(ret, key) {
|
|
457
457
|
if (key) return _optionalChain([ret, 'optionalAccess', _ => _[key]]);
|
|
458
458
|
return ret;
|
|
459
459
|
}
|
|
460
|
-
|
|
460
|
+
_chunkOUQM7GZHjs.__name.call(void 0, resolveDep, "resolveDep");
|
|
461
461
|
|
|
462
462
|
// src/decorators/helper.ts
|
|
463
463
|
function shallowClone(obj) {
|
|
@@ -465,11 +465,11 @@ function shallowClone(obj) {
|
|
|
465
465
|
...obj
|
|
466
466
|
};
|
|
467
467
|
}
|
|
468
|
-
|
|
468
|
+
_chunkOUQM7GZHjs.__name.call(void 0, shallowClone, "shallowClone");
|
|
469
469
|
function mergeObject(...args) {
|
|
470
470
|
return Object.assign({}, ...args);
|
|
471
471
|
}
|
|
472
|
-
|
|
472
|
+
_chunkOUQM7GZHjs.__name.call(void 0, mergeObject, "mergeObject");
|
|
473
473
|
|
|
474
474
|
// src/helper.ts
|
|
475
475
|
function createControllerMetaMap(meta, filter) {
|
|
@@ -485,14 +485,14 @@ function createControllerMetaMap(meta, filter) {
|
|
|
485
485
|
});
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
|
|
488
|
+
_chunkOUQM7GZHjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
489
489
|
handleMeta();
|
|
490
|
-
|
|
490
|
+
_chunkOUQM7GZHjs.HMR.call(void 0, handleMeta);
|
|
491
491
|
return metaMap;
|
|
492
492
|
}
|
|
493
|
-
|
|
493
|
+
_chunkOUQM7GZHjs.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
|
|
494
494
|
function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
495
|
-
if (
|
|
495
|
+
if (_chunkOUQM7GZHjs.IS_PURE) return;
|
|
496
496
|
const addonSet = /* @__PURE__ */ new Set();
|
|
497
497
|
const guardSet = /* @__PURE__ */ new Set();
|
|
498
498
|
const pipeSet = /* @__PURE__ */ new Set();
|
|
@@ -537,34 +537,34 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
|
537
537
|
...filterSet
|
|
538
538
|
].filter((i) => !Context.filterRecord[i]);
|
|
539
539
|
function exit() {
|
|
540
|
-
if (
|
|
541
|
-
|
|
540
|
+
if (_chunkOUQM7GZHjs.IS_STRICT) {
|
|
541
|
+
_chunkOUQM7GZHjs.log.call(void 0, "Does not meet strict mode requirements", "error");
|
|
542
542
|
process.exit(1);
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
|
-
|
|
545
|
+
_chunkOUQM7GZHjs.__name.call(void 0, exit, "exit");
|
|
546
546
|
if (missAddons.length) {
|
|
547
|
-
|
|
547
|
+
_chunkOUQM7GZHjs.log.call(void 0, `${_picocolors2.default.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
|
|
548
548
|
exit();
|
|
549
549
|
}
|
|
550
550
|
if (missGuards.length) {
|
|
551
|
-
|
|
551
|
+
_chunkOUQM7GZHjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
|
|
552
552
|
exit();
|
|
553
553
|
}
|
|
554
554
|
if (missPipes.length) {
|
|
555
|
-
|
|
555
|
+
_chunkOUQM7GZHjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
|
|
556
556
|
exit();
|
|
557
557
|
}
|
|
558
558
|
if (missFilters.length) {
|
|
559
|
-
|
|
559
|
+
_chunkOUQM7GZHjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
|
|
560
560
|
exit();
|
|
561
561
|
}
|
|
562
|
-
warningSet.forEach((warn) =>
|
|
562
|
+
warningSet.forEach((warn) => _chunkOUQM7GZHjs.log.call(void 0, warn, "warn"));
|
|
563
563
|
if (warningSet.size) exit();
|
|
564
564
|
}
|
|
565
|
-
|
|
565
|
+
_chunkOUQM7GZHjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
566
566
|
handleMeta();
|
|
567
|
-
|
|
567
|
+
_chunkOUQM7GZHjs.HMR.call(void 0, handleMeta);
|
|
568
568
|
return {
|
|
569
569
|
addonSet,
|
|
570
570
|
guardSet,
|
|
@@ -572,7 +572,7 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
|
572
572
|
filterSet
|
|
573
573
|
};
|
|
574
574
|
}
|
|
575
|
-
|
|
575
|
+
_chunkOUQM7GZHjs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
576
576
|
function joinUrl(base, ...paths) {
|
|
577
577
|
const joinedPath = [
|
|
578
578
|
base,
|
|
@@ -580,7 +580,7 @@ function joinUrl(base, ...paths) {
|
|
|
580
580
|
].filter((p) => p).map((path) => path.replace(/(^\/)/g, "")).join("/");
|
|
581
581
|
return `/${joinedPath}`;
|
|
582
582
|
}
|
|
583
|
-
|
|
583
|
+
_chunkOUQM7GZHjs.__name.call(void 0, joinUrl, "joinUrl");
|
|
584
584
|
|
|
585
585
|
|
|
586
586
|
|
|
@@ -612,4 +612,5 @@ _chunk4LLLQOMFjs.__name.call(void 0, joinUrl, "joinUrl");
|
|
|
612
612
|
|
|
613
613
|
|
|
614
614
|
|
|
615
|
-
|
|
615
|
+
|
|
616
|
+
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.defaultFilter = defaultFilter; 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;
|
|
@@ -8,11 +8,11 @@ var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
|
8
8
|
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
9
|
var IS_PURE = !!process.env.PS_PURE;
|
|
10
10
|
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
11
|
-
var PS_EXIT_CODE = /* @__PURE__ */ function(PS_EXIT_CODE2) {
|
|
11
|
+
var PS_EXIT_CODE = /* @__PURE__ */ (function(PS_EXIT_CODE2) {
|
|
12
12
|
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 4171] = "RELAUNCH";
|
|
13
13
|
PS_EXIT_CODE2[PS_EXIT_CODE2["EXIT"] = 4172] = "EXIT";
|
|
14
14
|
return PS_EXIT_CODE2;
|
|
15
|
-
}({});
|
|
15
|
+
})({});
|
|
16
16
|
|
|
17
17
|
// src/utils.ts
|
|
18
18
|
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
@@ -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 };
|