phecda-server 6.0.2 → 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-WXFZZZRY.mjs → chunk-2CFYUXPM.mjs} +1 -1
- package/dist/{chunk-HDQAT2IM.mjs → chunk-3H3T54IC.mjs} +116 -87
- package/dist/{chunk-7SYPUIBY.js → chunk-DVTBLV6I.js} +60 -60
- 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.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +49 -43
- package/dist/index.mjs +15 -9
- package/dist/rpc/bullmq/index.d.mts +1 -1
- package/dist/rpc/bullmq/index.d.ts +1 -1
- package/dist/rpc/bullmq/index.js +12 -12
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.d.mts +1 -1
- package/dist/rpc/kafka/index.d.ts +1 -1
- package/dist/rpc/kafka/index.js +12 -12
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +1 -1
- package/dist/rpc/nats/index.d.ts +1 -1
- package/dist/rpc/nats/index.js +11 -11
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.d.mts +1 -1
- package/dist/rpc/rabbitmq/index.d.ts +1 -1
- package/dist/rpc/rabbitmq/index.js +13 -13
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.d.mts +1 -1
- package/dist/rpc/redis/index.d.ts +1 -1
- package/dist/rpc/redis/index.js +11 -11
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/server/elysia/index.d.mts +1 -1
- package/dist/server/elysia/index.d.ts +1 -1
- package/dist/server/elysia/index.js +36 -36
- package/dist/server/elysia/index.mjs +3 -3
- package/dist/server/express/index.d.mts +1 -1
- package/dist/server/express/index.d.ts +1 -1
- package/dist/server/express/index.js +34 -34
- package/dist/server/express/index.mjs +2 -2
- package/dist/server/fastify/index.d.mts +1 -1
- package/dist/server/fastify/index.d.ts +1 -1
- package/dist/server/fastify/index.js +35 -35
- package/dist/server/fastify/index.mjs +3 -3
- package/dist/server/h3/index.d.mts +1 -1
- package/dist/server/h3/index.d.ts +1 -1
- package/dist/server/h3/index.js +34 -34
- package/dist/server/h3/index.mjs +2 -2
- package/dist/server/hono/index.d.mts +1 -1
- package/dist/server/hono/index.d.ts +1 -1
- package/dist/server/hono/index.js +33 -33
- package/dist/server/hono/index.mjs +2 -2
- package/dist/server/hyper-express/index.d.mts +1 -1
- package/dist/server/hyper-express/index.d.ts +1 -1
- package/dist/server/hyper-express/index.js +33 -33
- package/dist/server/hyper-express/index.mjs +2 -2
- package/dist/server/koa/index.d.mts +1 -1
- package/dist/server/koa/index.d.ts +1 -1
- package/dist/server/koa/index.js +34 -34
- package/dist/server/koa/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 +2 -2
- package/dist/chunk-LYEZ6RGX.js +0 -237
- package/dist/core-2SNw8m2B.d.mts +0 -30
- package/dist/core-BmJJLUqj.d.ts +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,14 +14,14 @@ 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
|
|
|
@@ -34,7 +34,7 @@ var Exception = class extends Error {
|
|
|
34
34
|
message: this.message,
|
|
35
35
|
description: this.description,
|
|
36
36
|
status: this.status,
|
|
37
|
-
[
|
|
37
|
+
[_chunkTVT62GIXjs.ERROR_SYMBOL]: true
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
};
|
|
@@ -42,7 +42,7 @@ var Exception = class extends Error {
|
|
|
42
42
|
// src/exception/undefine.ts
|
|
43
43
|
var UndefinedException = class extends Exception {
|
|
44
44
|
static {
|
|
45
|
-
|
|
45
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "UndefinedException");
|
|
46
46
|
}
|
|
47
47
|
constructor(message) {
|
|
48
48
|
super(message, 500, "Undefined error");
|
|
@@ -52,7 +52,7 @@ var UndefinedException = class extends Exception {
|
|
|
52
52
|
// src/exception/validate.ts
|
|
53
53
|
var ValidateException = class extends Exception {
|
|
54
54
|
static {
|
|
55
|
-
|
|
55
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "ValidateException");
|
|
56
56
|
}
|
|
57
57
|
constructor(message) {
|
|
58
58
|
super(message, 400, "Validate exception");
|
|
@@ -62,7 +62,7 @@ var ValidateException = class extends Exception {
|
|
|
62
62
|
// src/exception/forbidden.ts
|
|
63
63
|
var ForbiddenException = class extends Exception {
|
|
64
64
|
static {
|
|
65
|
-
|
|
65
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "ForbiddenException");
|
|
66
66
|
}
|
|
67
67
|
constructor(message) {
|
|
68
68
|
super(message, 403, "Forbidden resource");
|
|
@@ -72,7 +72,7 @@ var ForbiddenException = class extends Exception {
|
|
|
72
72
|
// src/exception/bad-request.ts
|
|
73
73
|
var BadRequestException = class extends Exception {
|
|
74
74
|
static {
|
|
75
|
-
|
|
75
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "BadRequestException");
|
|
76
76
|
}
|
|
77
77
|
constructor(message) {
|
|
78
78
|
super(message, 400, "Bad Request");
|
|
@@ -82,7 +82,7 @@ var BadRequestException = class extends Exception {
|
|
|
82
82
|
// src/exception/not-found.ts
|
|
83
83
|
var NotFoundException = class extends Exception {
|
|
84
84
|
static {
|
|
85
|
-
|
|
85
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "NotFoundException");
|
|
86
86
|
}
|
|
87
87
|
constructor(message) {
|
|
88
88
|
super(message, 404, "Not Found");
|
|
@@ -92,7 +92,7 @@ var NotFoundException = class extends Exception {
|
|
|
92
92
|
// src/exception/conflict.ts
|
|
93
93
|
var ConflictException = class extends Exception {
|
|
94
94
|
static {
|
|
95
|
-
|
|
95
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "ConflictException");
|
|
96
96
|
}
|
|
97
97
|
constructor(message) {
|
|
98
98
|
super(message, 409, "Conflict");
|
|
@@ -102,7 +102,7 @@ var ConflictException = class extends Exception {
|
|
|
102
102
|
// src/exception/bad-gateway.ts
|
|
103
103
|
var BadGatewayException = class extends Exception {
|
|
104
104
|
static {
|
|
105
|
-
|
|
105
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "BadGatewayException");
|
|
106
106
|
}
|
|
107
107
|
constructor(message) {
|
|
108
108
|
super(message, 502, "Bad Gatrway");
|
|
@@ -112,7 +112,7 @@ var BadGatewayException = class extends Exception {
|
|
|
112
112
|
// src/exception/invalid-input.ts
|
|
113
113
|
var InvalidInputException = class extends Exception {
|
|
114
114
|
static {
|
|
115
|
-
|
|
115
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "InvalidInputException");
|
|
116
116
|
}
|
|
117
117
|
constructor(message) {
|
|
118
118
|
super(message, 502, "Invalid Input");
|
|
@@ -122,7 +122,7 @@ var InvalidInputException = class extends Exception {
|
|
|
122
122
|
// src/exception/media-type.ts
|
|
123
123
|
var UnsupportedMediaTypeException = class extends Exception {
|
|
124
124
|
static {
|
|
125
|
-
|
|
125
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "UnsupportedMediaTypeException");
|
|
126
126
|
}
|
|
127
127
|
constructor(message) {
|
|
128
128
|
super(message, 415, "Unsupported Media Type");
|
|
@@ -132,7 +132,7 @@ var UnsupportedMediaTypeException = class extends Exception {
|
|
|
132
132
|
// src/exception/payload-large.ts
|
|
133
133
|
var PayloadLargeException = class extends Exception {
|
|
134
134
|
static {
|
|
135
|
-
|
|
135
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "PayloadLargeException");
|
|
136
136
|
}
|
|
137
137
|
constructor(message) {
|
|
138
138
|
super(message, 413, "Payload Too Large");
|
|
@@ -142,7 +142,7 @@ var PayloadLargeException = class extends Exception {
|
|
|
142
142
|
// src/exception/timeout.ts
|
|
143
143
|
var TimeoutException = class extends Exception {
|
|
144
144
|
static {
|
|
145
|
-
|
|
145
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "TimeoutException");
|
|
146
146
|
}
|
|
147
147
|
constructor(message) {
|
|
148
148
|
super(message, 408, "Request Timeout");
|
|
@@ -152,7 +152,7 @@ var TimeoutException = class extends Exception {
|
|
|
152
152
|
// src/exception/unauthorized.ts
|
|
153
153
|
var UnauthorizedException = class extends Exception {
|
|
154
154
|
static {
|
|
155
|
-
|
|
155
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "UnauthorizedException");
|
|
156
156
|
}
|
|
157
157
|
constructor(message) {
|
|
158
158
|
super(message, 401, "Unauthorized");
|
|
@@ -162,7 +162,7 @@ var UnauthorizedException = class extends Exception {
|
|
|
162
162
|
// src/exception/unavailable-service.ts
|
|
163
163
|
var ServiceUnavailableException = class extends Exception {
|
|
164
164
|
static {
|
|
165
|
-
|
|
165
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "ServiceUnavailableException");
|
|
166
166
|
}
|
|
167
167
|
constructor(message) {
|
|
168
168
|
super(message, 503, "Service Unavailable");
|
|
@@ -172,7 +172,7 @@ var ServiceUnavailableException = class extends Exception {
|
|
|
172
172
|
// src/exception/framework.ts
|
|
173
173
|
var FrameworkException = class extends Exception {
|
|
174
174
|
static {
|
|
175
|
-
|
|
175
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "FrameworkException");
|
|
176
176
|
}
|
|
177
177
|
constructor(message) {
|
|
178
178
|
super(`[phecda-server] ${message}`, 500, "Framework Error");
|
|
@@ -182,7 +182,7 @@ var FrameworkException = class extends Exception {
|
|
|
182
182
|
// src/exception/timer.ts
|
|
183
183
|
var TimerException = class extends Exception {
|
|
184
184
|
static {
|
|
185
|
-
|
|
185
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "TimerException");
|
|
186
186
|
}
|
|
187
187
|
constructor(message) {
|
|
188
188
|
super(message, 0, "Timer Error");
|
|
@@ -192,7 +192,7 @@ var TimerException = class extends Exception {
|
|
|
192
192
|
// src/exception/worker.ts
|
|
193
193
|
var WorkerException = class extends Exception {
|
|
194
194
|
static {
|
|
195
|
-
|
|
195
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "WorkerException");
|
|
196
196
|
}
|
|
197
197
|
constructor(message) {
|
|
198
198
|
super(message, 0, "Worker Error");
|
|
@@ -200,14 +200,14 @@ var WorkerException = class extends Exception {
|
|
|
200
200
|
};
|
|
201
201
|
|
|
202
202
|
// src/filter.ts
|
|
203
|
-
var defaultFilter = /* @__PURE__ */
|
|
203
|
+
var defaultFilter = /* @__PURE__ */ _chunkTVT62GIXjs.__name.call(void 0, (e) => {
|
|
204
204
|
if (!(e instanceof Exception)) {
|
|
205
|
-
|
|
206
|
-
if (
|
|
205
|
+
_chunkTVT62GIXjs.log.call(void 0, e.message, "error");
|
|
206
|
+
if (_chunkTVT62GIXjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
207
207
|
e = new UndefinedException(e.message || e);
|
|
208
208
|
} else {
|
|
209
|
-
|
|
210
|
-
if (
|
|
209
|
+
_chunkTVT62GIXjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
|
|
210
|
+
if (_chunkTVT62GIXjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
211
211
|
}
|
|
212
212
|
return e.data;
|
|
213
213
|
}, "defaultFilter");
|
|
@@ -216,7 +216,7 @@ var defaultFilter = /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (e) =>
|
|
|
216
216
|
var debug = _debug2.default.call(void 0, "phecda-server(Context)");
|
|
217
217
|
var Context = (_class = class _Context {
|
|
218
218
|
static {
|
|
219
|
-
|
|
219
|
+
_chunkTVT62GIXjs.__name.call(void 0, this, "Context");
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
|
|
@@ -233,7 +233,7 @@ var Context = (_class = class _Context {
|
|
|
233
233
|
|
|
234
234
|
constructor(data) {
|
|
235
235
|
this.data = data;
|
|
236
|
-
if (
|
|
236
|
+
if (_chunkTVT62GIXjs.IS_HMR)
|
|
237
237
|
data._context = this;
|
|
238
238
|
}
|
|
239
239
|
async run(opts, successCb, failCb) {
|
|
@@ -274,7 +274,7 @@ var Context = (_class = class _Context {
|
|
|
274
274
|
usePipe(args) {
|
|
275
275
|
return Promise.all(args.map((item) => {
|
|
276
276
|
if (item.pipe && !_Context.pipeRecord[item.pipe]) {
|
|
277
|
-
if (
|
|
277
|
+
if (_chunkTVT62GIXjs.IS_STRICT) {
|
|
278
278
|
throw new FrameworkException(`can't find pipe named '${item.pipe}'`);
|
|
279
279
|
} else {
|
|
280
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`);
|
|
@@ -286,7 +286,7 @@ var Context = (_class = class _Context {
|
|
|
286
286
|
}
|
|
287
287
|
useFilter(arg, filter = "default") {
|
|
288
288
|
if (!_Context.filterRecord[filter]) {
|
|
289
|
-
if (
|
|
289
|
+
if (_chunkTVT62GIXjs.IS_STRICT) {
|
|
290
290
|
throw new FrameworkException(`can't find filter named "${filter}"`);
|
|
291
291
|
} else {
|
|
292
292
|
debug(`Can't find filter named "${filter}" when handling func "${this.data.func}" on module "${this.data.tag}",use default filter instead`);
|
|
@@ -298,7 +298,7 @@ var Context = (_class = class _Context {
|
|
|
298
298
|
async useGuard(guards) {
|
|
299
299
|
for (const guard of new Set(guards)) {
|
|
300
300
|
if (!(guard in _Context.guardRecord)) {
|
|
301
|
-
if (
|
|
301
|
+
if (_chunkTVT62GIXjs.IS_STRICT) throw new FrameworkException(`Can't find guard named "${guard}"`);
|
|
302
302
|
else debug(`Can't find guard named "${guard}" when handling func "${this.data.func}" on module "${this.data.tag}",skip it`);
|
|
303
303
|
continue;
|
|
304
304
|
}
|
|
@@ -315,7 +315,7 @@ var Context = (_class = class _Context {
|
|
|
315
315
|
const cb = [];
|
|
316
316
|
for (const interceptor of new Set(interceptors)) {
|
|
317
317
|
if (!(interceptor in _Context.interceptorRecord)) {
|
|
318
|
-
if (
|
|
318
|
+
if (_chunkTVT62GIXjs.IS_STRICT) throw new FrameworkException(`can't find interceptor named "${interceptor}"`);
|
|
319
319
|
else debug(`Can't find interceptor named "${interceptor}" when handling func "${this.data.func}" on module "${this.data.tag}",skip it`);
|
|
320
320
|
continue;
|
|
321
321
|
}
|
|
@@ -331,7 +331,7 @@ var Context = (_class = class _Context {
|
|
|
331
331
|
const ret = [];
|
|
332
332
|
for (const m of new Set(plugins)) {
|
|
333
333
|
if (!(m in _Context.pluginRecord)) {
|
|
334
|
-
if (
|
|
334
|
+
if (_chunkTVT62GIXjs.IS_STRICT) throw new FrameworkException(`can't find middleware named '${m}'`);
|
|
335
335
|
continue;
|
|
336
336
|
}
|
|
337
337
|
const plugin = _Context.pluginRecord[m](framework);
|
|
@@ -341,43 +341,43 @@ var Context = (_class = class _Context {
|
|
|
341
341
|
}
|
|
342
342
|
}, _class.__initStatic(), _class.__initStatic2(), _class.__initStatic3(), _class.__initStatic4(), _class.__initStatic5(), _class);
|
|
343
343
|
function addPlugin(key, handler) {
|
|
344
|
-
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");
|
|
345
345
|
Context.pluginRecord[key] = handler;
|
|
346
346
|
}
|
|
347
|
-
|
|
347
|
+
_chunkTVT62GIXjs.__name.call(void 0, addPlugin, "addPlugin");
|
|
348
348
|
function addPipe(key, handler) {
|
|
349
|
-
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");
|
|
350
350
|
Context.pipeRecord[key] = handler;
|
|
351
351
|
}
|
|
352
|
-
|
|
352
|
+
_chunkTVT62GIXjs.__name.call(void 0, addPipe, "addPipe");
|
|
353
353
|
function addFilter(key, handler) {
|
|
354
|
-
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");
|
|
355
355
|
Context.filterRecord[key] = handler;
|
|
356
356
|
}
|
|
357
|
-
|
|
357
|
+
_chunkTVT62GIXjs.__name.call(void 0, addFilter, "addFilter");
|
|
358
358
|
function addGuard(key, handler) {
|
|
359
|
-
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");
|
|
360
360
|
Context.guardRecord[key] = handler;
|
|
361
361
|
}
|
|
362
|
-
|
|
362
|
+
_chunkTVT62GIXjs.__name.call(void 0, addGuard, "addGuard");
|
|
363
363
|
function addInterceptor(key, handler) {
|
|
364
|
-
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");
|
|
365
365
|
Context.interceptorRecord[key] = handler;
|
|
366
366
|
}
|
|
367
|
-
|
|
367
|
+
_chunkTVT62GIXjs.__name.call(void 0, addInterceptor, "addInterceptor");
|
|
368
368
|
|
|
369
369
|
// src/hmr.ts
|
|
370
370
|
function HMR(cb) {
|
|
371
|
-
if (
|
|
371
|
+
if (_chunkTVT62GIXjs.IS_HMR) _optionalChain([globalThis, 'access', _ => _.__PS_HMR__, 'optionalAccess', _2 => _2.push, 'call', _3 => _3(cb)]);
|
|
372
372
|
}
|
|
373
|
-
|
|
373
|
+
_chunkTVT62GIXjs.__name.call(void 0, HMR, "HMR");
|
|
374
374
|
|
|
375
375
|
// src/server/helper.ts
|
|
376
376
|
function resolveDep(ret, key) {
|
|
377
377
|
if (key) return _optionalChain([ret, 'optionalAccess', _4 => _4[key]]);
|
|
378
378
|
return ret;
|
|
379
379
|
}
|
|
380
|
-
|
|
380
|
+
_chunkTVT62GIXjs.__name.call(void 0, resolveDep, "resolveDep");
|
|
381
381
|
function argToReq(params, args, headers) {
|
|
382
382
|
const req = {
|
|
383
383
|
body: {},
|
|
@@ -391,14 +391,14 @@ function argToReq(params, args, headers) {
|
|
|
391
391
|
});
|
|
392
392
|
return req;
|
|
393
393
|
}
|
|
394
|
-
|
|
394
|
+
_chunkTVT62GIXjs.__name.call(void 0, argToReq, "argToReq");
|
|
395
395
|
|
|
396
396
|
// src/rpc/helper.ts
|
|
397
397
|
var _os = require('os');
|
|
398
398
|
function genClientQueue(key) {
|
|
399
399
|
return `PS-${key ? `${key}-` : ""}${_os.hostname.call(void 0, )}-${process.pid}`;
|
|
400
400
|
}
|
|
401
|
-
|
|
401
|
+
_chunkTVT62GIXjs.__name.call(void 0, genClientQueue, "genClientQueue");
|
|
402
402
|
|
|
403
403
|
// src/decorators/helper.ts
|
|
404
404
|
function shallowClone(obj) {
|
|
@@ -406,11 +406,11 @@ function shallowClone(obj) {
|
|
|
406
406
|
...obj
|
|
407
407
|
};
|
|
408
408
|
}
|
|
409
|
-
|
|
409
|
+
_chunkTVT62GIXjs.__name.call(void 0, shallowClone, "shallowClone");
|
|
410
410
|
function mergeObject(...args) {
|
|
411
411
|
return Object.assign({}, ...args);
|
|
412
412
|
}
|
|
413
|
-
|
|
413
|
+
_chunkTVT62GIXjs.__name.call(void 0, mergeObject, "mergeObject");
|
|
414
414
|
|
|
415
415
|
// src/helper.ts
|
|
416
416
|
function createControllerMetaMap(meta, filter) {
|
|
@@ -426,12 +426,12 @@ function createControllerMetaMap(meta, filter) {
|
|
|
426
426
|
});
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
|
-
|
|
429
|
+
_chunkTVT62GIXjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
430
430
|
handleMeta();
|
|
431
431
|
HMR(handleMeta);
|
|
432
432
|
return metaMap;
|
|
433
433
|
}
|
|
434
|
-
|
|
434
|
+
_chunkTVT62GIXjs.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
|
|
435
435
|
function detectAopDep(meta, { guards, interceptors, plugins } = {}, controller = "http") {
|
|
436
436
|
const pluginSet = /* @__PURE__ */ new Set();
|
|
437
437
|
const guardSet = /* @__PURE__ */ new Set();
|
|
@@ -483,14 +483,14 @@ function detectAopDep(meta, { guards, interceptors, plugins } = {}, controller =
|
|
|
483
483
|
const missFilters = [
|
|
484
484
|
...filterSet
|
|
485
485
|
].filter((i) => !Context.filterRecord[i]);
|
|
486
|
-
if (missPlugins.length)
|
|
487
|
-
if (missGuards.length)
|
|
488
|
-
if (missInterceptors.length)
|
|
489
|
-
if (missPipes.length)
|
|
490
|
-
if (missFilters.length)
|
|
491
|
-
warningSet.forEach((warn) =>
|
|
492
|
-
}
|
|
493
|
-
|
|
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");
|
|
494
494
|
handleMeta();
|
|
495
495
|
HMR(handleMeta);
|
|
496
496
|
return {
|
|
@@ -501,7 +501,7 @@ function detectAopDep(meta, { guards, interceptors, plugins } = {}, controller =
|
|
|
501
501
|
filterSet
|
|
502
502
|
};
|
|
503
503
|
}
|
|
504
|
-
|
|
504
|
+
_chunkTVT62GIXjs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
505
505
|
|
|
506
506
|
|
|
507
507
|
|
|
@@ -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
|
|