phecda-server 6.0.1 → 6.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-YUXERDQ6.mjs → chunk-2CFYUXPM.mjs} +9 -12
- package/dist/{chunk-HDQAT2IM.mjs → chunk-3H3T54IC.mjs} +116 -87
- package/dist/{chunk-TZYATAJX.js → chunk-DVTBLV6I.js} +62 -65
- package/dist/{chunk-UXD62LGG.mjs → chunk-G7TD2VB7.mjs} +10 -2
- package/dist/{chunk-F3W3NN7F.mjs → chunk-J7B24YSE.mjs} +1 -1
- package/dist/{chunk-XCND2QW3.js → chunk-JDV2XJYE.js} +25 -25
- package/dist/chunk-NL6QBQAR.js +266 -0
- package/dist/{chunk-GHFSIZUO.js → chunk-TVT62GIX.js} +11 -3
- package/dist/core-BlN0Spy9.d.ts +47 -0
- package/dist/core-P1CsH6jz.d.mts +47 -0
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/index.d.mts +12 -11
- package/dist/index.d.ts +12 -11
- package/dist/index.js +49 -43
- package/dist/index.mjs +19 -13
- package/dist/{types-BlIBlnVT.d.ts → meta-KtfiBIde.d.mts} +44 -44
- package/dist/{types-BlIBlnVT.d.mts → meta-KtfiBIde.d.ts} +44 -44
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +12 -12
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +12 -12
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +11 -11
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +13 -13
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +11 -11
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/server/elysia/index.d.mts +3 -3
- package/dist/server/elysia/index.d.ts +3 -3
- package/dist/server/elysia/index.js +44 -32
- package/dist/server/elysia/index.mjs +17 -5
- package/dist/server/express/index.d.mts +3 -3
- package/dist/server/express/index.d.ts +3 -3
- package/dist/server/express/index.js +34 -30
- package/dist/server/express/index.mjs +8 -4
- package/dist/server/fastify/index.d.mts +3 -3
- package/dist/server/fastify/index.d.ts +3 -3
- package/dist/server/fastify/index.js +35 -31
- package/dist/server/fastify/index.mjs +9 -5
- package/dist/server/h3/index.d.mts +3 -3
- package/dist/server/h3/index.d.ts +3 -3
- package/dist/server/h3/index.js +34 -30
- package/dist/server/h3/index.mjs +8 -4
- package/dist/server/hono/index.d.mts +3 -3
- package/dist/server/hono/index.d.ts +3 -3
- package/dist/server/hono/index.js +33 -29
- package/dist/server/hono/index.mjs +8 -4
- package/dist/server/hyper-express/index.d.mts +3 -3
- package/dist/server/hyper-express/index.d.ts +3 -3
- package/dist/server/hyper-express/index.js +33 -29
- package/dist/server/hyper-express/index.mjs +8 -4
- package/dist/server/koa/index.d.mts +3 -3
- package/dist/server/koa/index.d.ts +3 -3
- package/dist/server/koa/index.js +34 -30
- package/dist/server/koa/index.mjs +8 -4
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types-BCJhmpQh.d.ts → types-BvD3B5Ny.d.mts} +4 -2
- package/dist/{types-Dgxirc9f.d.mts → types-DIw7B6Up.d.ts} +4 -2
- package/dist/{types-B-ZFZajI.d.ts → types-JVT0mgLD.d.ts} +1 -1
- package/dist/{types-AgVwUXPC.d.mts → types-t9D1fU6G.d.mts} +1 -1
- package/package.json +2 -2
- package/dist/chunk-LYEZ6RGX.js +0 -237
- package/dist/core-Blq8frmr.d.ts +0 -30
- package/dist/core-D2oL8Ge0.d.mts +0 -30
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkTVT62GIXjs = require('./chunk-TVT62GIX.js');
|
|
9
9
|
|
|
10
10
|
// src/helper.ts
|
|
11
11
|
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
@@ -14,30 +14,27 @@ var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefau
|
|
|
14
14
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
15
15
|
|
|
16
16
|
// src/pipe.ts
|
|
17
|
-
var defaultPipe = /* @__PURE__ */
|
|
17
|
+
var defaultPipe = /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, ({ arg }) => {
|
|
18
18
|
return arg;
|
|
19
19
|
}, "defaultPipe");
|
|
20
20
|
|
|
21
21
|
// src/exception/base.ts
|
|
22
22
|
var Exception = class extends Error {
|
|
23
23
|
static {
|
|
24
|
-
|
|
24
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "Exception");
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
constructor(message, status = 0, description = "Exception") {
|
|
30
|
-
super(message);
|
|
31
|
-
this.message = message;
|
|
32
|
-
this.status = status;
|
|
33
|
-
this.description = description;
|
|
30
|
+
super(message), this.message = message, this.status = status, this.description = description;
|
|
34
31
|
}
|
|
35
32
|
get data() {
|
|
36
33
|
return {
|
|
37
34
|
message: this.message,
|
|
38
35
|
description: this.description,
|
|
39
36
|
status: this.status,
|
|
40
|
-
[
|
|
37
|
+
[_chunkTVT62GIXjs.ERROR_SYMBOL]: true
|
|
41
38
|
};
|
|
42
39
|
}
|
|
43
40
|
};
|
|
@@ -45,7 +42,7 @@ var Exception = class extends Error {
|
|
|
45
42
|
// src/exception/undefine.ts
|
|
46
43
|
var UndefinedException = class extends Exception {
|
|
47
44
|
static {
|
|
48
|
-
|
|
45
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "UndefinedException");
|
|
49
46
|
}
|
|
50
47
|
constructor(message) {
|
|
51
48
|
super(message, 500, "Undefined error");
|
|
@@ -55,7 +52,7 @@ var UndefinedException = class extends Exception {
|
|
|
55
52
|
// src/exception/validate.ts
|
|
56
53
|
var ValidateException = class extends Exception {
|
|
57
54
|
static {
|
|
58
|
-
|
|
55
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "ValidateException");
|
|
59
56
|
}
|
|
60
57
|
constructor(message) {
|
|
61
58
|
super(message, 400, "Validate exception");
|
|
@@ -65,7 +62,7 @@ var ValidateException = class extends Exception {
|
|
|
65
62
|
// src/exception/forbidden.ts
|
|
66
63
|
var ForbiddenException = class extends Exception {
|
|
67
64
|
static {
|
|
68
|
-
|
|
65
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "ForbiddenException");
|
|
69
66
|
}
|
|
70
67
|
constructor(message) {
|
|
71
68
|
super(message, 403, "Forbidden resource");
|
|
@@ -75,7 +72,7 @@ var ForbiddenException = class extends Exception {
|
|
|
75
72
|
// src/exception/bad-request.ts
|
|
76
73
|
var BadRequestException = class extends Exception {
|
|
77
74
|
static {
|
|
78
|
-
|
|
75
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "BadRequestException");
|
|
79
76
|
}
|
|
80
77
|
constructor(message) {
|
|
81
78
|
super(message, 400, "Bad Request");
|
|
@@ -85,7 +82,7 @@ var BadRequestException = class extends Exception {
|
|
|
85
82
|
// src/exception/not-found.ts
|
|
86
83
|
var NotFoundException = class extends Exception {
|
|
87
84
|
static {
|
|
88
|
-
|
|
85
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "NotFoundException");
|
|
89
86
|
}
|
|
90
87
|
constructor(message) {
|
|
91
88
|
super(message, 404, "Not Found");
|
|
@@ -95,7 +92,7 @@ var NotFoundException = class extends Exception {
|
|
|
95
92
|
// src/exception/conflict.ts
|
|
96
93
|
var ConflictException = class extends Exception {
|
|
97
94
|
static {
|
|
98
|
-
|
|
95
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "ConflictException");
|
|
99
96
|
}
|
|
100
97
|
constructor(message) {
|
|
101
98
|
super(message, 409, "Conflict");
|
|
@@ -105,7 +102,7 @@ var ConflictException = class extends Exception {
|
|
|
105
102
|
// src/exception/bad-gateway.ts
|
|
106
103
|
var BadGatewayException = class extends Exception {
|
|
107
104
|
static {
|
|
108
|
-
|
|
105
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "BadGatewayException");
|
|
109
106
|
}
|
|
110
107
|
constructor(message) {
|
|
111
108
|
super(message, 502, "Bad Gatrway");
|
|
@@ -115,7 +112,7 @@ var BadGatewayException = class extends Exception {
|
|
|
115
112
|
// src/exception/invalid-input.ts
|
|
116
113
|
var InvalidInputException = class extends Exception {
|
|
117
114
|
static {
|
|
118
|
-
|
|
115
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "InvalidInputException");
|
|
119
116
|
}
|
|
120
117
|
constructor(message) {
|
|
121
118
|
super(message, 502, "Invalid Input");
|
|
@@ -125,7 +122,7 @@ var InvalidInputException = class extends Exception {
|
|
|
125
122
|
// src/exception/media-type.ts
|
|
126
123
|
var UnsupportedMediaTypeException = class extends Exception {
|
|
127
124
|
static {
|
|
128
|
-
|
|
125
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "UnsupportedMediaTypeException");
|
|
129
126
|
}
|
|
130
127
|
constructor(message) {
|
|
131
128
|
super(message, 415, "Unsupported Media Type");
|
|
@@ -135,7 +132,7 @@ var UnsupportedMediaTypeException = class extends Exception {
|
|
|
135
132
|
// src/exception/payload-large.ts
|
|
136
133
|
var PayloadLargeException = class extends Exception {
|
|
137
134
|
static {
|
|
138
|
-
|
|
135
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "PayloadLargeException");
|
|
139
136
|
}
|
|
140
137
|
constructor(message) {
|
|
141
138
|
super(message, 413, "Payload Too Large");
|
|
@@ -145,7 +142,7 @@ var PayloadLargeException = class extends Exception {
|
|
|
145
142
|
// src/exception/timeout.ts
|
|
146
143
|
var TimeoutException = class extends Exception {
|
|
147
144
|
static {
|
|
148
|
-
|
|
145
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "TimeoutException");
|
|
149
146
|
}
|
|
150
147
|
constructor(message) {
|
|
151
148
|
super(message, 408, "Request Timeout");
|
|
@@ -155,7 +152,7 @@ var TimeoutException = class extends Exception {
|
|
|
155
152
|
// src/exception/unauthorized.ts
|
|
156
153
|
var UnauthorizedException = class extends Exception {
|
|
157
154
|
static {
|
|
158
|
-
|
|
155
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "UnauthorizedException");
|
|
159
156
|
}
|
|
160
157
|
constructor(message) {
|
|
161
158
|
super(message, 401, "Unauthorized");
|
|
@@ -165,7 +162,7 @@ var UnauthorizedException = class extends Exception {
|
|
|
165
162
|
// src/exception/unavailable-service.ts
|
|
166
163
|
var ServiceUnavailableException = class extends Exception {
|
|
167
164
|
static {
|
|
168
|
-
|
|
165
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "ServiceUnavailableException");
|
|
169
166
|
}
|
|
170
167
|
constructor(message) {
|
|
171
168
|
super(message, 503, "Service Unavailable");
|
|
@@ -175,7 +172,7 @@ var ServiceUnavailableException = class extends Exception {
|
|
|
175
172
|
// src/exception/framework.ts
|
|
176
173
|
var FrameworkException = class extends Exception {
|
|
177
174
|
static {
|
|
178
|
-
|
|
175
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "FrameworkException");
|
|
179
176
|
}
|
|
180
177
|
constructor(message) {
|
|
181
178
|
super(`[phecda-server] ${message}`, 500, "Framework Error");
|
|
@@ -185,7 +182,7 @@ var FrameworkException = class extends Exception {
|
|
|
185
182
|
// src/exception/timer.ts
|
|
186
183
|
var TimerException = class extends Exception {
|
|
187
184
|
static {
|
|
188
|
-
|
|
185
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "TimerException");
|
|
189
186
|
}
|
|
190
187
|
constructor(message) {
|
|
191
188
|
super(message, 0, "Timer Error");
|
|
@@ -195,7 +192,7 @@ var TimerException = class extends Exception {
|
|
|
195
192
|
// src/exception/worker.ts
|
|
196
193
|
var WorkerException = class extends Exception {
|
|
197
194
|
static {
|
|
198
|
-
|
|
195
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "WorkerException");
|
|
199
196
|
}
|
|
200
197
|
constructor(message) {
|
|
201
198
|
super(message, 0, "Worker Error");
|
|
@@ -203,14 +200,14 @@ var WorkerException = class extends Exception {
|
|
|
203
200
|
};
|
|
204
201
|
|
|
205
202
|
// src/filter.ts
|
|
206
|
-
var defaultFilter = /* @__PURE__ */
|
|
203
|
+
var defaultFilter = /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (e) => {
|
|
207
204
|
if (!(e instanceof Exception)) {
|
|
208
|
-
|
|
209
|
-
if (
|
|
205
|
+
_chunkTVT62GIXjs.log.call(void 0, e.message, "error");
|
|
206
|
+
if (_chunkTVT62GIXjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
210
207
|
e = new UndefinedException(e.message || e);
|
|
211
208
|
} else {
|
|
212
|
-
|
|
213
|
-
if (
|
|
209
|
+
_chunkTVT62GIXjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
|
|
210
|
+
if (_chunkTVT62GIXjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
214
211
|
}
|
|
215
212
|
return e.data;
|
|
216
213
|
}, "defaultFilter");
|
|
@@ -219,7 +216,7 @@ var defaultFilter = /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (e) =>
|
|
|
219
216
|
var debug = _debug2.default.call(void 0, "phecda-server(Context)");
|
|
220
217
|
var Context = (_class = class _Context {
|
|
221
218
|
static {
|
|
222
|
-
|
|
219
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "Context");
|
|
223
220
|
}
|
|
224
221
|
|
|
225
222
|
|
|
@@ -236,7 +233,7 @@ var Context = (_class = class _Context {
|
|
|
236
233
|
|
|
237
234
|
constructor(data) {
|
|
238
235
|
this.data = data;
|
|
239
|
-
if (
|
|
236
|
+
if (_chunkTVT62GIXjs.IS_HMR)
|
|
240
237
|
data._context = this;
|
|
241
238
|
}
|
|
242
239
|
async run(opts, successCb, failCb) {
|
|
@@ -277,7 +274,7 @@ var Context = (_class = class _Context {
|
|
|
277
274
|
usePipe(args) {
|
|
278
275
|
return Promise.all(args.map((item) => {
|
|
279
276
|
if (item.pipe && !_Context.pipeRecord[item.pipe]) {
|
|
280
|
-
if (
|
|
277
|
+
if (_chunkTVT62GIXjs.IS_STRICT) {
|
|
281
278
|
throw new FrameworkException(`can't find pipe named '${item.pipe}'`);
|
|
282
279
|
} else {
|
|
283
280
|
debug(`Can't find pipe named "${item.pipe}" when handling the ${item.index + 1}th argument of the func "${this.data.func}" on module "${this.data.tag}",use default pipe instead`);
|
|
@@ -289,7 +286,7 @@ var Context = (_class = class _Context {
|
|
|
289
286
|
}
|
|
290
287
|
useFilter(arg, filter = "default") {
|
|
291
288
|
if (!_Context.filterRecord[filter]) {
|
|
292
|
-
if (
|
|
289
|
+
if (_chunkTVT62GIXjs.IS_STRICT) {
|
|
293
290
|
throw new FrameworkException(`can't find filter named "${filter}"`);
|
|
294
291
|
} else {
|
|
295
292
|
debug(`Can't find filter named "${filter}" when handling func "${this.data.func}" on module "${this.data.tag}",use default filter instead`);
|
|
@@ -301,7 +298,7 @@ var Context = (_class = class _Context {
|
|
|
301
298
|
async useGuard(guards) {
|
|
302
299
|
for (const guard of new Set(guards)) {
|
|
303
300
|
if (!(guard in _Context.guardRecord)) {
|
|
304
|
-
if (
|
|
301
|
+
if (_chunkTVT62GIXjs.IS_STRICT) throw new FrameworkException(`Can't find guard named "${guard}"`);
|
|
305
302
|
else debug(`Can't find guard named "${guard}" when handling func "${this.data.func}" on module "${this.data.tag}",skip it`);
|
|
306
303
|
continue;
|
|
307
304
|
}
|
|
@@ -318,7 +315,7 @@ var Context = (_class = class _Context {
|
|
|
318
315
|
const cb = [];
|
|
319
316
|
for (const interceptor of new Set(interceptors)) {
|
|
320
317
|
if (!(interceptor in _Context.interceptorRecord)) {
|
|
321
|
-
if (
|
|
318
|
+
if (_chunkTVT62GIXjs.IS_STRICT) throw new FrameworkException(`can't find interceptor named "${interceptor}"`);
|
|
322
319
|
else debug(`Can't find interceptor named "${interceptor}" when handling func "${this.data.func}" on module "${this.data.tag}",skip it`);
|
|
323
320
|
continue;
|
|
324
321
|
}
|
|
@@ -334,7 +331,7 @@ var Context = (_class = class _Context {
|
|
|
334
331
|
const ret = [];
|
|
335
332
|
for (const m of new Set(plugins)) {
|
|
336
333
|
if (!(m in _Context.pluginRecord)) {
|
|
337
|
-
if (
|
|
334
|
+
if (_chunkTVT62GIXjs.IS_STRICT) throw new FrameworkException(`can't find middleware named '${m}'`);
|
|
338
335
|
continue;
|
|
339
336
|
}
|
|
340
337
|
const plugin = _Context.pluginRecord[m](framework);
|
|
@@ -344,43 +341,43 @@ var Context = (_class = class _Context {
|
|
|
344
341
|
}
|
|
345
342
|
}, _class.__initStatic(), _class.__initStatic2(), _class.__initStatic3(), _class.__initStatic4(), _class.__initStatic5(), _class);
|
|
346
343
|
function addPlugin(key, handler) {
|
|
347
|
-
if (Context.pluginRecord[key] && Context.pluginRecord[key] !== handler)
|
|
344
|
+
if (Context.pluginRecord[key] && Context.pluginRecord[key] !== handler) _chunkTVT62GIXjs.log.call(void 0, `overwrite Plugin "${String(key)}"`, "warn");
|
|
348
345
|
Context.pluginRecord[key] = handler;
|
|
349
346
|
}
|
|
350
|
-
|
|
347
|
+
_chunkTVT62GIXjs.__name.call(void 0, addPlugin, "addPlugin");
|
|
351
348
|
function addPipe(key, handler) {
|
|
352
|
-
if (Context.pipeRecord[key] && Context.pipeRecord[key] !== handler)
|
|
349
|
+
if (Context.pipeRecord[key] && Context.pipeRecord[key] !== handler) _chunkTVT62GIXjs.log.call(void 0, `overwrite Pipe "${String(key)}"`, "warn");
|
|
353
350
|
Context.pipeRecord[key] = handler;
|
|
354
351
|
}
|
|
355
|
-
|
|
352
|
+
_chunkTVT62GIXjs.__name.call(void 0, addPipe, "addPipe");
|
|
356
353
|
function addFilter(key, handler) {
|
|
357
|
-
if (Context.filterRecord[key] && Context.filterRecord[key] !== handler)
|
|
354
|
+
if (Context.filterRecord[key] && Context.filterRecord[key] !== handler) _chunkTVT62GIXjs.log.call(void 0, `overwrite Filter "${String(key)}"`, "warn");
|
|
358
355
|
Context.filterRecord[key] = handler;
|
|
359
356
|
}
|
|
360
|
-
|
|
357
|
+
_chunkTVT62GIXjs.__name.call(void 0, addFilter, "addFilter");
|
|
361
358
|
function addGuard(key, handler) {
|
|
362
|
-
if (Context.guardRecord[key] && Context.guardRecord[key] !== handler)
|
|
359
|
+
if (Context.guardRecord[key] && Context.guardRecord[key] !== handler) _chunkTVT62GIXjs.log.call(void 0, `overwrite Guard "${String(key)}"`, "warn");
|
|
363
360
|
Context.guardRecord[key] = handler;
|
|
364
361
|
}
|
|
365
|
-
|
|
362
|
+
_chunkTVT62GIXjs.__name.call(void 0, addGuard, "addGuard");
|
|
366
363
|
function addInterceptor(key, handler) {
|
|
367
|
-
if (Context.interceptorRecord[key] && Context.interceptorRecord[key] !== handler)
|
|
364
|
+
if (Context.interceptorRecord[key] && Context.interceptorRecord[key] !== handler) _chunkTVT62GIXjs.log.call(void 0, `overwrite Interceptor "${String(key)}"`, "warn");
|
|
368
365
|
Context.interceptorRecord[key] = handler;
|
|
369
366
|
}
|
|
370
|
-
|
|
367
|
+
_chunkTVT62GIXjs.__name.call(void 0, addInterceptor, "addInterceptor");
|
|
371
368
|
|
|
372
369
|
// src/hmr.ts
|
|
373
370
|
function HMR(cb) {
|
|
374
|
-
if (
|
|
371
|
+
if (_chunkTVT62GIXjs.IS_HMR) _optionalChain([globalThis, 'access', _ => _.__PS_HMR__, 'optionalAccess', _2 => _2.push, 'call', _3 => _3(cb)]);
|
|
375
372
|
}
|
|
376
|
-
|
|
373
|
+
_chunkTVT62GIXjs.__name.call(void 0, HMR, "HMR");
|
|
377
374
|
|
|
378
375
|
// src/server/helper.ts
|
|
379
376
|
function resolveDep(ret, key) {
|
|
380
377
|
if (key) return _optionalChain([ret, 'optionalAccess', _4 => _4[key]]);
|
|
381
378
|
return ret;
|
|
382
379
|
}
|
|
383
|
-
|
|
380
|
+
_chunkTVT62GIXjs.__name.call(void 0, resolveDep, "resolveDep");
|
|
384
381
|
function argToReq(params, args, headers) {
|
|
385
382
|
const req = {
|
|
386
383
|
body: {},
|
|
@@ -394,14 +391,14 @@ function argToReq(params, args, headers) {
|
|
|
394
391
|
});
|
|
395
392
|
return req;
|
|
396
393
|
}
|
|
397
|
-
|
|
394
|
+
_chunkTVT62GIXjs.__name.call(void 0, argToReq, "argToReq");
|
|
398
395
|
|
|
399
396
|
// src/rpc/helper.ts
|
|
400
397
|
var _os = require('os');
|
|
401
398
|
function genClientQueue(key) {
|
|
402
399
|
return `PS-${key ? `${key}-` : ""}${_os.hostname.call(void 0, )}-${process.pid}`;
|
|
403
400
|
}
|
|
404
|
-
|
|
401
|
+
_chunkTVT62GIXjs.__name.call(void 0, genClientQueue, "genClientQueue");
|
|
405
402
|
|
|
406
403
|
// src/decorators/helper.ts
|
|
407
404
|
function shallowClone(obj) {
|
|
@@ -409,11 +406,11 @@ function shallowClone(obj) {
|
|
|
409
406
|
...obj
|
|
410
407
|
};
|
|
411
408
|
}
|
|
412
|
-
|
|
409
|
+
_chunkTVT62GIXjs.__name.call(void 0, shallowClone, "shallowClone");
|
|
413
410
|
function mergeObject(...args) {
|
|
414
411
|
return Object.assign({}, ...args);
|
|
415
412
|
}
|
|
416
|
-
|
|
413
|
+
_chunkTVT62GIXjs.__name.call(void 0, mergeObject, "mergeObject");
|
|
417
414
|
|
|
418
415
|
// src/helper.ts
|
|
419
416
|
function createControllerMetaMap(meta, filter) {
|
|
@@ -429,12 +426,12 @@ function createControllerMetaMap(meta, filter) {
|
|
|
429
426
|
});
|
|
430
427
|
}
|
|
431
428
|
}
|
|
432
|
-
|
|
429
|
+
_chunkTVT62GIXjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
433
430
|
handleMeta();
|
|
434
431
|
HMR(handleMeta);
|
|
435
432
|
return metaMap;
|
|
436
433
|
}
|
|
437
|
-
|
|
434
|
+
_chunkTVT62GIXjs.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
|
|
438
435
|
function detectAopDep(meta, { guards, interceptors, plugins } = {}, controller = "http") {
|
|
439
436
|
const pluginSet = /* @__PURE__ */ new Set();
|
|
440
437
|
const guardSet = /* @__PURE__ */ new Set();
|
|
@@ -486,14 +483,14 @@ function detectAopDep(meta, { guards, interceptors, plugins } = {}, controller =
|
|
|
486
483
|
const missFilters = [
|
|
487
484
|
...filterSet
|
|
488
485
|
].filter((i) => !Context.filterRecord[i]);
|
|
489
|
-
if (missPlugins.length)
|
|
490
|
-
if (missGuards.length)
|
|
491
|
-
if (missInterceptors.length)
|
|
492
|
-
if (missPipes.length)
|
|
493
|
-
if (missFilters.length)
|
|
494
|
-
warningSet.forEach((warn) =>
|
|
495
|
-
}
|
|
496
|
-
|
|
486
|
+
if (missPlugins.length) _chunkTVT62GIXjs.log.call(void 0, `${_picocolors2.default.white(`Plugin [${missPlugins.join(",")}]`)} doesn't exist`, "warn");
|
|
487
|
+
if (missGuards.length) _chunkTVT62GIXjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
|
|
488
|
+
if (missInterceptors.length) _chunkTVT62GIXjs.log.call(void 0, `${_picocolors2.default.cyan(`Interceptor [${missInterceptors.join(",")}]`)} doesn't exist`, "warn");
|
|
489
|
+
if (missPipes.length) _chunkTVT62GIXjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
|
|
490
|
+
if (missFilters.length) _chunkTVT62GIXjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
|
|
491
|
+
warningSet.forEach((warn) => _chunkTVT62GIXjs.log.call(void 0, warn, "warn"));
|
|
492
|
+
}
|
|
493
|
+
_chunkTVT62GIXjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
497
494
|
handleMeta();
|
|
498
495
|
HMR(handleMeta);
|
|
499
496
|
return {
|
|
@@ -504,7 +501,7 @@ function detectAopDep(meta, { guards, interceptors, plugins } = {}, controller =
|
|
|
504
501
|
filterSet
|
|
505
502
|
};
|
|
506
503
|
}
|
|
507
|
-
|
|
504
|
+
_chunkTVT62GIXjs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
508
505
|
|
|
509
506
|
|
|
510
507
|
|
|
@@ -539,4 +536,4 @@ _chunkGHFSIZUOjs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
|
539
536
|
|
|
540
537
|
|
|
541
538
|
|
|
542
|
-
exports.defaultPipe = defaultPipe; 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.
|
|
539
|
+
exports.defaultPipe = defaultPipe; 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.Context = Context; exports.addPlugin = addPlugin; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addInterceptor = addInterceptor; exports.HMR = HMR; exports.resolveDep = resolveDep; exports.argToReq = argToReq; exports.genClientQueue = genClientQueue; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep;
|
|
@@ -17,13 +17,19 @@ var PS_EXIT_CODE;
|
|
|
17
17
|
import pc from "picocolors";
|
|
18
18
|
import { Mixin } from "ts-mixer";
|
|
19
19
|
var time;
|
|
20
|
-
var internalLogger
|
|
20
|
+
var internalLogger;
|
|
21
21
|
function setLogger(logger) {
|
|
22
22
|
internalLogger = logger;
|
|
23
23
|
}
|
|
24
24
|
__name(setLogger, "setLogger");
|
|
25
|
+
function getLogger() {
|
|
26
|
+
return internalLogger;
|
|
27
|
+
}
|
|
28
|
+
__name(getLogger, "getLogger");
|
|
25
29
|
function log(msg, level = "log") {
|
|
30
|
+
if (internalLogger) internalLogger[level](msg);
|
|
26
31
|
const logLevel = {
|
|
32
|
+
debug: -1,
|
|
27
33
|
info: 0,
|
|
28
34
|
log: 1,
|
|
29
35
|
warn: 2,
|
|
@@ -31,6 +37,7 @@ function log(msg, level = "log") {
|
|
|
31
37
|
}[level];
|
|
32
38
|
if (logLevel < LOG_LEVEL) return;
|
|
33
39
|
const color = {
|
|
40
|
+
debug: "bgMagenta",
|
|
34
41
|
error: "red",
|
|
35
42
|
info: "gray",
|
|
36
43
|
warn: "yellow",
|
|
@@ -40,7 +47,7 @@ function log(msg, level = "log") {
|
|
|
40
47
|
const current = Date.now();
|
|
41
48
|
const interval = time && current - time ? `+${current - time}` : "";
|
|
42
49
|
time = current;
|
|
43
|
-
|
|
50
|
+
console[level](`${pc.magenta("[phecda-server]")} ${pc.gray(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`)} ${pc[color](msg)} ${pc.gray(interval)}`);
|
|
44
51
|
}
|
|
45
52
|
__name(log, "log");
|
|
46
53
|
|
|
@@ -53,6 +60,7 @@ export {
|
|
|
53
60
|
LOG_LEVEL,
|
|
54
61
|
PS_EXIT_CODE,
|
|
55
62
|
setLogger,
|
|
63
|
+
getLogger,
|
|
56
64
|
log,
|
|
57
65
|
Mixin
|
|
58
66
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkTVT62GIXjs = require('./chunk-TVT62GIX.js');
|
|
4
4
|
|
|
5
5
|
// src/decorators/param.ts
|
|
6
6
|
var _phecdacore = require('phecda-core');
|
|
@@ -10,42 +10,42 @@ function BaseParam(data) {
|
|
|
10
10
|
_phecdacore.setMeta.call(void 0, target, property, index, data);
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
_chunkTVT62GIXjs.__name.call(void 0, BaseParam, "BaseParam");
|
|
14
14
|
function Body(key = "") {
|
|
15
15
|
return BaseParam({
|
|
16
16
|
type: "body",
|
|
17
17
|
key
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
_chunkTVT62GIXjs.__name.call(void 0, Body, "Body");
|
|
21
21
|
function Head(key) {
|
|
22
22
|
return BaseParam({
|
|
23
23
|
type: "headers",
|
|
24
24
|
key: key.toLowerCase()
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
_chunkTVT62GIXjs.__name.call(void 0, Head, "Head");
|
|
28
28
|
function Query(key = "") {
|
|
29
29
|
return BaseParam({
|
|
30
30
|
type: "query",
|
|
31
31
|
key
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
_chunkTVT62GIXjs.__name.call(void 0, Query, "Query");
|
|
35
35
|
function Param(key) {
|
|
36
36
|
return BaseParam({
|
|
37
37
|
type: "params",
|
|
38
38
|
key
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
_chunkTVT62GIXjs.__name.call(void 0, Param, "Param");
|
|
42
42
|
function Arg(target, k, index) {
|
|
43
43
|
BaseParam({
|
|
44
44
|
type: "args",
|
|
45
45
|
key: `${index}`
|
|
46
46
|
})(target, k, index);
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
_chunkTVT62GIXjs.__name.call(void 0, Arg, "Arg");
|
|
49
49
|
|
|
50
50
|
// src/decorators/aop.ts
|
|
51
51
|
|
|
@@ -56,7 +56,7 @@ function Guard(...guards) {
|
|
|
56
56
|
});
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
_chunkTVT62GIXjs.__name.call(void 0, Guard, "Guard");
|
|
60
60
|
function Plugin(...plugins) {
|
|
61
61
|
return (target, property) => {
|
|
62
62
|
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
@@ -64,7 +64,7 @@ function Plugin(...plugins) {
|
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
_chunkTVT62GIXjs.__name.call(void 0, Plugin, "Plugin");
|
|
68
68
|
function Interceptor(...interceptors) {
|
|
69
69
|
return (target, property) => {
|
|
70
70
|
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
@@ -72,7 +72,7 @@ function Interceptor(...interceptors) {
|
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
_chunkTVT62GIXjs.__name.call(void 0, Interceptor, "Interceptor");
|
|
76
76
|
function Filter(filter) {
|
|
77
77
|
return (target, property) => {
|
|
78
78
|
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
@@ -80,7 +80,7 @@ function Filter(filter) {
|
|
|
80
80
|
});
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
_chunkTVT62GIXjs.__name.call(void 0, Filter, "Filter");
|
|
84
84
|
function Pipe(pipe) {
|
|
85
85
|
return (target, property, index) => {
|
|
86
86
|
if (typeof index === "number") {
|
|
@@ -94,7 +94,7 @@ function Pipe(pipe) {
|
|
|
94
94
|
});
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
_chunkTVT62GIXjs.__name.call(void 0, Pipe, "Pipe");
|
|
98
98
|
|
|
99
99
|
// src/decorators/http.ts
|
|
100
100
|
|
|
@@ -108,7 +108,7 @@ function Route(route, type) {
|
|
|
108
108
|
});
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
_chunkTVT62GIXjs.__name.call(void 0, Route, "Route");
|
|
112
112
|
function Header(headers) {
|
|
113
113
|
return (target, property) => {
|
|
114
114
|
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
@@ -118,31 +118,31 @@ function Header(headers) {
|
|
|
118
118
|
});
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
_chunkTVT62GIXjs.__name.call(void 0, Header, "Header");
|
|
122
122
|
function Get(route = "") {
|
|
123
123
|
return Route(route, "get");
|
|
124
124
|
}
|
|
125
|
-
|
|
125
|
+
_chunkTVT62GIXjs.__name.call(void 0, Get, "Get");
|
|
126
126
|
function Post(route = "") {
|
|
127
127
|
return Route(route, "post");
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
_chunkTVT62GIXjs.__name.call(void 0, Post, "Post");
|
|
130
130
|
function Put(route = "") {
|
|
131
131
|
return Route(route, "put");
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
_chunkTVT62GIXjs.__name.call(void 0, Put, "Put");
|
|
134
134
|
function Search(route = "") {
|
|
135
135
|
return Route(route, "search");
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
_chunkTVT62GIXjs.__name.call(void 0, Search, "Search");
|
|
138
138
|
function Patch(route = "") {
|
|
139
139
|
return Route(route, "patch");
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
_chunkTVT62GIXjs.__name.call(void 0, Patch, "Patch");
|
|
142
142
|
function Delete(route = "") {
|
|
143
143
|
return Route(route, "delete");
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
_chunkTVT62GIXjs.__name.call(void 0, Delete, "Delete");
|
|
146
146
|
function Controller(prefix = "") {
|
|
147
147
|
return (target) => {
|
|
148
148
|
_phecdacore.setMeta.call(void 0, target, void 0, void 0, {
|
|
@@ -153,7 +153,7 @@ function Controller(prefix = "") {
|
|
|
153
153
|
});
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
_chunkTVT62GIXjs.__name.call(void 0, Controller, "Controller");
|
|
157
157
|
|
|
158
158
|
// src/decorators/rpc.ts
|
|
159
159
|
|
|
@@ -167,7 +167,7 @@ function Queue(queue = "", isEvent) {
|
|
|
167
167
|
});
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
_chunkTVT62GIXjs.__name.call(void 0, Queue, "Queue");
|
|
171
171
|
function Rpc() {
|
|
172
172
|
return (target) => {
|
|
173
173
|
_phecdacore.setMeta.call(void 0, target, void 0, void 0, {
|
|
@@ -175,11 +175,11 @@ function Rpc() {
|
|
|
175
175
|
});
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
_chunkTVT62GIXjs.__name.call(void 0, Rpc, "Rpc");
|
|
179
179
|
|
|
180
180
|
// src/decorators/ctx.ts
|
|
181
181
|
|
|
182
|
-
var Ctx = /* @__PURE__ */
|
|
182
|
+
var Ctx = /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (target, property) => {
|
|
183
183
|
_phecdacore.setMeta.call(void 0, target, _phecdacore.SHARE_KEY, void 0, {
|
|
184
184
|
ctxs: [
|
|
185
185
|
property
|
|
@@ -208,7 +208,7 @@ function Define(key, value) {
|
|
|
208
208
|
}
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
-
|
|
211
|
+
_chunkTVT62GIXjs.__name.call(void 0, Define, "Define");
|
|
212
212
|
|
|
213
213
|
|
|
214
214
|
|