phecda-server 7.0.0-alpha.7 → 7.0.0-alpha.8
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-MENRZSGW.js → chunk-7EMAZGYO.js} +86 -56
- package/dist/{chunk-JPSXNDXP.mjs → chunk-7NWDKK7D.mjs} +1 -1
- package/dist/{chunk-RGSKKTHD.mjs → chunk-B45BN7LY.mjs} +4 -4
- package/dist/{chunk-VYMSCWXC.js → chunk-BBNJVYVX.js} +24 -24
- package/dist/{chunk-XSMUJ77A.js → chunk-QJIAXSLZ.js} +19 -19
- package/dist/{chunk-IRXNF6ZE.mjs → chunk-SGMQZRP6.mjs} +39 -9
- package/dist/{chunk-M5HGFUCV.js → chunk-VSGYTGHY.js} +2 -2
- package/dist/{chunk-C5BVKEGW.mjs → chunk-YKP4ODZA.mjs} +2 -2
- package/dist/{core-CzElxZoF.d.ts → core-BGEsBtTG.d.ts} +1 -1
- package/dist/{core-DU7gQKSk.d.mts → core-BcKywWLd.d.mts} +1 -1
- package/dist/helper.d.mts +3 -2
- package/dist/helper.d.ts +3 -2
- package/dist/helper.js +5 -3
- package/dist/helper.mjs +4 -2
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +42 -41
- package/dist/http/elysia/index.mjs +6 -5
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +39 -38
- package/dist/http/express/index.mjs +5 -4
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +40 -39
- package/dist/http/fastify/index.mjs +6 -5
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +40 -39
- package/dist/http/h3/index.mjs +6 -5
- 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 -35
- package/dist/http/hono/index.mjs +2 -2
- 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 +37 -36
- package/dist/http/hyper-express/index.mjs +5 -4
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +39 -38
- package/dist/http/koa/index.mjs +5 -4
- package/dist/index.d.mts +35 -33
- package/dist/index.d.ts +35 -33
- package/dist/index.js +43 -42
- package/dist/index.mjs +15 -14
- package/dist/{meta-BTnLXuCa.d.ts → meta-B_HW7cWh.d.mts} +3 -3
- package/dist/{meta-BTnLXuCa.d.mts → meta-B_HW7cWh.d.ts} +3 -3
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/test.d.mts +2 -2
- package/dist/test.d.ts +2 -2
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types--E-OCZhC.d.ts → types-C2SQ9U9V.d.mts} +3 -3
- package/dist/{types-CbfaGkPA.d.ts → types-CYF0vha6.d.ts} +3 -3
- package/dist/{types-BYqBeqrs.d.mts → types-DEQb_e59.d.mts} +3 -3
- package/dist/{types-BxlzVoRv.d.mts → types-PFPIQWVF.d.ts} +3 -3
- package/package.json +3 -2
- package/register/loader.mjs +2 -2
package/bin/cli.mjs
CHANGED
|
@@ -30,7 +30,7 @@ if (nodeVersion < 18.19) {
|
|
|
30
30
|
|
|
31
31
|
function startChild(file, args) {
|
|
32
32
|
child = fork(file, {
|
|
33
|
-
env: {
|
|
33
|
+
env: { ...process.env },
|
|
34
34
|
stdio: 'inherit',
|
|
35
35
|
execArgv: [
|
|
36
36
|
nodeVersion < 18.19
|
|
@@ -114,9 +114,18 @@ cli
|
|
|
114
114
|
.alias('run')
|
|
115
115
|
.allowUnknownOptions()
|
|
116
116
|
.alias('run')
|
|
117
|
+
.option('-p,--prod [prod]', 'prod mode', {
|
|
118
|
+
default: false,
|
|
119
|
+
})
|
|
117
120
|
.action((file, root, options) => {
|
|
118
121
|
if (root)
|
|
119
122
|
process.chdir(root)
|
|
123
|
+
|
|
124
|
+
if (options.prod)
|
|
125
|
+
process.env.NODE_ENV = 'production'
|
|
126
|
+
else
|
|
127
|
+
process.env.NODE_ENV = 'development'
|
|
128
|
+
|
|
120
129
|
process.env.PS_CONFIG_FILE = options.config
|
|
121
130
|
|
|
122
131
|
log('process start!')
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkVSGYTGHYjs = require('./chunk-VSGYTGHY.js');
|
|
9
9
|
|
|
10
10
|
// src/helper.ts
|
|
11
11
|
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
@@ -15,14 +15,14 @@ var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
// src/pipe.ts
|
|
18
|
-
var defaultPipe = /* @__PURE__ */
|
|
18
|
+
var defaultPipe = /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, ({ arg }) => {
|
|
19
19
|
return arg;
|
|
20
20
|
}, "defaultPipe");
|
|
21
21
|
|
|
22
22
|
// src/exception/base.ts
|
|
23
23
|
var Exception = class extends Error {
|
|
24
24
|
static {
|
|
25
|
-
|
|
25
|
+
_chunkVSGYTGHYjs.__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
|
+
[_chunkVSGYTGHYjs.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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "WorkerException");
|
|
197
197
|
}
|
|
198
198
|
constructor(message) {
|
|
199
199
|
super(message, 0, "Worker Error");
|
|
@@ -201,14 +201,14 @@ var WorkerException = class extends Exception {
|
|
|
201
201
|
};
|
|
202
202
|
|
|
203
203
|
// src/filter.ts
|
|
204
|
-
var defaultFilter = /* @__PURE__ */
|
|
204
|
+
var defaultFilter = /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (e) => {
|
|
205
205
|
if (!(e instanceof Exception)) {
|
|
206
|
-
|
|
207
|
-
if (
|
|
206
|
+
_chunkVSGYTGHYjs.log.call(void 0, e.message, "error");
|
|
207
|
+
if (_chunkVSGYTGHYjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
208
208
|
e = new UndefinedException(e.message || e);
|
|
209
209
|
} else {
|
|
210
|
-
|
|
211
|
-
if (
|
|
210
|
+
_chunkVSGYTGHYjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
|
|
211
|
+
if (_chunkVSGYTGHYjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
212
212
|
}
|
|
213
213
|
return e.data;
|
|
214
214
|
}, "defaultFilter");
|
|
@@ -217,7 +217,7 @@ var defaultFilter = /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (e) =>
|
|
|
217
217
|
var debug = _debug2.default.call(void 0, "phecda-server(Context)");
|
|
218
218
|
var Context = (_class = class _Context {
|
|
219
219
|
static {
|
|
220
|
-
|
|
220
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "Context");
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
|
|
@@ -230,10 +230,25 @@ var Context = (_class = class _Context {
|
|
|
230
230
|
}}
|
|
231
231
|
static __initStatic3() {this.guardRecord = {}}
|
|
232
232
|
static __initStatic4() {this.addonRecord = {}}
|
|
233
|
+
|
|
234
|
+
|
|
233
235
|
constructor(data) {
|
|
234
236
|
this.data = data;
|
|
235
|
-
|
|
237
|
+
this.canGetCtx = true;
|
|
238
|
+
if (_chunkVSGYTGHYjs.IS_DEV)
|
|
236
239
|
data._context = this;
|
|
240
|
+
const that = this;
|
|
241
|
+
this.ctx = new Proxy(data, {
|
|
242
|
+
get(target, p) {
|
|
243
|
+
if (_chunkVSGYTGHYjs.IS_DEV && !that.canGetCtx) throw new FrameworkException("ctx must be obtained within the same request cycle in controller");
|
|
244
|
+
if (!(p in target)) _chunkVSGYTGHYjs.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);
|
|
245
|
+
return target[p];
|
|
246
|
+
},
|
|
247
|
+
set(target, p, newValue) {
|
|
248
|
+
target[p] = newValue;
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
237
252
|
}
|
|
238
253
|
static getAop(meta, opts) {
|
|
239
254
|
const { globalGuards = [], globalFilter = "default", globalPipe = "default" } = opts;
|
|
@@ -264,19 +279,25 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
264
279
|
const { paramsType, data: { ctxs, tag, params, func } } = meta;
|
|
265
280
|
try {
|
|
266
281
|
let res;
|
|
267
|
-
const nextHandler = /* @__PURE__ */
|
|
282
|
+
const nextHandler = /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (index) => {
|
|
268
283
|
return async () => {
|
|
269
284
|
if (index === guards.length) {
|
|
270
285
|
const instance = moduleMap.get(tag);
|
|
271
286
|
if (ctxs) {
|
|
272
|
-
ctxs.forEach((ctx) => instance[ctx] = this.
|
|
287
|
+
ctxs.forEach((ctx) => instance[ctx] = this.ctx);
|
|
273
288
|
}
|
|
274
289
|
const args = await Promise.all(params.map((item, i) => pipe[i]({
|
|
275
290
|
arg: resolveDep(this.data[item.type], item.key),
|
|
276
291
|
reflect: paramsType[item.index],
|
|
277
292
|
...item
|
|
278
|
-
}, this.
|
|
293
|
+
}, this.ctx)));
|
|
294
|
+
if (_chunkVSGYTGHYjs.IS_DEV) {
|
|
295
|
+
Promise.resolve().then(() => {
|
|
296
|
+
this.canGetCtx = false;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
279
299
|
res = await instance[func](...args);
|
|
300
|
+
this.canGetCtx = true;
|
|
280
301
|
} else {
|
|
281
302
|
let nextPromise;
|
|
282
303
|
async function next() {
|
|
@@ -288,8 +309,8 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
288
309
|
return res;
|
|
289
310
|
});
|
|
290
311
|
}
|
|
291
|
-
|
|
292
|
-
const ret = await guards[index](this.
|
|
312
|
+
_chunkVSGYTGHYjs.__name.call(void 0, next, "next");
|
|
313
|
+
const ret = await guards[index](this.ctx, next);
|
|
293
314
|
if (ret !== void 0) {
|
|
294
315
|
res = ret;
|
|
295
316
|
} else {
|
|
@@ -302,7 +323,7 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
302
323
|
await nextHandler(0)();
|
|
303
324
|
return successCb(res);
|
|
304
325
|
} catch (e) {
|
|
305
|
-
const err = await filter(e, this.
|
|
326
|
+
const err = await filter(e, this.ctx);
|
|
306
327
|
return failCb(err);
|
|
307
328
|
}
|
|
308
329
|
}
|
|
@@ -333,12 +354,12 @@ function addPipe(key, pipe) {
|
|
|
333
354
|
if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) debug(`overwrite Pipe "${String(key)}"`, "warn");
|
|
334
355
|
Context.pipeRecord[key] = pipe;
|
|
335
356
|
}
|
|
336
|
-
|
|
357
|
+
_chunkVSGYTGHYjs.__name.call(void 0, addPipe, "addPipe");
|
|
337
358
|
function addFilter(key, filter) {
|
|
338
359
|
if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) debug(`overwrite Filter "${String(key)}"`, "warn");
|
|
339
360
|
Context.filterRecord[key] = filter;
|
|
340
361
|
}
|
|
341
|
-
|
|
362
|
+
_chunkVSGYTGHYjs.__name.call(void 0, addFilter, "addFilter");
|
|
342
363
|
function addGuard(key, guard, priority = 0) {
|
|
343
364
|
if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) debug(`overwrite Guard "${String(key)}"`, "warn");
|
|
344
365
|
Context.guardRecord[key] = {
|
|
@@ -346,7 +367,7 @@ function addGuard(key, guard, priority = 0) {
|
|
|
346
367
|
priority
|
|
347
368
|
};
|
|
348
369
|
}
|
|
349
|
-
|
|
370
|
+
_chunkVSGYTGHYjs.__name.call(void 0, addGuard, "addGuard");
|
|
350
371
|
function addAddon(key, addon, priority = 0) {
|
|
351
372
|
if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) debug(`overwrite Addon "${String(key)}"`, "warn");
|
|
352
373
|
Context.addonRecord[key] = {
|
|
@@ -354,20 +375,20 @@ function addAddon(key, addon, priority = 0) {
|
|
|
354
375
|
priority
|
|
355
376
|
};
|
|
356
377
|
}
|
|
357
|
-
|
|
378
|
+
_chunkVSGYTGHYjs.__name.call(void 0, addAddon, "addAddon");
|
|
358
379
|
|
|
359
380
|
// src/hmr.ts
|
|
360
381
|
function HMR(cb) {
|
|
361
|
-
if (
|
|
382
|
+
if (_chunkVSGYTGHYjs.IS_DEV) _optionalChain([globalThis, 'access', _ => _.__PS_HMR__, 'optionalAccess', _2 => _2.push, 'call', _3 => _3(cb)]);
|
|
362
383
|
}
|
|
363
|
-
|
|
384
|
+
_chunkVSGYTGHYjs.__name.call(void 0, HMR, "HMR");
|
|
364
385
|
|
|
365
386
|
// src/http/helper.ts
|
|
366
387
|
function resolveDep(ret, key) {
|
|
367
388
|
if (key) return _optionalChain([ret, 'optionalAccess', _4 => _4[key]]);
|
|
368
389
|
return ret;
|
|
369
390
|
}
|
|
370
|
-
|
|
391
|
+
_chunkVSGYTGHYjs.__name.call(void 0, resolveDep, "resolveDep");
|
|
371
392
|
function argToReq(params, args, headers) {
|
|
372
393
|
const req = {
|
|
373
394
|
body: {},
|
|
@@ -381,14 +402,14 @@ function argToReq(params, args, headers) {
|
|
|
381
402
|
});
|
|
382
403
|
return req;
|
|
383
404
|
}
|
|
384
|
-
|
|
405
|
+
_chunkVSGYTGHYjs.__name.call(void 0, argToReq, "argToReq");
|
|
385
406
|
|
|
386
407
|
// src/rpc/helper.ts
|
|
387
408
|
var _os = require('os');
|
|
388
409
|
function genClientQueue(key) {
|
|
389
410
|
return `PS-${key ? `${key}-` : ""}${_os.hostname.call(void 0, )}-${process.pid}`;
|
|
390
411
|
}
|
|
391
|
-
|
|
412
|
+
_chunkVSGYTGHYjs.__name.call(void 0, genClientQueue, "genClientQueue");
|
|
392
413
|
|
|
393
414
|
// src/decorators/helper.ts
|
|
394
415
|
function shallowClone(obj) {
|
|
@@ -396,11 +417,11 @@ function shallowClone(obj) {
|
|
|
396
417
|
...obj
|
|
397
418
|
};
|
|
398
419
|
}
|
|
399
|
-
|
|
420
|
+
_chunkVSGYTGHYjs.__name.call(void 0, shallowClone, "shallowClone");
|
|
400
421
|
function mergeObject(...args) {
|
|
401
422
|
return Object.assign({}, ...args);
|
|
402
423
|
}
|
|
403
|
-
|
|
424
|
+
_chunkVSGYTGHYjs.__name.call(void 0, mergeObject, "mergeObject");
|
|
404
425
|
|
|
405
426
|
// src/helper.ts
|
|
406
427
|
function createControllerMetaMap(meta, filter) {
|
|
@@ -416,12 +437,12 @@ function createControllerMetaMap(meta, filter) {
|
|
|
416
437
|
});
|
|
417
438
|
}
|
|
418
439
|
}
|
|
419
|
-
|
|
440
|
+
_chunkVSGYTGHYjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
420
441
|
handleMeta();
|
|
421
442
|
HMR(handleMeta);
|
|
422
443
|
return metaMap;
|
|
423
444
|
}
|
|
424
|
-
|
|
445
|
+
_chunkVSGYTGHYjs.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
|
|
425
446
|
function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
426
447
|
const addonSet = /* @__PURE__ */ new Set();
|
|
427
448
|
const guardSet = /* @__PURE__ */ new Set();
|
|
@@ -465,29 +486,29 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
|
465
486
|
...filterSet
|
|
466
487
|
].filter((i) => !Context.filterRecord[i]);
|
|
467
488
|
function exit() {
|
|
468
|
-
if (
|
|
489
|
+
if (_chunkVSGYTGHYjs.IS_STRICT) process.exit(5);
|
|
469
490
|
}
|
|
470
|
-
|
|
491
|
+
_chunkVSGYTGHYjs.__name.call(void 0, exit, "exit");
|
|
471
492
|
if (missAddons.length) {
|
|
472
|
-
|
|
493
|
+
_chunkVSGYTGHYjs.log.call(void 0, `${_picocolors2.default.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
|
|
473
494
|
exit();
|
|
474
495
|
}
|
|
475
496
|
if (missGuards.length) {
|
|
476
|
-
|
|
497
|
+
_chunkVSGYTGHYjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
|
|
477
498
|
exit();
|
|
478
499
|
}
|
|
479
500
|
if (missPipes.length) {
|
|
480
|
-
|
|
501
|
+
_chunkVSGYTGHYjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
|
|
481
502
|
exit();
|
|
482
503
|
}
|
|
483
504
|
if (missFilters.length) {
|
|
484
|
-
|
|
505
|
+
_chunkVSGYTGHYjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
|
|
485
506
|
exit();
|
|
486
507
|
}
|
|
487
|
-
warningSet.forEach((warn) =>
|
|
508
|
+
warningSet.forEach((warn) => _chunkVSGYTGHYjs.log.call(void 0, warn, "warn"));
|
|
488
509
|
if (warningSet.size) exit();
|
|
489
510
|
}
|
|
490
|
-
|
|
511
|
+
_chunkVSGYTGHYjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
491
512
|
handleMeta();
|
|
492
513
|
HMR(handleMeta);
|
|
493
514
|
return {
|
|
@@ -497,7 +518,16 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
|
497
518
|
filterSet
|
|
498
519
|
};
|
|
499
520
|
}
|
|
500
|
-
|
|
521
|
+
_chunkVSGYTGHYjs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
522
|
+
function joinUrl(base, ...paths) {
|
|
523
|
+
const joinedPath = [
|
|
524
|
+
base,
|
|
525
|
+
...paths
|
|
526
|
+
].filter((p) => p).map((path) => path.replace(/(^\/)/g, "")).join("/");
|
|
527
|
+
return `/${joinedPath}`;
|
|
528
|
+
}
|
|
529
|
+
_chunkVSGYTGHYjs.__name.call(void 0, joinUrl, "joinUrl");
|
|
530
|
+
|
|
501
531
|
|
|
502
532
|
|
|
503
533
|
|
|
@@ -531,4 +561,4 @@ _chunkM5HGFUCVjs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
|
531
561
|
|
|
532
562
|
|
|
533
563
|
|
|
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.HMR = HMR; exports.resolveDep = resolveDep; exports.argToReq = argToReq; exports.genClientQueue = genClientQueue; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep;
|
|
564
|
+
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.HMR = HMR; exports.resolveDep = resolveDep; exports.argToReq = argToReq; exports.genClientQueue = genClientQueue; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep; exports.joinUrl = joinUrl;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
IS_DEV,
|
|
3
3
|
IS_ONLY_GENERATE,
|
|
4
4
|
__name,
|
|
5
5
|
log
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YKP4ODZA.mjs";
|
|
7
7
|
|
|
8
8
|
// src/meta.ts
|
|
9
9
|
var Meta = class {
|
|
@@ -62,7 +62,7 @@ var ServerPhecda = class {
|
|
|
62
62
|
async start(models) {
|
|
63
63
|
for (const model of models) await this.buildDepModule(model);
|
|
64
64
|
const generateCode = /* @__PURE__ */ __name(async () => {
|
|
65
|
-
if (
|
|
65
|
+
if (IS_DEV) {
|
|
66
66
|
return Promise.all(this.generators.map((generator) => {
|
|
67
67
|
debug(`generate "${generator.name}" code to ${generator.path}`);
|
|
68
68
|
return generator.output(this.meta);
|
|
@@ -72,7 +72,7 @@ var ServerPhecda = class {
|
|
|
72
72
|
generateCode().then(() => {
|
|
73
73
|
if (IS_ONLY_GENERATE) process.exit(4);
|
|
74
74
|
});
|
|
75
|
-
if (
|
|
75
|
+
if (IS_DEV) {
|
|
76
76
|
if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
|
|
77
77
|
globalThis.__PS_HMR__?.push(async (files) => {
|
|
78
78
|
debug("reload files ");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkVSGYTGHYjs = require('./chunk-VSGYTGHY.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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__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
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Guard, "Guard");
|
|
60
60
|
function Addon(...addons) {
|
|
61
61
|
return (target, property) => {
|
|
62
62
|
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
@@ -64,7 +64,7 @@ function Addon(...addons) {
|
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Addon, "Addon");
|
|
68
68
|
function Filter(filter) {
|
|
69
69
|
return (target, property) => {
|
|
70
70
|
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
@@ -72,7 +72,7 @@ function Filter(filter) {
|
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Filter, "Filter");
|
|
76
76
|
function Pipe(pipe) {
|
|
77
77
|
return (target, property, index) => {
|
|
78
78
|
if (typeof index === "number") {
|
|
@@ -86,7 +86,7 @@ function Pipe(pipe) {
|
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Pipe, "Pipe");
|
|
90
90
|
|
|
91
91
|
// src/decorators/http.ts
|
|
92
92
|
|
|
@@ -100,7 +100,7 @@ function Route(route, type) {
|
|
|
100
100
|
});
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
|
|
103
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Route, "Route");
|
|
104
104
|
function Header(headers) {
|
|
105
105
|
return (target, property) => {
|
|
106
106
|
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
@@ -110,31 +110,31 @@ function Header(headers) {
|
|
|
110
110
|
});
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Header, "Header");
|
|
114
114
|
function Get(route = "") {
|
|
115
115
|
return Route(route, "get");
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Get, "Get");
|
|
118
118
|
function Post(route = "") {
|
|
119
119
|
return Route(route, "post");
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Post, "Post");
|
|
122
122
|
function Put(route = "") {
|
|
123
123
|
return Route(route, "put");
|
|
124
124
|
}
|
|
125
|
-
|
|
125
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Put, "Put");
|
|
126
126
|
function Search(route = "") {
|
|
127
127
|
return Route(route, "search");
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Search, "Search");
|
|
130
130
|
function Patch(route = "") {
|
|
131
131
|
return Route(route, "patch");
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Patch, "Patch");
|
|
134
134
|
function Delete(route = "") {
|
|
135
135
|
return Route(route, "delete");
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Delete, "Delete");
|
|
138
138
|
function Controller(prefix = "") {
|
|
139
139
|
return (target) => {
|
|
140
140
|
_phecdacore.setMeta.call(void 0, target, void 0, void 0, {
|
|
@@ -145,7 +145,7 @@ function Controller(prefix = "") {
|
|
|
145
145
|
});
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Controller, "Controller");
|
|
149
149
|
|
|
150
150
|
// src/decorators/rpc.ts
|
|
151
151
|
|
|
@@ -159,7 +159,7 @@ function Queue(queue = "", isEvent) {
|
|
|
159
159
|
});
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Queue, "Queue");
|
|
163
163
|
function Rpc() {
|
|
164
164
|
return (target) => {
|
|
165
165
|
_phecdacore.setMeta.call(void 0, target, void 0, void 0, {
|
|
@@ -167,11 +167,11 @@ function Rpc() {
|
|
|
167
167
|
});
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Rpc, "Rpc");
|
|
171
171
|
|
|
172
172
|
// src/decorators/ctx.ts
|
|
173
173
|
|
|
174
|
-
var Ctx = /* @__PURE__ */
|
|
174
|
+
var Ctx = /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (target, property) => {
|
|
175
175
|
_phecdacore.setMeta.call(void 0, target, _phecdacore.SHARE_KEY, void 0, {
|
|
176
176
|
ctxs: [
|
|
177
177
|
property
|
|
@@ -200,7 +200,7 @@ function Define(key, value) {
|
|
|
200
200
|
}
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Define, "Define");
|
|
204
204
|
|
|
205
205
|
|
|
206
206
|
|