phecda-server 7.0.0-alpha.7 → 7.0.0-alpha.9
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 +10 -1
- package/dist/{chunk-M5HGFUCV.js → chunk-5RBTN33A.js} +23 -3
- package/dist/{chunk-RGSKKTHD.mjs → chunk-7ZGYJ5OW.mjs} +88 -54
- package/dist/{chunk-IRXNF6ZE.mjs → chunk-CVPZWDXU.mjs} +39 -30
- package/dist/{chunk-MENRZSGW.js → chunk-FX3LDQII.js} +88 -79
- package/dist/{chunk-C5BVKEGW.mjs → chunk-FXTJ3BJ6.mjs} +25 -5
- package/dist/{chunk-XSMUJ77A.js → chunk-KJUD2BKE.js} +103 -69
- package/dist/{chunk-JPSXNDXP.mjs → chunk-ODVWOXVB.mjs} +1 -1
- package/dist/{chunk-VYMSCWXC.js → chunk-V5EYXVJT.js} +24 -24
- package/dist/{core-DU7gQKSk.d.mts → core-BDkhrEyf.d.mts} +4 -3
- package/dist/{core-CzElxZoF.d.ts → core-D_cz0tKa.d.ts} +4 -3
- package/dist/helper.d.mts +7 -5
- package/dist/helper.d.ts +7 -5
- package/dist/helper.js +8 -3
- package/dist/helper.mjs +10 -5
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +41 -44
- package/dist/http/elysia/index.mjs +7 -10
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +38 -41
- package/dist/http/express/index.mjs +7 -10
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +39 -42
- package/dist/http/fastify/index.mjs +7 -10
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +39 -42
- package/dist/http/h3/index.mjs +7 -10
- package/dist/http/hono/index.d.mts +4 -4
- package/dist/http/hono/index.d.ts +4 -4
- package/dist/http/hono/index.js +35 -39
- package/dist/http/hono/index.mjs +3 -7
- package/dist/http/hyper-express/index.d.mts +4 -4
- package/dist/http/hyper-express/index.d.ts +4 -4
- package/dist/http/hyper-express/index.js +36 -39
- package/dist/http/hyper-express/index.mjs +6 -9
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +38 -41
- package/dist/http/koa/index.mjs +7 -10
- package/dist/index.d.mts +35 -33
- package/dist/index.d.ts +35 -33
- package/dist/index.js +42 -43
- package/dist/index.mjs +15 -16
- package/dist/{meta-BTnLXuCa.d.ts → meta-BX5jhe4Z.d.mts} +3 -4
- package/dist/{meta-BTnLXuCa.d.mts → meta-BX5jhe4Z.d.ts} +3 -4
- package/dist/rpc/bullmq/index.d.mts +4 -4
- package/dist/rpc/bullmq/index.d.ts +4 -4
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +3 -3
- package/dist/rpc/kafka/index.d.mts +4 -4
- package/dist/rpc/kafka/index.d.ts +4 -4
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +4 -4
- package/dist/rpc/nats/index.d.ts +4 -4
- package/dist/rpc/nats/index.js +13 -13
- package/dist/rpc/nats/index.mjs +3 -3
- package/dist/rpc/rabbitmq/index.d.mts +4 -4
- package/dist/rpc/rabbitmq/index.d.ts +4 -4
- package/dist/rpc/rabbitmq/index.js +15 -15
- package/dist/rpc/rabbitmq/index.mjs +3 -3
- package/dist/rpc/redis/index.d.mts +4 -4
- package/dist/rpc/redis/index.d.ts +4 -4
- package/dist/rpc/redis/index.js +13 -13
- package/dist/rpc/redis/index.mjs +3 -3
- 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-CbfaGkPA.d.ts → types-B-rUM9Fm.d.mts} +3 -3
- package/dist/{types--E-OCZhC.d.ts → types-CMeuFoyd.d.ts} +3 -3
- package/dist/{types-BxlzVoRv.d.mts → types-DKVhyZk_.d.mts} +3 -3
- package/dist/{types-BYqBeqrs.d.mts → types-MxxtkZXw.d.ts} +3 -3
- package/package.json +3 -2
- package/register/index.mjs +20 -11
- package/register/loader.mjs +13 -28
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
var _chunk5RBTN33Ajs = require('./chunk-5RBTN33A.js');
|
|
9
10
|
|
|
10
11
|
// src/helper.ts
|
|
11
12
|
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
@@ -15,14 +16,14 @@ var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
// src/pipe.ts
|
|
18
|
-
var defaultPipe = /* @__PURE__ */
|
|
19
|
+
var defaultPipe = /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, ({ arg }) => {
|
|
19
20
|
return arg;
|
|
20
21
|
}, "defaultPipe");
|
|
21
22
|
|
|
22
23
|
// src/exception/base.ts
|
|
23
24
|
var Exception = class extends Error {
|
|
24
25
|
static {
|
|
25
|
-
|
|
26
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "Exception");
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
|
|
@@ -35,7 +36,7 @@ var Exception = class extends Error {
|
|
|
35
36
|
message: this.message,
|
|
36
37
|
description: this.description,
|
|
37
38
|
status: this.status,
|
|
38
|
-
[
|
|
39
|
+
[_chunk5RBTN33Ajs.ERROR_SYMBOL]: true
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
};
|
|
@@ -43,7 +44,7 @@ var Exception = class extends Error {
|
|
|
43
44
|
// src/exception/undefine.ts
|
|
44
45
|
var UndefinedException = class extends Exception {
|
|
45
46
|
static {
|
|
46
|
-
|
|
47
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "UndefinedException");
|
|
47
48
|
}
|
|
48
49
|
constructor(message) {
|
|
49
50
|
super(message, 500, "Undefined error");
|
|
@@ -53,7 +54,7 @@ var UndefinedException = class extends Exception {
|
|
|
53
54
|
// src/exception/validate.ts
|
|
54
55
|
var ValidateException = class extends Exception {
|
|
55
56
|
static {
|
|
56
|
-
|
|
57
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "ValidateException");
|
|
57
58
|
}
|
|
58
59
|
constructor(message) {
|
|
59
60
|
super(message, 400, "Validate exception");
|
|
@@ -63,7 +64,7 @@ var ValidateException = class extends Exception {
|
|
|
63
64
|
// src/exception/forbidden.ts
|
|
64
65
|
var ForbiddenException = class extends Exception {
|
|
65
66
|
static {
|
|
66
|
-
|
|
67
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "ForbiddenException");
|
|
67
68
|
}
|
|
68
69
|
constructor(message) {
|
|
69
70
|
super(message, 403, "Forbidden resource");
|
|
@@ -73,7 +74,7 @@ var ForbiddenException = class extends Exception {
|
|
|
73
74
|
// src/exception/bad-request.ts
|
|
74
75
|
var BadRequestException = class extends Exception {
|
|
75
76
|
static {
|
|
76
|
-
|
|
77
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "BadRequestException");
|
|
77
78
|
}
|
|
78
79
|
constructor(message) {
|
|
79
80
|
super(message, 400, "Bad Request");
|
|
@@ -83,7 +84,7 @@ var BadRequestException = class extends Exception {
|
|
|
83
84
|
// src/exception/not-found.ts
|
|
84
85
|
var NotFoundException = class extends Exception {
|
|
85
86
|
static {
|
|
86
|
-
|
|
87
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "NotFoundException");
|
|
87
88
|
}
|
|
88
89
|
constructor(message) {
|
|
89
90
|
super(message, 404, "Not Found");
|
|
@@ -93,7 +94,7 @@ var NotFoundException = class extends Exception {
|
|
|
93
94
|
// src/exception/conflict.ts
|
|
94
95
|
var ConflictException = class extends Exception {
|
|
95
96
|
static {
|
|
96
|
-
|
|
97
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "ConflictException");
|
|
97
98
|
}
|
|
98
99
|
constructor(message) {
|
|
99
100
|
super(message, 409, "Conflict");
|
|
@@ -103,7 +104,7 @@ var ConflictException = class extends Exception {
|
|
|
103
104
|
// src/exception/bad-gateway.ts
|
|
104
105
|
var BadGatewayException = class extends Exception {
|
|
105
106
|
static {
|
|
106
|
-
|
|
107
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "BadGatewayException");
|
|
107
108
|
}
|
|
108
109
|
constructor(message) {
|
|
109
110
|
super(message, 502, "Bad Gatrway");
|
|
@@ -113,7 +114,7 @@ var BadGatewayException = class extends Exception {
|
|
|
113
114
|
// src/exception/invalid-input.ts
|
|
114
115
|
var InvalidInputException = class extends Exception {
|
|
115
116
|
static {
|
|
116
|
-
|
|
117
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "InvalidInputException");
|
|
117
118
|
}
|
|
118
119
|
constructor(message) {
|
|
119
120
|
super(message, 502, "Invalid Input");
|
|
@@ -123,7 +124,7 @@ var InvalidInputException = class extends Exception {
|
|
|
123
124
|
// src/exception/media-type.ts
|
|
124
125
|
var UnsupportedMediaTypeException = class extends Exception {
|
|
125
126
|
static {
|
|
126
|
-
|
|
127
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "UnsupportedMediaTypeException");
|
|
127
128
|
}
|
|
128
129
|
constructor(message) {
|
|
129
130
|
super(message, 415, "Unsupported Media Type");
|
|
@@ -133,7 +134,7 @@ var UnsupportedMediaTypeException = class extends Exception {
|
|
|
133
134
|
// src/exception/payload-large.ts
|
|
134
135
|
var PayloadLargeException = class extends Exception {
|
|
135
136
|
static {
|
|
136
|
-
|
|
137
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "PayloadLargeException");
|
|
137
138
|
}
|
|
138
139
|
constructor(message) {
|
|
139
140
|
super(message, 413, "Payload Too Large");
|
|
@@ -143,7 +144,7 @@ var PayloadLargeException = class extends Exception {
|
|
|
143
144
|
// src/exception/timeout.ts
|
|
144
145
|
var TimeoutException = class extends Exception {
|
|
145
146
|
static {
|
|
146
|
-
|
|
147
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "TimeoutException");
|
|
147
148
|
}
|
|
148
149
|
constructor(message) {
|
|
149
150
|
super(message, 408, "Request Timeout");
|
|
@@ -153,7 +154,7 @@ var TimeoutException = class extends Exception {
|
|
|
153
154
|
// src/exception/unauthorized.ts
|
|
154
155
|
var UnauthorizedException = class extends Exception {
|
|
155
156
|
static {
|
|
156
|
-
|
|
157
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "UnauthorizedException");
|
|
157
158
|
}
|
|
158
159
|
constructor(message) {
|
|
159
160
|
super(message, 401, "Unauthorized");
|
|
@@ -163,7 +164,7 @@ var UnauthorizedException = class extends Exception {
|
|
|
163
164
|
// src/exception/unavailable-service.ts
|
|
164
165
|
var ServiceUnavailableException = class extends Exception {
|
|
165
166
|
static {
|
|
166
|
-
|
|
167
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "ServiceUnavailableException");
|
|
167
168
|
}
|
|
168
169
|
constructor(message) {
|
|
169
170
|
super(message, 503, "Service Unavailable");
|
|
@@ -173,7 +174,7 @@ var ServiceUnavailableException = class extends Exception {
|
|
|
173
174
|
// src/exception/framework.ts
|
|
174
175
|
var FrameworkException = class extends Exception {
|
|
175
176
|
static {
|
|
176
|
-
|
|
177
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "FrameworkException");
|
|
177
178
|
}
|
|
178
179
|
constructor(message) {
|
|
179
180
|
super(`[phecda-server] ${message}`, 500, "Framework Error");
|
|
@@ -183,7 +184,7 @@ var FrameworkException = class extends Exception {
|
|
|
183
184
|
// src/exception/timer.ts
|
|
184
185
|
var TimerException = class extends Exception {
|
|
185
186
|
static {
|
|
186
|
-
|
|
187
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "TimerException");
|
|
187
188
|
}
|
|
188
189
|
constructor(message) {
|
|
189
190
|
super(message, 0, "Timer Error");
|
|
@@ -193,7 +194,7 @@ var TimerException = class extends Exception {
|
|
|
193
194
|
// src/exception/worker.ts
|
|
194
195
|
var WorkerException = class extends Exception {
|
|
195
196
|
static {
|
|
196
|
-
|
|
197
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "WorkerException");
|
|
197
198
|
}
|
|
198
199
|
constructor(message) {
|
|
199
200
|
super(message, 0, "Worker Error");
|
|
@@ -201,14 +202,14 @@ var WorkerException = class extends Exception {
|
|
|
201
202
|
};
|
|
202
203
|
|
|
203
204
|
// src/filter.ts
|
|
204
|
-
var defaultFilter = /* @__PURE__ */
|
|
205
|
+
var defaultFilter = /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (e) => {
|
|
205
206
|
if (!(e instanceof Exception)) {
|
|
206
|
-
|
|
207
|
-
if (
|
|
207
|
+
_chunk5RBTN33Ajs.log.call(void 0, e.message, "error");
|
|
208
|
+
if (_chunk5RBTN33Ajs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
208
209
|
e = new UndefinedException(e.message || e);
|
|
209
210
|
} else {
|
|
210
|
-
|
|
211
|
-
if (
|
|
211
|
+
_chunk5RBTN33Ajs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
|
|
212
|
+
if (_chunk5RBTN33Ajs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
212
213
|
}
|
|
213
214
|
return e.data;
|
|
214
215
|
}, "defaultFilter");
|
|
@@ -217,7 +218,7 @@ var defaultFilter = /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (e) =>
|
|
|
217
218
|
var debug = _debug2.default.call(void 0, "phecda-server(Context)");
|
|
218
219
|
var Context = (_class = class _Context {
|
|
219
220
|
static {
|
|
220
|
-
|
|
221
|
+
_chunk5RBTN33Ajs.__name.call(void 0, this, "Context");
|
|
221
222
|
}
|
|
222
223
|
|
|
223
224
|
|
|
@@ -230,10 +231,25 @@ var Context = (_class = class _Context {
|
|
|
230
231
|
}}
|
|
231
232
|
static __initStatic3() {this.guardRecord = {}}
|
|
232
233
|
static __initStatic4() {this.addonRecord = {}}
|
|
234
|
+
|
|
235
|
+
|
|
233
236
|
constructor(data) {
|
|
234
237
|
this.data = data;
|
|
235
|
-
|
|
238
|
+
this.canGetCtx = true;
|
|
239
|
+
if (_chunk5RBTN33Ajs.IS_DEV)
|
|
236
240
|
data._context = this;
|
|
241
|
+
const that = this;
|
|
242
|
+
this.ctx = new Proxy(data, {
|
|
243
|
+
get(target, p) {
|
|
244
|
+
if (_chunk5RBTN33Ajs.IS_DEV && !that.canGetCtx) throw new FrameworkException("ctx must be obtained within the same request cycle in controller");
|
|
245
|
+
if (!(p in target)) _chunk5RBTN33Ajs.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);
|
|
246
|
+
return target[p];
|
|
247
|
+
},
|
|
248
|
+
set(target, p, newValue) {
|
|
249
|
+
target[p] = newValue;
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
237
253
|
}
|
|
238
254
|
static getAop(meta, opts) {
|
|
239
255
|
const { globalGuards = [], globalFilter = "default", globalPipe = "default" } = opts;
|
|
@@ -264,19 +280,25 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
264
280
|
const { paramsType, data: { ctxs, tag, params, func } } = meta;
|
|
265
281
|
try {
|
|
266
282
|
let res;
|
|
267
|
-
const nextHandler = /* @__PURE__ */
|
|
283
|
+
const nextHandler = /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (index) => {
|
|
268
284
|
return async () => {
|
|
269
285
|
if (index === guards.length) {
|
|
270
286
|
const instance = moduleMap.get(tag);
|
|
271
287
|
if (ctxs) {
|
|
272
|
-
ctxs.forEach((ctx) => instance[ctx] = this.
|
|
288
|
+
ctxs.forEach((ctx) => instance[ctx] = this.ctx);
|
|
273
289
|
}
|
|
274
290
|
const args = await Promise.all(params.map((item, i) => pipe[i]({
|
|
275
291
|
arg: resolveDep(this.data[item.type], item.key),
|
|
276
292
|
reflect: paramsType[item.index],
|
|
277
293
|
...item
|
|
278
|
-
}, this.
|
|
294
|
+
}, this.ctx)));
|
|
295
|
+
if (_chunk5RBTN33Ajs.IS_DEV) {
|
|
296
|
+
Promise.resolve().then(() => {
|
|
297
|
+
this.canGetCtx = false;
|
|
298
|
+
});
|
|
299
|
+
}
|
|
279
300
|
res = await instance[func](...args);
|
|
301
|
+
this.canGetCtx = true;
|
|
280
302
|
} else {
|
|
281
303
|
let nextPromise;
|
|
282
304
|
async function next() {
|
|
@@ -288,8 +310,8 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
288
310
|
return res;
|
|
289
311
|
});
|
|
290
312
|
}
|
|
291
|
-
|
|
292
|
-
const ret = await guards[index](this.
|
|
313
|
+
_chunk5RBTN33Ajs.__name.call(void 0, next, "next");
|
|
314
|
+
const ret = await guards[index](this.ctx, next);
|
|
293
315
|
if (ret !== void 0) {
|
|
294
316
|
res = ret;
|
|
295
317
|
} else {
|
|
@@ -302,7 +324,7 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
302
324
|
await nextHandler(0)();
|
|
303
325
|
return successCb(res);
|
|
304
326
|
} catch (e) {
|
|
305
|
-
const err = await filter(e, this.
|
|
327
|
+
const err = await filter(e, this.ctx);
|
|
306
328
|
return failCb(err);
|
|
307
329
|
}
|
|
308
330
|
}
|
|
@@ -333,12 +355,12 @@ function addPipe(key, pipe) {
|
|
|
333
355
|
if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) debug(`overwrite Pipe "${String(key)}"`, "warn");
|
|
334
356
|
Context.pipeRecord[key] = pipe;
|
|
335
357
|
}
|
|
336
|
-
|
|
358
|
+
_chunk5RBTN33Ajs.__name.call(void 0, addPipe, "addPipe");
|
|
337
359
|
function addFilter(key, filter) {
|
|
338
360
|
if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) debug(`overwrite Filter "${String(key)}"`, "warn");
|
|
339
361
|
Context.filterRecord[key] = filter;
|
|
340
362
|
}
|
|
341
|
-
|
|
363
|
+
_chunk5RBTN33Ajs.__name.call(void 0, addFilter, "addFilter");
|
|
342
364
|
function addGuard(key, guard, priority = 0) {
|
|
343
365
|
if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) debug(`overwrite Guard "${String(key)}"`, "warn");
|
|
344
366
|
Context.guardRecord[key] = {
|
|
@@ -346,7 +368,7 @@ function addGuard(key, guard, priority = 0) {
|
|
|
346
368
|
priority
|
|
347
369
|
};
|
|
348
370
|
}
|
|
349
|
-
|
|
371
|
+
_chunk5RBTN33Ajs.__name.call(void 0, addGuard, "addGuard");
|
|
350
372
|
function addAddon(key, addon, priority = 0) {
|
|
351
373
|
if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) debug(`overwrite Addon "${String(key)}"`, "warn");
|
|
352
374
|
Context.addonRecord[key] = {
|
|
@@ -354,41 +376,21 @@ function addAddon(key, addon, priority = 0) {
|
|
|
354
376
|
priority
|
|
355
377
|
};
|
|
356
378
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
// src/hmr.ts
|
|
360
|
-
function HMR(cb) {
|
|
361
|
-
if (_chunkM5HGFUCVjs.IS_HMR) _optionalChain([globalThis, 'access', _ => _.__PS_HMR__, 'optionalAccess', _2 => _2.push, 'call', _3 => _3(cb)]);
|
|
362
|
-
}
|
|
363
|
-
_chunkM5HGFUCVjs.__name.call(void 0, HMR, "HMR");
|
|
379
|
+
_chunk5RBTN33Ajs.__name.call(void 0, addAddon, "addAddon");
|
|
364
380
|
|
|
365
381
|
// src/http/helper.ts
|
|
366
382
|
function resolveDep(ret, key) {
|
|
367
|
-
if (key) return _optionalChain([ret, 'optionalAccess',
|
|
383
|
+
if (key) return _optionalChain([ret, 'optionalAccess', _ => _[key]]);
|
|
368
384
|
return ret;
|
|
369
385
|
}
|
|
370
|
-
|
|
371
|
-
function argToReq(params, args, headers) {
|
|
372
|
-
const req = {
|
|
373
|
-
body: {},
|
|
374
|
-
query: {},
|
|
375
|
-
params: {},
|
|
376
|
-
headers
|
|
377
|
-
};
|
|
378
|
-
params.forEach((param) => {
|
|
379
|
-
if (param.key) req[param.type][param.key] = args[param.index];
|
|
380
|
-
else req[param.type] = args[param.index];
|
|
381
|
-
});
|
|
382
|
-
return req;
|
|
383
|
-
}
|
|
384
|
-
_chunkM5HGFUCVjs.__name.call(void 0, argToReq, "argToReq");
|
|
386
|
+
_chunk5RBTN33Ajs.__name.call(void 0, resolveDep, "resolveDep");
|
|
385
387
|
|
|
386
388
|
// src/rpc/helper.ts
|
|
387
389
|
var _os = require('os');
|
|
388
390
|
function genClientQueue(key) {
|
|
389
391
|
return `PS-${key ? `${key}-` : ""}${_os.hostname.call(void 0, )}-${process.pid}`;
|
|
390
392
|
}
|
|
391
|
-
|
|
393
|
+
_chunk5RBTN33Ajs.__name.call(void 0, genClientQueue, "genClientQueue");
|
|
392
394
|
|
|
393
395
|
// src/decorators/helper.ts
|
|
394
396
|
function shallowClone(obj) {
|
|
@@ -396,11 +398,11 @@ function shallowClone(obj) {
|
|
|
396
398
|
...obj
|
|
397
399
|
};
|
|
398
400
|
}
|
|
399
|
-
|
|
401
|
+
_chunk5RBTN33Ajs.__name.call(void 0, shallowClone, "shallowClone");
|
|
400
402
|
function mergeObject(...args) {
|
|
401
403
|
return Object.assign({}, ...args);
|
|
402
404
|
}
|
|
403
|
-
|
|
405
|
+
_chunk5RBTN33Ajs.__name.call(void 0, mergeObject, "mergeObject");
|
|
404
406
|
|
|
405
407
|
// src/helper.ts
|
|
406
408
|
function createControllerMetaMap(meta, filter) {
|
|
@@ -416,12 +418,12 @@ function createControllerMetaMap(meta, filter) {
|
|
|
416
418
|
});
|
|
417
419
|
}
|
|
418
420
|
}
|
|
419
|
-
|
|
421
|
+
_chunk5RBTN33Ajs.__name.call(void 0, handleMeta, "handleMeta");
|
|
420
422
|
handleMeta();
|
|
421
|
-
HMR(handleMeta);
|
|
423
|
+
_chunk5RBTN33Ajs.HMR.call(void 0, handleMeta);
|
|
422
424
|
return metaMap;
|
|
423
425
|
}
|
|
424
|
-
|
|
426
|
+
_chunk5RBTN33Ajs.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
|
|
425
427
|
function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
426
428
|
const addonSet = /* @__PURE__ */ new Set();
|
|
427
429
|
const guardSet = /* @__PURE__ */ new Set();
|
|
@@ -434,10 +436,10 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
|
434
436
|
pipeSet.clear();
|
|
435
437
|
filterSet.clear();
|
|
436
438
|
warningSet.clear();
|
|
437
|
-
_optionalChain([addons, 'optionalAccess',
|
|
439
|
+
_optionalChain([addons, 'optionalAccess', _2 => _2.forEach, 'call', _3 => _3((item) => {
|
|
438
440
|
addonSet.add(item);
|
|
439
441
|
})]);
|
|
440
|
-
_optionalChain([guards, 'optionalAccess',
|
|
442
|
+
_optionalChain([guards, 'optionalAccess', _4 => _4.forEach, 'call', _5 => _5((item) => {
|
|
441
443
|
guardSet.add(item);
|
|
442
444
|
})]);
|
|
443
445
|
meta.forEach(({ data }) => {
|
|
@@ -465,31 +467,31 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
|
465
467
|
...filterSet
|
|
466
468
|
].filter((i) => !Context.filterRecord[i]);
|
|
467
469
|
function exit() {
|
|
468
|
-
if (
|
|
470
|
+
if (_chunk5RBTN33Ajs.IS_STRICT) process.exit(5);
|
|
469
471
|
}
|
|
470
|
-
|
|
472
|
+
_chunk5RBTN33Ajs.__name.call(void 0, exit, "exit");
|
|
471
473
|
if (missAddons.length) {
|
|
472
|
-
|
|
474
|
+
_chunk5RBTN33Ajs.log.call(void 0, `${_picocolors2.default.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
|
|
473
475
|
exit();
|
|
474
476
|
}
|
|
475
477
|
if (missGuards.length) {
|
|
476
|
-
|
|
478
|
+
_chunk5RBTN33Ajs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
|
|
477
479
|
exit();
|
|
478
480
|
}
|
|
479
481
|
if (missPipes.length) {
|
|
480
|
-
|
|
482
|
+
_chunk5RBTN33Ajs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
|
|
481
483
|
exit();
|
|
482
484
|
}
|
|
483
485
|
if (missFilters.length) {
|
|
484
|
-
|
|
486
|
+
_chunk5RBTN33Ajs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
|
|
485
487
|
exit();
|
|
486
488
|
}
|
|
487
|
-
warningSet.forEach((warn) =>
|
|
489
|
+
warningSet.forEach((warn) => _chunk5RBTN33Ajs.log.call(void 0, warn, "warn"));
|
|
488
490
|
if (warningSet.size) exit();
|
|
489
491
|
}
|
|
490
|
-
|
|
492
|
+
_chunk5RBTN33Ajs.__name.call(void 0, handleMeta, "handleMeta");
|
|
491
493
|
handleMeta();
|
|
492
|
-
HMR(handleMeta);
|
|
494
|
+
_chunk5RBTN33Ajs.HMR.call(void 0, handleMeta);
|
|
493
495
|
return {
|
|
494
496
|
addonSet,
|
|
495
497
|
guardSet,
|
|
@@ -497,8 +499,15 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
|
497
499
|
filterSet
|
|
498
500
|
};
|
|
499
501
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
+
_chunk5RBTN33Ajs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
503
|
+
function joinUrl(base, ...paths) {
|
|
504
|
+
const joinedPath = [
|
|
505
|
+
base,
|
|
506
|
+
...paths
|
|
507
|
+
].filter((p) => p).map((path) => path.replace(/(^\/)/g, "")).join("/");
|
|
508
|
+
return `/${joinedPath}`;
|
|
509
|
+
}
|
|
510
|
+
_chunk5RBTN33Ajs.__name.call(void 0, joinUrl, "joinUrl");
|
|
502
511
|
|
|
503
512
|
|
|
504
513
|
|
|
@@ -531,4 +540,4 @@ _chunkM5HGFUCVjs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
|
531
540
|
|
|
532
541
|
|
|
533
542
|
|
|
534
|
-
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.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addAddon = addAddon; exports.
|
|
543
|
+
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.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addAddon = addAddon; exports.resolveDep = resolveDep; exports.genClientQueue = genClientQueue; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep; exports.joinUrl = joinUrl;
|
|
@@ -3,11 +3,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/common.ts
|
|
5
5
|
var ERROR_SYMBOL = "__PS_ERROR__";
|
|
6
|
-
var
|
|
6
|
+
var IS_DEV = process.env.NODE_ENV === "development";
|
|
7
7
|
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
8
|
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
9
|
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
10
|
-
var IS_READY = Symbol("IS_READY");
|
|
11
10
|
var PS_EXIT_CODE = /* @__PURE__ */ function(PS_EXIT_CODE2) {
|
|
12
11
|
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 2] = "RELAUNCH";
|
|
13
12
|
PS_EXIT_CODE2[PS_EXIT_CODE2["CODE"] = 4] = "CODE";
|
|
@@ -110,18 +109,39 @@ function runMiddleware(ctx, middleware) {
|
|
|
110
109
|
}
|
|
111
110
|
__name(runMiddleware, "runMiddleware");
|
|
112
111
|
|
|
112
|
+
// src/hmr.ts
|
|
113
|
+
function HMR(cb) {
|
|
114
|
+
if (IS_DEV) {
|
|
115
|
+
if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
|
|
116
|
+
globalThis.__PS_HMR__.push(cb);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
__name(HMR, "HMR");
|
|
120
|
+
async function RELOAD(oldModels, newModels) {
|
|
121
|
+
log("reload module...");
|
|
122
|
+
for (const cb of globalThis.__PS_HMR__) await cb(oldModels, newModels);
|
|
123
|
+
log("reload done");
|
|
124
|
+
}
|
|
125
|
+
__name(RELOAD, "RELOAD");
|
|
126
|
+
function RELAUNCH() {
|
|
127
|
+
if (IS_DEV) process.exit(2);
|
|
128
|
+
}
|
|
129
|
+
__name(RELAUNCH, "RELAUNCH");
|
|
130
|
+
|
|
113
131
|
export {
|
|
114
132
|
__name,
|
|
115
133
|
ERROR_SYMBOL,
|
|
116
|
-
|
|
134
|
+
IS_DEV,
|
|
117
135
|
IS_ONLY_GENERATE,
|
|
118
136
|
IS_STRICT,
|
|
119
137
|
LOG_LEVEL,
|
|
120
|
-
IS_READY,
|
|
121
138
|
PS_EXIT_CODE,
|
|
122
139
|
setLogger,
|
|
123
140
|
getLogger,
|
|
124
141
|
log,
|
|
125
142
|
runMiddleware,
|
|
126
|
-
Mixin
|
|
143
|
+
Mixin,
|
|
144
|
+
HMR,
|
|
145
|
+
RELOAD,
|
|
146
|
+
RELAUNCH
|
|
127
147
|
};
|