phecda-server 4.0.1 → 4.0.2
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-PIRUVYEF.mjs → chunk-AJ2HYENF.mjs} +10 -4
- package/dist/{chunk-PIRUVYEF.mjs.map → chunk-AJ2HYENF.mjs.map} +1 -1
- package/dist/{chunk-7E4FZ7TC.js → chunk-D3VS53JQ.js} +24 -26
- package/dist/chunk-D3VS53JQ.js.map +1 -0
- package/dist/{chunk-JGSJIKGN.js → chunk-FAHHXHL5.js} +3 -3
- package/dist/{chunk-HY6T4ZWQ.mjs → chunk-JQPX546Z.mjs} +2 -2
- package/dist/{chunk-PU3LWJ2C.js → chunk-LZAU5FUS.js} +12 -6
- package/dist/chunk-LZAU5FUS.js.map +1 -0
- package/dist/{chunk-O2H7ERZR.mjs → chunk-Q6T7HNEO.mjs} +4 -6
- package/dist/{chunk-O2H7ERZR.mjs.map → chunk-Q6T7HNEO.mjs.map} +1 -1
- package/dist/{chunk-KVUJ3VJZ.mjs → chunk-WRMLZ7NU.mjs} +3 -5
- package/dist/{chunk-KVUJ3VJZ.mjs.map → chunk-WRMLZ7NU.mjs.map} +1 -1
- package/dist/{chunk-B22W7BG7.js → chunk-YU7ROHTO.js} +43 -45
- package/dist/chunk-YU7ROHTO.js.map +1 -0
- package/dist/index.d.ts +16 -10
- package/dist/index.js +57 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -7
- package/dist/index.mjs.map +1 -1
- package/dist/rpc/rabbitmq/index.js +9 -11
- package/dist/rpc/rabbitmq/index.js.map +1 -1
- package/dist/rpc/rabbitmq/index.mjs +3 -5
- package/dist/rpc/rabbitmq/index.mjs.map +1 -1
- package/dist/rpc/redis/index.js +9 -11
- package/dist/rpc/redis/index.js.map +1 -1
- package/dist/rpc/redis/index.mjs +3 -5
- package/dist/rpc/redis/index.mjs.map +1 -1
- package/dist/server/express/index.js +23 -25
- package/dist/server/express/index.js.map +1 -1
- package/dist/server/express/index.mjs +4 -6
- package/dist/server/express/index.mjs.map +1 -1
- package/dist/server/fastify/index.js +20 -22
- package/dist/server/fastify/index.js.map +1 -1
- package/dist/server/fastify/index.mjs +4 -6
- package/dist/server/fastify/index.mjs.map +1 -1
- package/dist/server/h3/index.js +23 -25
- package/dist/server/h3/index.js.map +1 -1
- package/dist/server/h3/index.mjs +4 -6
- package/dist/server/h3/index.mjs.map +1 -1
- package/dist/server/koa/index.d.ts +22 -0
- package/dist/server/koa/index.js +193 -0
- package/dist/server/koa/index.js.map +1 -0
- package/dist/server/koa/index.mjs +193 -0
- package/dist/server/koa/index.mjs.map +1 -0
- package/dist/test.js +7 -9
- package/dist/test.js.map +1 -1
- package/dist/test.mjs +4 -6
- package/dist/test.mjs.map +1 -1
- package/package.json +10 -2
- package/register/index.mjs +1 -1
- package/dist/chunk-7E4FZ7TC.js.map +0 -1
- package/dist/chunk-B22W7BG7.js.map +0 -1
- package/dist/chunk-IIGNGFDC.js +0 -47
- package/dist/chunk-IIGNGFDC.js.map +0 -1
- package/dist/chunk-PU3LWJ2C.js.map +0 -1
- package/dist/chunk-Q4FA4TAV.mjs +0 -47
- package/dist/chunk-Q4FA4TAV.mjs.map +0 -1
- package/dist/supertest-G6LTYS5C.js +0 -21969
- package/dist/supertest-G6LTYS5C.js.map +0 -1
- package/dist/supertest-NLMK5OIC.mjs +0 -21969
- package/dist/supertest-NLMK5OIC.mjs.map +0 -1
- /package/dist/{chunk-JGSJIKGN.js.map → chunk-FAHHXHL5.js.map} +0 -0
- /package/dist/{chunk-HY6T4ZWQ.mjs.map → chunk-JQPX546Z.mjs.map} +0 -0
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var _chunkPU3LWJ2Cjs = require('./chunk-PU3LWJ2C.js');
|
|
6
5
|
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
var _chunkIIGNGFDCjs = require('./chunk-IIGNGFDC.js');
|
|
7
|
+
var _chunkLZAU5FUSjs = require('./chunk-LZAU5FUS.js');
|
|
10
8
|
|
|
11
9
|
// src/exception/base.ts
|
|
12
10
|
var Exception = class extends Error {
|
|
@@ -28,7 +26,7 @@ var Exception = class extends Error {
|
|
|
28
26
|
};
|
|
29
27
|
}
|
|
30
28
|
};
|
|
31
|
-
|
|
29
|
+
_chunkLZAU5FUSjs.__name.call(void 0, Exception, "Exception");
|
|
32
30
|
|
|
33
31
|
// src/exception/validate.ts
|
|
34
32
|
var ValidateException = class extends Exception {
|
|
@@ -36,11 +34,11 @@ var ValidateException = class extends Exception {
|
|
|
36
34
|
super(message, 400, "Validate exception");
|
|
37
35
|
}
|
|
38
36
|
};
|
|
39
|
-
|
|
37
|
+
_chunkLZAU5FUSjs.__name.call(void 0, ValidateException, "ValidateException");
|
|
40
38
|
|
|
41
39
|
// src/pipe.ts
|
|
42
40
|
var _phecdacore = require('phecda-core');
|
|
43
|
-
var defaultPipe = /* @__PURE__ */
|
|
41
|
+
var defaultPipe = /* @__PURE__ */ _chunkLZAU5FUSjs.__name.call(void 0, async ({ arg, reflect, index }) => {
|
|
44
42
|
if (_phecdacore.isPhecda.call(void 0, reflect)) {
|
|
45
43
|
const instance = _phecdacore.plainToClass.call(void 0, reflect, arg);
|
|
46
44
|
const err = await _phecdacore.transformClass.call(void 0, instance);
|
|
@@ -66,7 +64,7 @@ var UndefinedException = class extends Exception {
|
|
|
66
64
|
super(message, 500, "Undefined error");
|
|
67
65
|
}
|
|
68
66
|
};
|
|
69
|
-
|
|
67
|
+
_chunkLZAU5FUSjs.__name.call(void 0, UndefinedException, "UndefinedException");
|
|
70
68
|
|
|
71
69
|
// src/exception/forbidden.ts
|
|
72
70
|
var ForbiddenException = class extends Exception {
|
|
@@ -74,7 +72,7 @@ var ForbiddenException = class extends Exception {
|
|
|
74
72
|
super(message, 403, "Forbidden resource");
|
|
75
73
|
}
|
|
76
74
|
};
|
|
77
|
-
|
|
75
|
+
_chunkLZAU5FUSjs.__name.call(void 0, ForbiddenException, "ForbiddenException");
|
|
78
76
|
|
|
79
77
|
// src/exception/bad-request.ts
|
|
80
78
|
var BadRequestException = class extends Exception {
|
|
@@ -82,7 +80,7 @@ var BadRequestException = class extends Exception {
|
|
|
82
80
|
super(message, 400, "Bad Request");
|
|
83
81
|
}
|
|
84
82
|
};
|
|
85
|
-
|
|
83
|
+
_chunkLZAU5FUSjs.__name.call(void 0, BadRequestException, "BadRequestException");
|
|
86
84
|
|
|
87
85
|
// src/exception/not-found.ts
|
|
88
86
|
var NotFoundException = class extends Exception {
|
|
@@ -90,7 +88,7 @@ var NotFoundException = class extends Exception {
|
|
|
90
88
|
super(message, 404, "Not Found");
|
|
91
89
|
}
|
|
92
90
|
};
|
|
93
|
-
|
|
91
|
+
_chunkLZAU5FUSjs.__name.call(void 0, NotFoundException, "NotFoundException");
|
|
94
92
|
|
|
95
93
|
// src/exception/conflict.ts
|
|
96
94
|
var ConflictException = class extends Exception {
|
|
@@ -98,7 +96,7 @@ var ConflictException = class extends Exception {
|
|
|
98
96
|
super(message, 409, "Conflict");
|
|
99
97
|
}
|
|
100
98
|
};
|
|
101
|
-
|
|
99
|
+
_chunkLZAU5FUSjs.__name.call(void 0, ConflictException, "ConflictException");
|
|
102
100
|
|
|
103
101
|
// src/exception/bad-gateway.ts
|
|
104
102
|
var BadGatewayException = class extends Exception {
|
|
@@ -106,7 +104,7 @@ var BadGatewayException = class extends Exception {
|
|
|
106
104
|
super(message, 502, "Bad Gatrway");
|
|
107
105
|
}
|
|
108
106
|
};
|
|
109
|
-
|
|
107
|
+
_chunkLZAU5FUSjs.__name.call(void 0, BadGatewayException, "BadGatewayException");
|
|
110
108
|
|
|
111
109
|
// src/exception/invalid-input.ts
|
|
112
110
|
var InvalidInputException = class extends Exception {
|
|
@@ -114,7 +112,7 @@ var InvalidInputException = class extends Exception {
|
|
|
114
112
|
super(message, 502, "Invalid Input");
|
|
115
113
|
}
|
|
116
114
|
};
|
|
117
|
-
|
|
115
|
+
_chunkLZAU5FUSjs.__name.call(void 0, InvalidInputException, "InvalidInputException");
|
|
118
116
|
|
|
119
117
|
// src/exception/media-type.ts
|
|
120
118
|
var UnsupportedMediaTypeException = class extends Exception {
|
|
@@ -122,7 +120,7 @@ var UnsupportedMediaTypeException = class extends Exception {
|
|
|
122
120
|
super(message, 415, "Unsupported Media Type");
|
|
123
121
|
}
|
|
124
122
|
};
|
|
125
|
-
|
|
123
|
+
_chunkLZAU5FUSjs.__name.call(void 0, UnsupportedMediaTypeException, "UnsupportedMediaTypeException");
|
|
126
124
|
|
|
127
125
|
// src/exception/payload-large.ts
|
|
128
126
|
var PayloadLargeException = class extends Exception {
|
|
@@ -130,7 +128,7 @@ var PayloadLargeException = class extends Exception {
|
|
|
130
128
|
super(message, 413, "Payload Too Large");
|
|
131
129
|
}
|
|
132
130
|
};
|
|
133
|
-
|
|
131
|
+
_chunkLZAU5FUSjs.__name.call(void 0, PayloadLargeException, "PayloadLargeException");
|
|
134
132
|
|
|
135
133
|
// src/exception/timeout.ts
|
|
136
134
|
var TimeoutException = class extends Exception {
|
|
@@ -138,7 +136,7 @@ var TimeoutException = class extends Exception {
|
|
|
138
136
|
super(message, 408, "Request Timeout");
|
|
139
137
|
}
|
|
140
138
|
};
|
|
141
|
-
|
|
139
|
+
_chunkLZAU5FUSjs.__name.call(void 0, TimeoutException, "TimeoutException");
|
|
142
140
|
|
|
143
141
|
// src/exception/unauthorized.ts
|
|
144
142
|
var UnauthorizedException = class extends Exception {
|
|
@@ -146,7 +144,7 @@ var UnauthorizedException = class extends Exception {
|
|
|
146
144
|
super(message, 401, "Unauthorized");
|
|
147
145
|
}
|
|
148
146
|
};
|
|
149
|
-
|
|
147
|
+
_chunkLZAU5FUSjs.__name.call(void 0, UnauthorizedException, "UnauthorizedException");
|
|
150
148
|
|
|
151
149
|
// src/exception/unavailable-service.ts
|
|
152
150
|
var ServiceUnavailableException = class extends Exception {
|
|
@@ -154,7 +152,7 @@ var ServiceUnavailableException = class extends Exception {
|
|
|
154
152
|
super(message, 503, "Service Unavailable");
|
|
155
153
|
}
|
|
156
154
|
};
|
|
157
|
-
|
|
155
|
+
_chunkLZAU5FUSjs.__name.call(void 0, ServiceUnavailableException, "ServiceUnavailableException");
|
|
158
156
|
|
|
159
157
|
// src/exception/framework.ts
|
|
160
158
|
var FrameworkException = class extends Exception {
|
|
@@ -162,19 +160,19 @@ var FrameworkException = class extends Exception {
|
|
|
162
160
|
super(`[phecda-server] ${message}`, 500, "Framework Error");
|
|
163
161
|
}
|
|
164
162
|
};
|
|
165
|
-
|
|
163
|
+
_chunkLZAU5FUSjs.__name.call(void 0, FrameworkException, "FrameworkException");
|
|
166
164
|
|
|
167
165
|
// src/context.ts
|
|
168
166
|
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
169
167
|
|
|
170
168
|
// src/filter.ts
|
|
171
|
-
var defaultFilter = /* @__PURE__ */
|
|
169
|
+
var defaultFilter = /* @__PURE__ */ _chunkLZAU5FUSjs.__name.call(void 0, (e) => {
|
|
172
170
|
if (!(e instanceof Exception)) {
|
|
173
|
-
|
|
171
|
+
_chunkLZAU5FUSjs.log.call(void 0, e.message, "error");
|
|
174
172
|
console.error(e.stack);
|
|
175
173
|
e = new UndefinedException(e.message || e);
|
|
176
174
|
} else {
|
|
177
|
-
|
|
175
|
+
_chunkLZAU5FUSjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
|
|
178
176
|
console.error(e.stack);
|
|
179
177
|
}
|
|
180
178
|
return e.data;
|
|
@@ -192,7 +190,7 @@ var Histroy = (_class = class {constructor() { _class.prototype.__init.call(this
|
|
|
192
190
|
return false;
|
|
193
191
|
}
|
|
194
192
|
}, _class);
|
|
195
|
-
|
|
193
|
+
_chunkLZAU5FUSjs.__name.call(void 0, Histroy, "Histroy");
|
|
196
194
|
|
|
197
195
|
// src/context.ts
|
|
198
196
|
var guardRecord = {};
|
|
@@ -207,13 +205,13 @@ var _Context = class {
|
|
|
207
205
|
this.tag = tag;
|
|
208
206
|
this.data = data;
|
|
209
207
|
this.history = new Histroy();
|
|
210
|
-
if (
|
|
208
|
+
if (_chunkLZAU5FUSjs.IS_DEV)
|
|
211
209
|
data._context = this;
|
|
212
210
|
}
|
|
213
211
|
usePipe(args) {
|
|
214
212
|
return Promise.all(args.map((item) => {
|
|
215
213
|
if (item.pipe && !_Context.pipeRecord[item.pipe]) {
|
|
216
|
-
if (
|
|
214
|
+
if (_chunkLZAU5FUSjs.IS_STRICT)
|
|
217
215
|
throw new FrameworkException(`can't find pipe named '${item.pipe}'`);
|
|
218
216
|
else
|
|
219
217
|
return _Context.pipeRecord.default(item, this.tag, this.data);
|
|
@@ -228,7 +226,7 @@ var _Context = class {
|
|
|
228
226
|
for (const guard of guards) {
|
|
229
227
|
if (this.history.record(guard, "guard")) {
|
|
230
228
|
if (!(guard in _Context.guardRecord)) {
|
|
231
|
-
if (
|
|
229
|
+
if (_chunkLZAU5FUSjs.IS_STRICT)
|
|
232
230
|
throw new FrameworkException(`can't find guard named '${guard}'`);
|
|
233
231
|
continue;
|
|
234
232
|
}
|
|
@@ -247,7 +245,7 @@ var _Context = class {
|
|
|
247
245
|
for (const interceptor of interceptors) {
|
|
248
246
|
if (this.history.record(interceptor, "interceptor")) {
|
|
249
247
|
if (!(interceptor in _Context.interceptorRecord)) {
|
|
250
|
-
if (
|
|
248
|
+
if (_chunkLZAU5FUSjs.IS_STRICT)
|
|
251
249
|
throw new FrameworkException(`can't find interceptor named '${interceptor}'`);
|
|
252
250
|
continue;
|
|
253
251
|
}
|
|
@@ -266,7 +264,7 @@ var _Context = class {
|
|
|
266
264
|
const ret = [];
|
|
267
265
|
for (const m of plugins) {
|
|
268
266
|
if (!(m in _Context.pluginRecord)) {
|
|
269
|
-
if (
|
|
267
|
+
if (_chunkLZAU5FUSjs.IS_STRICT)
|
|
270
268
|
throw new FrameworkException(`can't find middleware named '${m}'`);
|
|
271
269
|
continue;
|
|
272
270
|
}
|
|
@@ -276,34 +274,34 @@ var _Context = class {
|
|
|
276
274
|
}
|
|
277
275
|
};
|
|
278
276
|
var Context = _Context;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
277
|
+
_chunkLZAU5FUSjs.__name.call(void 0, Context, "Context");
|
|
278
|
+
_chunkLZAU5FUSjs.__publicField.call(void 0, Context, "filter", defaultFilter);
|
|
279
|
+
_chunkLZAU5FUSjs.__publicField.call(void 0, Context, "pipeRecord", {
|
|
282
280
|
default: defaultPipe
|
|
283
281
|
});
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
282
|
+
_chunkLZAU5FUSjs.__publicField.call(void 0, Context, "guardRecord", {});
|
|
283
|
+
_chunkLZAU5FUSjs.__publicField.call(void 0, Context, "interceptorRecord", {});
|
|
284
|
+
_chunkLZAU5FUSjs.__publicField.call(void 0, Context, "pluginRecord", {});
|
|
287
285
|
function addPlugin(key, handler) {
|
|
288
286
|
Context.pluginRecord[key] = handler;
|
|
289
287
|
}
|
|
290
|
-
|
|
288
|
+
_chunkLZAU5FUSjs.__name.call(void 0, addPlugin, "addPlugin");
|
|
291
289
|
function addPipe(key, pipe) {
|
|
292
290
|
Context.pipeRecord[key] = pipe;
|
|
293
291
|
}
|
|
294
|
-
|
|
292
|
+
_chunkLZAU5FUSjs.__name.call(void 0, addPipe, "addPipe");
|
|
295
293
|
function setFilter(filter) {
|
|
296
294
|
Context.filter = filter;
|
|
297
295
|
}
|
|
298
|
-
|
|
296
|
+
_chunkLZAU5FUSjs.__name.call(void 0, setFilter, "setFilter");
|
|
299
297
|
function addGuard(key, handler) {
|
|
300
298
|
Context.guardRecord[key] = handler;
|
|
301
299
|
}
|
|
302
|
-
|
|
300
|
+
_chunkLZAU5FUSjs.__name.call(void 0, addGuard, "addGuard");
|
|
303
301
|
function addInterceptor(key, handler) {
|
|
304
302
|
Context.interceptorRecord[key] = handler;
|
|
305
303
|
}
|
|
306
|
-
|
|
304
|
+
_chunkLZAU5FUSjs.__name.call(void 0, addInterceptor, "addInterceptor");
|
|
307
305
|
function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
|
|
308
306
|
const pluginSet = new Set(plugins);
|
|
309
307
|
const guardSet = new Set(guards);
|
|
@@ -322,28 +320,28 @@ function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
|
|
|
322
320
|
...pluginSet
|
|
323
321
|
].forEach((i) => {
|
|
324
322
|
if (!Context.pluginRecord[i])
|
|
325
|
-
|
|
323
|
+
_chunkLZAU5FUSjs.log.call(void 0, `${_picocolors2.default.white(`Plugin [${i}]`)} doesn't exist`, "warn");
|
|
326
324
|
});
|
|
327
325
|
[
|
|
328
326
|
...guardSet
|
|
329
327
|
].forEach((i) => {
|
|
330
328
|
if (!Context.guardRecord[i])
|
|
331
|
-
|
|
329
|
+
_chunkLZAU5FUSjs.log.call(void 0, `${_picocolors2.default.red(`Guard [${i}]`)} doesn't exist`, "warn");
|
|
332
330
|
});
|
|
333
331
|
[
|
|
334
332
|
...interceptorSet
|
|
335
333
|
].forEach((i) => {
|
|
336
334
|
if (!Context.interceptorRecord[i])
|
|
337
|
-
|
|
335
|
+
_chunkLZAU5FUSjs.log.call(void 0, `${_picocolors2.default.cyan(`Interceptor [${i}]`)} doesn't exist`, "warn");
|
|
338
336
|
});
|
|
339
337
|
[
|
|
340
338
|
...pipeSet
|
|
341
339
|
].forEach((i) => {
|
|
342
340
|
if (!Context.pipeRecord[i])
|
|
343
|
-
|
|
341
|
+
_chunkLZAU5FUSjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${i}]`)} doesn't exist`, "warn");
|
|
344
342
|
});
|
|
345
343
|
}
|
|
346
|
-
|
|
344
|
+
_chunkLZAU5FUSjs.__name.call(void 0, isAopDepInject, "isAopDepInject");
|
|
347
345
|
|
|
348
346
|
|
|
349
347
|
|
|
@@ -372,4 +370,4 @@ _chunkIIGNGFDCjs.__name.call(void 0, isAopDepInject, "isAopDepInject");
|
|
|
372
370
|
|
|
373
371
|
|
|
374
372
|
exports.Exception = Exception; exports.ValidateException = ValidateException; exports.defaultPipe = defaultPipe; exports.UndefinedException = UndefinedException; 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.defaultFilter = defaultFilter; exports.guardRecord = guardRecord; exports.Context = Context; exports.addPlugin = addPlugin; exports.addPipe = addPipe; exports.setFilter = setFilter; exports.addGuard = addGuard; exports.addInterceptor = addInterceptor; exports.isAopDepInject = isAopDepInject;
|
|
375
|
-
//# sourceMappingURL=chunk-
|
|
373
|
+
//# sourceMappingURL=chunk-YU7ROHTO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/exception/base.ts","../src/exception/validate.ts","../src/pipe.ts","../src/exception/undefine.ts","../src/exception/forbidden.ts","../src/exception/bad-request.ts","../src/exception/not-found.ts","../src/exception/conflict.ts","../src/exception/bad-gateway.ts","../src/exception/invalid-input.ts","../src/exception/media-type.ts","../src/exception/payload-large.ts","../src/exception/timeout.ts","../src/exception/unauthorized.ts","../src/exception/unavailable-service.ts","../src/exception/framework.ts","../src/context.ts","../src/filter.ts","../src/history.ts"],"names":["Exception","Error","message","status","description","constructor","data","error","ValidateException","isPhecda","plainToClass","transformClass","defaultPipe","arg","reflect","index","instance","err","length","Number","Boolean","includes","Object","is","NaN","UndefinedException","ForbiddenException","BadRequestException","NotFoundException","ConflictException","BadGatewayException","InvalidInputException","UnsupportedMediaTypeException","PayloadLargeException","TimeoutException","UnauthorizedException","ServiceUnavailableException","FrameworkException","pc","defaultFilter","e","log","console","stack","name","Histroy","guard","interceptor","record","type","push","guardRecord","Context","tag","method","params","history","postInterceptors","IS_DEV","_context","usePipe","args","Promise","all","map","item","pipe","pipeRecord","IS_STRICT","default","useFilter","filter","useGuard","guards","usePostInterceptor","ret","cb","useInterceptor","interceptors","interceptorRecord","postInterceptor","undefined","usePlugin","plugins","m","pluginRecord","addPlugin","key","handler","addPipe","setFilter","addGuard","addInterceptor","isAopDepInject","meta","pluginSet","Set","guardSet","interceptorSet","pipeSet","forEach","i","add","white","red","cyan","blue"],"mappings":";;;;;;;;;AAAO,IAAMA,YAAN,cAAwBC,MAAAA;EACVC;EAAwBC;EAAuBC;EAAlEC,YAAmBH,SAAwBC,QAAuBC,cAAc,kBAAkB;AAChG,UAAMF,OAAAA;mBADWA;kBAAwBC;uBAAuBC;EAElE;EAEA,IAAIE,OAAO;AACT,WAAO;MAAEJ,SAAS,KAAKA;MAASE,aAAa,KAAKA;MAAaD,QAAQ,KAAKA;MAAQI,OAAO;IAAK;EAClG;AACF;AARaP;;;ACEN,IAAMQ,oBAAN,cAAgCR,UAAAA;EACrCK,YAAYH,SAAiB;AAC3B,UAAMA,SAAS,KAAK,oBAAA;EACtB;AACF;AAJaM;;;ACFb,SAASC,UAAUC,cAAcC,sBAAsB;AAKhD,IAAMC,cAAsB,8BAAO,EAAEC,KAAKC,SAASC,MAAK,MAAY;AACzE,MAAIN,SAASK,OAAAA,GAAU;AACrB,UAAME,WAAWN,aAAaI,SAASD,GAAAA;AACvC,UAAMI,MAAM,MAAMN,eAAeK,QAAAA;AACjC,QAAIC,IAAIC,SAAS;AACf,YAAM,IAAIV,kBAAkBS,IAAI,EAAE;AAEpCJ,UAAMG;EACR,OACK;AACH,QAAI;MAACG;MAAQC;MAASC,SAASP,OAAAA,GAAU;AACvCD,YAAMC,QAAQD,GAAAA;AAEd,UAAIC,YAAYK,UAAUG,OAAOC,GAAGV,KAAKW,GAAAA;AACvC,cAAM,IAAIhB,kBAAkB,aAAaW,OAAOJ,KAAAA,IAAS,sBAAsB;IACnF;EACF;AACA,SAA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,CAAC,EAAE9F,KAAI,MAAO;AACzBA,SAAKwE,aAAasB,QAAQC,CAAAA,MAAKH,eAAeI,IAAID,CAAAA,CAAAA;AAClD/F,SAAKmE,OAAO2B,QAAQC,CAAAA,MAAKJ,SAASK,IAAID,CAAAA,CAAAA;AACtC/F,SAAK6E,QAAQiB,QAAQC,CAAAA,MAAKN,UAAUO,IAAID,CAAAA,CAAAA;AACxC/F,SAAKiD,OAAO6C,QAAQ,CAACC,MAAM;AACzB,UAAIA,EAAEnC;AACJiC,gBAAQG,IAAID,EAAEnC,IAAI;IACtB,CAAA;EACF,CAAA;AAEA;OAAI6B;IAAWK,QAAQ,CAACC,MAAM;AAC5B,QAAI,CAACjD,QAAQiC,aAAagB;AACxB5D,UAAI,GAAGH,GAAGiE,MAAM,WAAWF,IAAI,mBAAmB,MAAA;EACtD,CAAA;AACA;OAAIJ;IAAUG,QAAQ,CAACC,MAAM;AAC3B,QAAI,CAACjD,QAAQD,YAAYkD;AACvB5D,UAAI,GAAGH,GAAGkE,IAAI,UAAUH,IAAI,mBAAmB,MAAA;EACnD,CAAA;AACA;OAAIH;IAAgBE,QAAQ,CAACC,MAAM;AACjC,QAAI,CAACjD,QAAQ2B,kBAAkBsB;AAC7B5D,UAAI,GAAGH,GAAGmE,KAAK,gBAAgBJ,IAAI,mBAAmB,MAAA;EAC1D,CAAA;AACA;OAAIF;IAASC,QAAQ,CAACC,MAAM;AAC1B,QAAI,CAACjD,QAAQe,WAAWkC;AACtB5D,UAAI,GAAGH,GAAGoE,KAAK,SAASL,IAAI,mBAAmB,MAAA;EACnD,CAAA;AACF;AApCgBR","sourcesContent":["export class Exception extends Error {\n constructor(public message: string, public status: number, public description = 'Http exception') {\n super(message)\n }\n\n get data() {\n return { message: this.message, description: this.description, status: this.status, error: true }\n }\n}\n","import { Exception } from './base'\n\nexport class ValidateException extends Exception {\n constructor(message: string) {\n super(message, 400, 'Validate exception')\n }\n}\n","import { isPhecda, plainToClass, transformClass } from 'phecda-core'\nimport { ValidateException } from './exception/validate'\n\nimport type { P } from './types'\n\nexport const defaultPipe: P.Pipe = async ({ arg, reflect, index }: any) => {\n if (isPhecda(reflect)) {\n const instance = plainToClass(reflect, arg)\n const err = await transformClass(instance)\n if (err.length > 0)\n throw new ValidateException(err[0])\n\n arg = instance\n }\n else {\n if ([Number, Boolean].includes(reflect)) {\n arg = reflect(arg)\n\n if (reflect === Number && Object.is(arg, NaN))\n throw new ValidateException(`parameter ${Number(index) + 1} should be a number`)\n }\n }\n return arg\n}\n","import { Exception } from './base'\n\nexport class UndefinedException extends Exception {\n constructor(message: string) {\n super(message, 500, 'Undefined error')\n }\n}\n","import { Exception } from './base'\n\nexport class ForbiddenException extends Exception {\n constructor(message: string) {\n super(message, 403, 'Forbidden resource')\n }\n}\n","import { Exception } from './base'\n\nexport class BadRequestException extends Exception {\n constructor(message: string) {\n super(message, 400, 'Bad Request')\n }\n}\n","import { Exception } from './base'\n\nexport class NotFoundException extends Exception {\n constructor(message: string) {\n super(message, 404, 'Not Found')\n }\n}\n","import { Exception } from './base'\n\nexport class ConflictException extends Exception {\n constructor(message: string) {\n super(message, 409, 'Conflict')\n }\n}\n","import { Exception } from './base'\n\nexport class BadGatewayException extends Exception {\n constructor(message: string) {\n super(message, 502, 'Bad Gatrway')\n }\n}\n","import { Exception } from './base'\n\nexport class InvalidInputException extends Exception {\n constructor(message: string) {\n super(message, 502, 'Invalid Input')\n }\n}\n","import { Exception } from './base'\n\nexport class UnsupportedMediaTypeException extends Exception {\n constructor(message: string) {\n super(message, 415, 'Unsupported Media Type')\n }\n}\n","import { Exception } from './base'\n\nexport class PayloadLargeException extends Exception {\n constructor(message: string) {\n super(message, 413, 'Payload Too Large')\n }\n}\n","import { Exception } from './base'\n\nexport class TimeoutException extends Exception {\n constructor(message: string) {\n super(message, 408, 'Request Timeout',\n )\n }\n}\n","import { Exception } from './base'\n\nexport class UnauthorizedException extends Exception {\n constructor(message: string) {\n super(message, 401, 'Unauthorized')\n }\n}\n","import { Exception } from './base'\n\nexport class ServiceUnavailableException extends Exception {\n constructor(message: string) {\n super(message, 503, 'Service Unavailable')\n }\n}\n","import { Exception } from './base'\n\nexport class FrameworkException extends Exception {\n constructor(message: string) {\n super(`[phecda-server] ${message}`, 500, 'Framework Error')\n }\n}\n","import pc from 'picocolors'\nimport { defaultPipe } from './pipe'\nimport { ForbiddenException, FrameworkException } from './exception'\nimport { defaultFilter } from './filter'\nimport { Histroy } from './history'\nimport type { P } from './types'\nimport { IS_DEV, IS_STRICT } from './common'\nimport type { Meta } from './meta'\nimport { log } from './utils'\nexport const guardRecord = {} as Record<string, P.Guard>\n\nexport class Context<Data = any> {\n method: string\n params: string[]\n history = new Histroy()\n\n static filter: P.Filter = defaultFilter\n static pipeRecord: Record<string, P.Pipe> = {\n default: defaultPipe,\n }\n\n static guardRecord: Record<string, P.Guard> = {}\n static interceptorRecord: Record<string, P.Interceptor> = {}\n\n static pluginRecord: Record<string, any> = {}\n postInterceptors: Function[]\n\n constructor(public tag: string, public data: Data) {\n if (IS_DEV)\n // @ts-expect-error work for debug\n data._context = this\n }\n\n usePipe(args: { arg: any; pipe?: string; pipeOpts?: any; type: string; key: string; index: number; reflect: any }[]) {\n return Promise.all(args.map((item) => {\n if (item.pipe && !Context.pipeRecord[item.pipe]) {\n if (IS_STRICT)\n throw new FrameworkException(`can't find pipe named '${item.pipe}'`)\n\n else\n return Context.pipeRecord.default(item, this.tag, this.data)\n }\n\n return Context.pipeRecord[item.pipe || 'default'](item, this.tag, this.data)\n }))\n }\n\n useFilter(arg: any) {\n return Context.filter(arg, this.tag, this.data)\n }\n\n async useGuard(guards: string[]) {\n for (const guard of guards) {\n if (this.history.record(guard, 'guard')) {\n if (!(guard in Context.guardRecord)) {\n if (IS_STRICT)\n throw new FrameworkException(`can't find guard named '${guard}'`)\n continue\n }\n if (!await Context.guardRecord[guard](this.tag, this.data))\n throw new ForbiddenException(`Guard exception--${guard}`)\n }\n }\n }\n\n async usePostInterceptor(ret: any) {\n for (const cb of this.postInterceptors)\n ret = await cb(ret) || ret\n\n return ret\n }\n\n async useInterceptor(interceptors: string[]) {\n const ret = []\n for (const interceptor of interceptors) {\n if (this.history.record(interceptor, 'interceptor')) {\n if (!(interceptor in Context.interceptorRecord)) {\n if (IS_STRICT)\n throw new FrameworkException(`can't find interceptor named '${interceptor}'`)\n\n continue\n }\n const postInterceptor = await Context.interceptorRecord[interceptor](this.tag, this.data)\n if (postInterceptor !== undefined) {\n if (typeof postInterceptor === 'function')\n ret.push(postInterceptor)\n\n else\n return postInterceptor\n }\n }\n }\n this.postInterceptors = ret\n }\n\n static usePlugin(plugins: string[]) {\n const ret = []\n for (const m of plugins) {\n if (!(m in Context.pluginRecord)) {\n if (IS_STRICT)\n throw new FrameworkException(`can't find middleware named '${m}'`)\n\n continue\n }\n ret.push(Context.pluginRecord[m])\n }\n return ret as any[]\n }\n}\nexport function addPlugin<C>(key: string, handler: C) {\n Context.pluginRecord[key] = handler\n}\n\nexport function addPipe(key: string, pipe: P.Pipe) {\n Context.pipeRecord[key] = pipe\n}\n\nexport function setFilter(filter: P.Filter) {\n Context.filter = filter\n}\n\nexport function addGuard(key: string, handler: P.Guard) {\n Context.guardRecord[key] = handler\n}\n\nexport function addInterceptor(key: string, handler: P.Interceptor) {\n Context.interceptorRecord[key] = handler\n}\n\nexport function isAopDepInject(meta: Meta[], { guards, interceptors, plugins }: {\n guards?: string[]\n interceptors?: string[]\n plugins?: string[]\n} = {}) {\n const pluginSet = new Set<string>(plugins)\n\n const guardSet = new Set<string>(guards)\n const interceptorSet = new Set<string>(interceptors)\n const pipeSet = new Set<string>()\n meta.forEach(({ data }) => {\n data.interceptors.forEach(i => interceptorSet.add(i))\n data.guards.forEach(i => guardSet.add(i))\n data.plugins.forEach(i => pluginSet.add(i))\n data.params.forEach((i) => {\n if (i.pipe)\n pipeSet.add(i.pipe)\n })\n });\n\n [...pluginSet].forEach((i) => {\n if (!Context.pluginRecord[i])\n log(`${pc.white(`Plugin [${i}]`)} doesn't exist`, 'warn')\n });\n [...guardSet].forEach((i) => {\n if (!Context.guardRecord[i])\n log(`${pc.red(`Guard [${i}]`)} doesn't exist`, 'warn')\n });\n [...interceptorSet].forEach((i) => {\n if (!Context.interceptorRecord[i])\n log(`${pc.cyan(`Interceptor [${i}]`)} doesn't exist`, 'warn')\n });\n [...pipeSet].forEach((i) => {\n if (!Context.pipeRecord[i])\n log(`${pc.blue(`Pipe [${i}]`)} doesn't exist`, 'warn')\n })\n}\n","import { Exception, UndefinedException } from './exception'\nimport type { P } from './types'\nimport { log } from './utils'\n\nexport const defaultFilter: P.Filter = (e: any) => {\n if (!(e instanceof Exception)) {\n log(e.message, 'error')\n console.error(e.stack)\n e = new UndefinedException(e.message || e)\n }\n else {\n log(`[${e.constructor.name}] ${e.message}`, 'error')\n console.error(e.stack)\n }\n\n return e.data\n}\n","export class Histroy {\n guard: string[] = []\n interceptor: string[] = []\n record(name: string, type: 'guard' | 'interceptor') {\n if (!this[type].includes(name)) {\n this[type].push(name)\n return true\n }\n return false\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as Exception, P } from './types-ead02c5d.js';
|
|
2
|
-
export { B as BaseError, C as Construct,
|
|
1
|
+
import { E as Exception, P, a as Emitter } from './types-ead02c5d.js';
|
|
2
|
+
export { B as BaseError, C as Construct, M as MergeType, R as RequestType, S as ServerErr, T as ToInstance } from './types-ead02c5d.js';
|
|
3
3
|
import { M as Meta } from './core-7c2dd0c7.js';
|
|
4
4
|
export { F as Factory, I as Injectable, e as emitter } from './core-7c2dd0c7.js';
|
|
5
5
|
export * from 'phecda-core';
|
|
@@ -144,22 +144,23 @@ declare const IS_DEV: boolean;
|
|
|
144
144
|
declare const IS_STRICT: boolean;
|
|
145
145
|
|
|
146
146
|
declare class Dev {
|
|
147
|
-
|
|
147
|
+
protected readonly emitter: Emitter;
|
|
148
|
+
private readonly [UNMOUNT_SYMBOL];
|
|
148
149
|
onUnmount(cb: () => void): void;
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
declare abstract class PFilter extends Dev {
|
|
152
|
+
declare abstract class PFilter<C = any, S = any, E extends Exception = Exception> extends Dev {
|
|
152
153
|
constructor();
|
|
153
|
-
abstract use
|
|
154
|
+
abstract use(error: Error | E, tag?: string, ctx?: C): S;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
declare abstract class PGuard extends Dev {
|
|
157
|
-
abstract use
|
|
157
|
+
declare abstract class PGuard<C = any> extends Dev {
|
|
158
|
+
abstract use(tag: string, ctx: C): Promise<boolean> | boolean;
|
|
158
159
|
constructor();
|
|
159
160
|
}
|
|
160
161
|
|
|
161
|
-
declare abstract class PInterceptor extends Dev {
|
|
162
|
-
abstract use
|
|
162
|
+
declare abstract class PInterceptor<C = any> extends Dev {
|
|
163
|
+
abstract use(tag: string, ctx: C): ((arg: any) => any) | void;
|
|
163
164
|
constructor();
|
|
164
165
|
}
|
|
165
166
|
|
|
@@ -175,8 +176,13 @@ declare abstract class PPipe<C = any> extends Dev {
|
|
|
175
176
|
}, tag: string, ctx: C): Promise<any>;
|
|
176
177
|
}
|
|
177
178
|
|
|
179
|
+
declare abstract class PPlugin extends Dev {
|
|
180
|
+
constructor();
|
|
181
|
+
abstract use(...args: any): void;
|
|
182
|
+
}
|
|
183
|
+
|
|
178
184
|
declare function generateRPCCode(meta: P.Meta[]): string;
|
|
179
185
|
|
|
180
186
|
declare function generateHTTPCode(meta: P.Meta[]): string;
|
|
181
187
|
|
|
182
|
-
export { APP_SYMBOL, Arg, BadGatewayException, BadRequestException, BaseParam, Body, ConflictException, Context, Controller, Define, Delete, Dev, Event, Exception, ForbiddenException, FrameworkException, Get, Guard, Head, Header, IS_DEV, IS_STRICT, Interceptor, InvalidInputException, MERGE_SYMBOL, META_SYMBOL, MODULE_SYMBOL, Meta, NotFoundException, P, PFilter, PGuard, PInterceptor, PPipe, Param, Patch, PayloadLargeException, Pipe, Plugin, Post, Put, Query, Route, Rpc, ServiceUnavailableException, TimeoutException, UNMOUNT_SYMBOL, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, addGuard, addInterceptor, addPipe, addPlugin, defaultPipe, generateHTTPCode, generateRPCCode, guardRecord, isAopDepInject, resolveDep, setFilter };
|
|
188
|
+
export { APP_SYMBOL, Arg, BadGatewayException, BadRequestException, BaseParam, Body, ConflictException, Context, Controller, Define, Delete, Dev, Emitter, Event, Exception, ForbiddenException, FrameworkException, Get, Guard, Head, Header, IS_DEV, IS_STRICT, Interceptor, InvalidInputException, MERGE_SYMBOL, META_SYMBOL, MODULE_SYMBOL, Meta, NotFoundException, P, PFilter, PGuard, PInterceptor, PPipe, PPlugin, Param, Patch, PayloadLargeException, Pipe, Plugin, Post, Put, Query, Route, Rpc, ServiceUnavailableException, TimeoutException, UNMOUNT_SYMBOL, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, addGuard, addInterceptor, addPipe, addPlugin, defaultPipe, generateHTTPCode, generateRPCCode, guardRecord, isAopDepInject, resolveDep, setFilter };
|