phecda-server 6.0.2 → 7.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +160 -157
- package/dist/{chunk-HDQAT2IM.mjs → chunk-5622RBNB.mjs} +118 -90
- package/dist/chunk-BGXSMOLX.js +265 -0
- package/dist/{chunk-F3W3NN7F.mjs → chunk-HMVLXNV3.mjs} +5 -14
- package/dist/{chunk-GHFSIZUO.js → chunk-J5CFUN4V.js} +18 -3
- package/dist/{chunk-XCND2QW3.js → chunk-MBCHNDAY.js} +27 -36
- package/dist/{chunk-WXFZZZRY.mjs → chunk-P75VKZJY.mjs} +101 -137
- package/dist/chunk-SW5IKE5H.js +503 -0
- package/dist/{chunk-UXD62LGG.mjs → chunk-WHJ5FALK.mjs} +17 -2
- package/dist/core-BIcUwV18.d.mts +47 -0
- package/dist/core-CYwEPfN4.d.ts +47 -0
- package/dist/helper.d.mts +4 -6
- package/dist/helper.d.ts +4 -6
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/{server → http}/elysia/index.d.mts +5 -5
- package/dist/{server → http}/elysia/index.d.ts +5 -5
- package/dist/{server → http}/elysia/index.js +80 -62
- package/dist/{server → http}/elysia/index.mjs +50 -32
- package/dist/{server → http}/express/index.d.mts +5 -5
- package/dist/{server → http}/express/index.d.ts +5 -5
- package/dist/{server → http}/express/index.js +71 -55
- package/dist/{server → http}/express/index.mjs +42 -26
- package/dist/{server → http}/fastify/index.d.mts +5 -5
- package/dist/{server → http}/fastify/index.d.ts +5 -5
- package/dist/{server → http}/fastify/index.js +72 -72
- package/dist/{server → http}/fastify/index.mjs +47 -47
- package/dist/{server → http}/h3/index.d.mts +5 -5
- package/dist/{server → http}/h3/index.d.ts +5 -5
- package/dist/http/h3/index.js +160 -0
- package/dist/{server → http}/h3/index.mjs +68 -62
- package/dist/{server → http}/hono/index.d.mts +5 -5
- package/dist/{server → http}/hono/index.d.ts +5 -5
- package/dist/{server → http}/hono/index.js +69 -54
- package/dist/{server → http}/hono/index.mjs +41 -26
- package/dist/{server → http}/hyper-express/index.d.mts +5 -5
- package/dist/{server → http}/hyper-express/index.d.ts +5 -5
- package/dist/{server → http}/hyper-express/index.js +69 -56
- package/dist/{server → http}/hyper-express/index.mjs +41 -28
- package/dist/{server → http}/koa/index.d.mts +5 -5
- package/dist/{server → http}/koa/index.d.ts +5 -5
- package/dist/{server → http}/koa/index.js +71 -55
- package/dist/{server → http}/koa/index.mjs +42 -26
- package/dist/index.d.mts +53 -41
- package/dist/index.d.ts +53 -41
- package/dist/index.js +62 -78
- package/dist/index.mjs +46 -62
- package/dist/{meta-KtfiBIde.d.ts → meta-BXKLFTgG.d.mts} +2 -3
- package/dist/{meta-KtfiBIde.d.mts → meta-BXKLFTgG.d.ts} +2 -3
- package/dist/rpc/bullmq/index.d.mts +6 -6
- package/dist/rpc/bullmq/index.d.ts +6 -6
- package/dist/rpc/bullmq/index.js +24 -24
- package/dist/rpc/bullmq/index.mjs +14 -14
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +25 -21
- package/dist/rpc/kafka/index.mjs +15 -11
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +22 -21
- package/dist/rpc/nats/index.mjs +13 -12
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +23 -22
- package/dist/rpc/rabbitmq/index.mjs +12 -11
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +24 -20
- package/dist/rpc/redis/index.mjs +15 -11
- 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-JVT0mgLD.d.ts → types-BtbL49Zs.d.mts} +2 -1
- package/dist/{types-DIw7B6Up.d.ts → types-VFzEM7LL.d.ts} +5 -5
- package/dist/{types-BvD3B5Ny.d.mts → types-h40T3cRG.d.mts} +5 -5
- package/dist/{types-t9D1fU6G.d.mts → types-m3IEDKjP.d.ts} +2 -1
- package/package.json +24 -24
- package/dist/chunk-7SYPUIBY.js +0 -539
- package/dist/chunk-LYEZ6RGX.js +0 -237
- package/dist/core-2SNw8m2B.d.mts +0 -30
- package/dist/core-BmJJLUqj.d.ts +0 -30
- package/dist/server/h3/index.js +0 -154
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
|
|
5
5
|
"author": "fgsreally",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,32 +26,32 @@
|
|
|
26
26
|
"import": "./dist/test.mjs"
|
|
27
27
|
},
|
|
28
28
|
"./h3": {
|
|
29
|
-
"require": "./dist/
|
|
30
|
-
"import": "./dist/
|
|
29
|
+
"require": "./dist/http/h3/index.js",
|
|
30
|
+
"import": "./dist/http/h3/index.mjs"
|
|
31
31
|
},
|
|
32
32
|
"./express": {
|
|
33
|
-
"require": "./dist/
|
|
34
|
-
"import": "./dist/
|
|
33
|
+
"require": "./dist/http/express/index.js",
|
|
34
|
+
"import": "./dist/http/express/index.mjs"
|
|
35
35
|
},
|
|
36
36
|
"./koa": {
|
|
37
|
-
"require": "./dist/
|
|
38
|
-
"import": "./dist/
|
|
37
|
+
"require": "./dist/http/koa/index.js",
|
|
38
|
+
"import": "./dist/http/koa/index.mjs"
|
|
39
39
|
},
|
|
40
40
|
"./fastify": {
|
|
41
|
-
"require": "./dist/
|
|
42
|
-
"import": "./dist/
|
|
41
|
+
"require": "./dist/http/fastify/index.js",
|
|
42
|
+
"import": "./dist/http/fastify/index.mjs"
|
|
43
43
|
},
|
|
44
44
|
"./hyper-express": {
|
|
45
|
-
"require": "./dist/
|
|
46
|
-
"import": "./dist/
|
|
45
|
+
"require": "./dist/http/hyper-express/index.js",
|
|
46
|
+
"import": "./dist/http/hyper-express/index.mjs"
|
|
47
47
|
},
|
|
48
48
|
"./hono": {
|
|
49
|
-
"require": "./dist/
|
|
50
|
-
"import": "./dist/
|
|
49
|
+
"require": "./dist/http/hono/index.js",
|
|
50
|
+
"import": "./dist/http/hono/index.mjs"
|
|
51
51
|
},
|
|
52
52
|
"./elysia": {
|
|
53
|
-
"require": "./dist/
|
|
54
|
-
"import": "./dist/
|
|
53
|
+
"require": "./dist/http/elysia/index.js",
|
|
54
|
+
"import": "./dist/http/elysia/index.mjs"
|
|
55
55
|
},
|
|
56
56
|
"./redis": {
|
|
57
57
|
"require": "./dist/rpc/redis/index.js",
|
|
@@ -91,25 +91,25 @@
|
|
|
91
91
|
"dist/helper.d.ts"
|
|
92
92
|
],
|
|
93
93
|
"h3": [
|
|
94
|
-
"dist/
|
|
94
|
+
"dist/http/h3/index.d.ts"
|
|
95
95
|
],
|
|
96
96
|
"express": [
|
|
97
|
-
"dist/
|
|
97
|
+
"dist/http/express/index.d.ts"
|
|
98
98
|
],
|
|
99
99
|
"koa": [
|
|
100
|
-
"dist/
|
|
100
|
+
"dist/http/koa/index.d.ts"
|
|
101
101
|
],
|
|
102
102
|
"fastify": [
|
|
103
|
-
"dist/
|
|
103
|
+
"dist/http/fastify/index.d.ts"
|
|
104
104
|
],
|
|
105
105
|
"hyper-express": [
|
|
106
|
-
"dist/
|
|
106
|
+
"dist/http/hyper-express/index.d.ts"
|
|
107
107
|
],
|
|
108
108
|
"hono": [
|
|
109
|
-
"dist/
|
|
109
|
+
"dist/http/hono/index.d.ts"
|
|
110
110
|
],
|
|
111
111
|
"elysia": [
|
|
112
|
-
"dist/
|
|
112
|
+
"dist/http/elysia/index.d.ts"
|
|
113
113
|
],
|
|
114
114
|
"redis": [
|
|
115
115
|
"dist/rpc/redis/index.d.ts"
|
|
@@ -143,10 +143,11 @@
|
|
|
143
143
|
"chokidar": "^3.5.3",
|
|
144
144
|
"debug": "^4.3.4",
|
|
145
145
|
"fs-extra": "^11.2.0",
|
|
146
|
+
"h3": "^1.12.0",
|
|
146
147
|
"picocolors": "^1.0.0",
|
|
147
148
|
"reflect-metadata": "^0.1.13",
|
|
148
149
|
"ts-mixer": "^6.0.4",
|
|
149
|
-
"phecda-core": "4.0.
|
|
150
|
+
"phecda-core": "4.0.1"
|
|
150
151
|
},
|
|
151
152
|
"devDependencies": {
|
|
152
153
|
"@koa/router": "^12.0.1",
|
|
@@ -163,7 +164,6 @@
|
|
|
163
164
|
"elysia": "^1.0.17",
|
|
164
165
|
"express": "^4.18.2",
|
|
165
166
|
"fastify": "^4.25.1",
|
|
166
|
-
"h3": "^1.11.1",
|
|
167
167
|
"hono": "^4.3.4",
|
|
168
168
|
"hyper-express": "^6.15.2",
|
|
169
169
|
"ioredis": "^5.3.2",
|
package/dist/chunk-7SYPUIBY.js
DELETED
|
@@ -1,539 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkGHFSIZUOjs = require('./chunk-GHFSIZUO.js');
|
|
9
|
-
|
|
10
|
-
// src/helper.ts
|
|
11
|
-
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
12
|
-
|
|
13
|
-
// src/context.ts
|
|
14
|
-
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
15
|
-
|
|
16
|
-
// src/pipe.ts
|
|
17
|
-
var defaultPipe = /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, ({ arg }) => {
|
|
18
|
-
return arg;
|
|
19
|
-
}, "defaultPipe");
|
|
20
|
-
|
|
21
|
-
// src/exception/base.ts
|
|
22
|
-
var Exception = class extends Error {
|
|
23
|
-
static {
|
|
24
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "Exception");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
constructor(message, status = 0, description = "Exception") {
|
|
30
|
-
super(message), this.message = message, this.status = status, this.description = description;
|
|
31
|
-
}
|
|
32
|
-
get data() {
|
|
33
|
-
return {
|
|
34
|
-
message: this.message,
|
|
35
|
-
description: this.description,
|
|
36
|
-
status: this.status,
|
|
37
|
-
[_chunkGHFSIZUOjs.ERROR_SYMBOL]: true
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// src/exception/undefine.ts
|
|
43
|
-
var UndefinedException = class extends Exception {
|
|
44
|
-
static {
|
|
45
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "UndefinedException");
|
|
46
|
-
}
|
|
47
|
-
constructor(message) {
|
|
48
|
-
super(message, 500, "Undefined error");
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// src/exception/validate.ts
|
|
53
|
-
var ValidateException = class extends Exception {
|
|
54
|
-
static {
|
|
55
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "ValidateException");
|
|
56
|
-
}
|
|
57
|
-
constructor(message) {
|
|
58
|
-
super(message, 400, "Validate exception");
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// src/exception/forbidden.ts
|
|
63
|
-
var ForbiddenException = class extends Exception {
|
|
64
|
-
static {
|
|
65
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "ForbiddenException");
|
|
66
|
-
}
|
|
67
|
-
constructor(message) {
|
|
68
|
-
super(message, 403, "Forbidden resource");
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// src/exception/bad-request.ts
|
|
73
|
-
var BadRequestException = class extends Exception {
|
|
74
|
-
static {
|
|
75
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "BadRequestException");
|
|
76
|
-
}
|
|
77
|
-
constructor(message) {
|
|
78
|
-
super(message, 400, "Bad Request");
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// src/exception/not-found.ts
|
|
83
|
-
var NotFoundException = class extends Exception {
|
|
84
|
-
static {
|
|
85
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "NotFoundException");
|
|
86
|
-
}
|
|
87
|
-
constructor(message) {
|
|
88
|
-
super(message, 404, "Not Found");
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// src/exception/conflict.ts
|
|
93
|
-
var ConflictException = class extends Exception {
|
|
94
|
-
static {
|
|
95
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "ConflictException");
|
|
96
|
-
}
|
|
97
|
-
constructor(message) {
|
|
98
|
-
super(message, 409, "Conflict");
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// src/exception/bad-gateway.ts
|
|
103
|
-
var BadGatewayException = class extends Exception {
|
|
104
|
-
static {
|
|
105
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "BadGatewayException");
|
|
106
|
-
}
|
|
107
|
-
constructor(message) {
|
|
108
|
-
super(message, 502, "Bad Gatrway");
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
// src/exception/invalid-input.ts
|
|
113
|
-
var InvalidInputException = class extends Exception {
|
|
114
|
-
static {
|
|
115
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "InvalidInputException");
|
|
116
|
-
}
|
|
117
|
-
constructor(message) {
|
|
118
|
-
super(message, 502, "Invalid Input");
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
// src/exception/media-type.ts
|
|
123
|
-
var UnsupportedMediaTypeException = class extends Exception {
|
|
124
|
-
static {
|
|
125
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "UnsupportedMediaTypeException");
|
|
126
|
-
}
|
|
127
|
-
constructor(message) {
|
|
128
|
-
super(message, 415, "Unsupported Media Type");
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// src/exception/payload-large.ts
|
|
133
|
-
var PayloadLargeException = class extends Exception {
|
|
134
|
-
static {
|
|
135
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "PayloadLargeException");
|
|
136
|
-
}
|
|
137
|
-
constructor(message) {
|
|
138
|
-
super(message, 413, "Payload Too Large");
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
// src/exception/timeout.ts
|
|
143
|
-
var TimeoutException = class extends Exception {
|
|
144
|
-
static {
|
|
145
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "TimeoutException");
|
|
146
|
-
}
|
|
147
|
-
constructor(message) {
|
|
148
|
-
super(message, 408, "Request Timeout");
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
// src/exception/unauthorized.ts
|
|
153
|
-
var UnauthorizedException = class extends Exception {
|
|
154
|
-
static {
|
|
155
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "UnauthorizedException");
|
|
156
|
-
}
|
|
157
|
-
constructor(message) {
|
|
158
|
-
super(message, 401, "Unauthorized");
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
// src/exception/unavailable-service.ts
|
|
163
|
-
var ServiceUnavailableException = class extends Exception {
|
|
164
|
-
static {
|
|
165
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "ServiceUnavailableException");
|
|
166
|
-
}
|
|
167
|
-
constructor(message) {
|
|
168
|
-
super(message, 503, "Service Unavailable");
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// src/exception/framework.ts
|
|
173
|
-
var FrameworkException = class extends Exception {
|
|
174
|
-
static {
|
|
175
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "FrameworkException");
|
|
176
|
-
}
|
|
177
|
-
constructor(message) {
|
|
178
|
-
super(`[phecda-server] ${message}`, 500, "Framework Error");
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
// src/exception/timer.ts
|
|
183
|
-
var TimerException = class extends Exception {
|
|
184
|
-
static {
|
|
185
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "TimerException");
|
|
186
|
-
}
|
|
187
|
-
constructor(message) {
|
|
188
|
-
super(message, 0, "Timer Error");
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
// src/exception/worker.ts
|
|
193
|
-
var WorkerException = class extends Exception {
|
|
194
|
-
static {
|
|
195
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "WorkerException");
|
|
196
|
-
}
|
|
197
|
-
constructor(message) {
|
|
198
|
-
super(message, 0, "Worker Error");
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
// src/filter.ts
|
|
203
|
-
var defaultFilter = /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (e) => {
|
|
204
|
-
if (!(e instanceof Exception)) {
|
|
205
|
-
_chunkGHFSIZUOjs.log.call(void 0, e.message, "error");
|
|
206
|
-
if (_chunkGHFSIZUOjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
207
|
-
e = new UndefinedException(e.message || e);
|
|
208
|
-
} else {
|
|
209
|
-
_chunkGHFSIZUOjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
|
|
210
|
-
if (_chunkGHFSIZUOjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
211
|
-
}
|
|
212
|
-
return e.data;
|
|
213
|
-
}, "defaultFilter");
|
|
214
|
-
|
|
215
|
-
// src/context.ts
|
|
216
|
-
var debug = _debug2.default.call(void 0, "phecda-server(Context)");
|
|
217
|
-
var Context = (_class = class _Context {
|
|
218
|
-
static {
|
|
219
|
-
_chunkGHFSIZUOjs.__name.call(void 0, this, "Context");
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
static __initStatic() {this.filterRecord = {
|
|
225
|
-
default: defaultFilter
|
|
226
|
-
}}
|
|
227
|
-
static __initStatic2() {this.pipeRecord = {
|
|
228
|
-
default: defaultPipe
|
|
229
|
-
}}
|
|
230
|
-
static __initStatic3() {this.guardRecord = {}}
|
|
231
|
-
static __initStatic4() {this.interceptorRecord = {}}
|
|
232
|
-
static __initStatic5() {this.pluginRecord = {}}
|
|
233
|
-
|
|
234
|
-
constructor(data) {
|
|
235
|
-
this.data = data;
|
|
236
|
-
if (_chunkGHFSIZUOjs.IS_HMR)
|
|
237
|
-
data._context = this;
|
|
238
|
-
}
|
|
239
|
-
async run(opts, successCb, failCb) {
|
|
240
|
-
const { meta, moduleMap } = this.data;
|
|
241
|
-
const { globalGuards = [], globalFilter, globalInterceptors = [], globalPipe } = opts;
|
|
242
|
-
const { paramsType, data: { guards, interceptors, params, tag, func, ctxs, filter } } = meta;
|
|
243
|
-
try {
|
|
244
|
-
await this.useGuard([
|
|
245
|
-
...globalGuards,
|
|
246
|
-
...guards
|
|
247
|
-
]);
|
|
248
|
-
const i1 = await this.useInterceptor([
|
|
249
|
-
...globalInterceptors,
|
|
250
|
-
...interceptors
|
|
251
|
-
]);
|
|
252
|
-
if (i1 !== void 0) return successCb(i1);
|
|
253
|
-
const args = await this.usePipe(params.map((param) => {
|
|
254
|
-
return {
|
|
255
|
-
arg: resolveDep(this.data[param.type], param.key),
|
|
256
|
-
reflect: paramsType[param.index],
|
|
257
|
-
...param,
|
|
258
|
-
pipe: param.pipe || globalPipe
|
|
259
|
-
};
|
|
260
|
-
}));
|
|
261
|
-
const instance = moduleMap.get(tag);
|
|
262
|
-
if (ctxs) {
|
|
263
|
-
ctxs.forEach((ctx) => instance[ctx] = this.data);
|
|
264
|
-
}
|
|
265
|
-
const returnData = await instance[func](...args);
|
|
266
|
-
const i2 = await this.usePostInterceptor(returnData);
|
|
267
|
-
if (i2 !== void 0) return successCb(i2);
|
|
268
|
-
return successCb(returnData);
|
|
269
|
-
} catch (e) {
|
|
270
|
-
const err = await this.useFilter(e, filter || globalFilter);
|
|
271
|
-
return failCb(err);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
usePipe(args) {
|
|
275
|
-
return Promise.all(args.map((item) => {
|
|
276
|
-
if (item.pipe && !_Context.pipeRecord[item.pipe]) {
|
|
277
|
-
if (_chunkGHFSIZUOjs.IS_STRICT) {
|
|
278
|
-
throw new FrameworkException(`can't find pipe named '${item.pipe}'`);
|
|
279
|
-
} else {
|
|
280
|
-
debug(`Can't find pipe named "${item.pipe}" when handling the ${item.index + 1}th argument of the func "${this.data.func}" on module "${this.data.tag}",use default pipe instead`);
|
|
281
|
-
return _Context.pipeRecord.default(item, this.data);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return _Context.pipeRecord[item.pipe || "default"](item, this.data);
|
|
285
|
-
}));
|
|
286
|
-
}
|
|
287
|
-
useFilter(arg, filter = "default") {
|
|
288
|
-
if (!_Context.filterRecord[filter]) {
|
|
289
|
-
if (_chunkGHFSIZUOjs.IS_STRICT) {
|
|
290
|
-
throw new FrameworkException(`can't find filter named "${filter}"`);
|
|
291
|
-
} else {
|
|
292
|
-
debug(`Can't find filter named "${filter}" when handling func "${this.data.func}" on module "${this.data.tag}",use default filter instead`);
|
|
293
|
-
return _Context.filterRecord.default(arg, this.data);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
return _Context.filterRecord[filter](arg, this.data);
|
|
297
|
-
}
|
|
298
|
-
async useGuard(guards) {
|
|
299
|
-
for (const guard of new Set(guards)) {
|
|
300
|
-
if (!(guard in _Context.guardRecord)) {
|
|
301
|
-
if (_chunkGHFSIZUOjs.IS_STRICT) throw new FrameworkException(`Can't find guard named "${guard}"`);
|
|
302
|
-
else debug(`Can't find guard named "${guard}" when handling func "${this.data.func}" on module "${this.data.tag}",skip it`);
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
|
-
if (!await _Context.guardRecord[guard](this.data)) throw new ForbiddenException(`Guard exception--[${guard}]`);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
async usePostInterceptor(data) {
|
|
309
|
-
for (const cb of this.postInterceptors) {
|
|
310
|
-
const ret = await cb(data);
|
|
311
|
-
if (ret !== void 0) return ret;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
async useInterceptor(interceptors) {
|
|
315
|
-
const cb = [];
|
|
316
|
-
for (const interceptor of new Set(interceptors)) {
|
|
317
|
-
if (!(interceptor in _Context.interceptorRecord)) {
|
|
318
|
-
if (_chunkGHFSIZUOjs.IS_STRICT) throw new FrameworkException(`can't find interceptor named "${interceptor}"`);
|
|
319
|
-
else debug(`Can't find interceptor named "${interceptor}" when handling func "${this.data.func}" on module "${this.data.tag}",skip it`);
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
const interceptRet = await _Context.interceptorRecord[interceptor](this.data);
|
|
323
|
-
if (interceptRet !== void 0) {
|
|
324
|
-
if (typeof interceptRet === "function") cb.push(interceptRet);
|
|
325
|
-
else return interceptRet;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
this.postInterceptors = cb;
|
|
329
|
-
}
|
|
330
|
-
static usePlugin(plugins, framework) {
|
|
331
|
-
const ret = [];
|
|
332
|
-
for (const m of new Set(plugins)) {
|
|
333
|
-
if (!(m in _Context.pluginRecord)) {
|
|
334
|
-
if (_chunkGHFSIZUOjs.IS_STRICT) throw new FrameworkException(`can't find middleware named '${m}'`);
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
const plugin = _Context.pluginRecord[m](framework);
|
|
338
|
-
plugin && ret.push(plugin);
|
|
339
|
-
}
|
|
340
|
-
return ret;
|
|
341
|
-
}
|
|
342
|
-
}, _class.__initStatic(), _class.__initStatic2(), _class.__initStatic3(), _class.__initStatic4(), _class.__initStatic5(), _class);
|
|
343
|
-
function addPlugin(key, handler) {
|
|
344
|
-
if (Context.pluginRecord[key] && Context.pluginRecord[key] !== handler) _chunkGHFSIZUOjs.log.call(void 0, `overwrite Plugin "${String(key)}"`, "warn");
|
|
345
|
-
Context.pluginRecord[key] = handler;
|
|
346
|
-
}
|
|
347
|
-
_chunkGHFSIZUOjs.__name.call(void 0, addPlugin, "addPlugin");
|
|
348
|
-
function addPipe(key, handler) {
|
|
349
|
-
if (Context.pipeRecord[key] && Context.pipeRecord[key] !== handler) _chunkGHFSIZUOjs.log.call(void 0, `overwrite Pipe "${String(key)}"`, "warn");
|
|
350
|
-
Context.pipeRecord[key] = handler;
|
|
351
|
-
}
|
|
352
|
-
_chunkGHFSIZUOjs.__name.call(void 0, addPipe, "addPipe");
|
|
353
|
-
function addFilter(key, handler) {
|
|
354
|
-
if (Context.filterRecord[key] && Context.filterRecord[key] !== handler) _chunkGHFSIZUOjs.log.call(void 0, `overwrite Filter "${String(key)}"`, "warn");
|
|
355
|
-
Context.filterRecord[key] = handler;
|
|
356
|
-
}
|
|
357
|
-
_chunkGHFSIZUOjs.__name.call(void 0, addFilter, "addFilter");
|
|
358
|
-
function addGuard(key, handler) {
|
|
359
|
-
if (Context.guardRecord[key] && Context.guardRecord[key] !== handler) _chunkGHFSIZUOjs.log.call(void 0, `overwrite Guard "${String(key)}"`, "warn");
|
|
360
|
-
Context.guardRecord[key] = handler;
|
|
361
|
-
}
|
|
362
|
-
_chunkGHFSIZUOjs.__name.call(void 0, addGuard, "addGuard");
|
|
363
|
-
function addInterceptor(key, handler) {
|
|
364
|
-
if (Context.interceptorRecord[key] && Context.interceptorRecord[key] !== handler) _chunkGHFSIZUOjs.log.call(void 0, `overwrite Interceptor "${String(key)}"`, "warn");
|
|
365
|
-
Context.interceptorRecord[key] = handler;
|
|
366
|
-
}
|
|
367
|
-
_chunkGHFSIZUOjs.__name.call(void 0, addInterceptor, "addInterceptor");
|
|
368
|
-
|
|
369
|
-
// src/hmr.ts
|
|
370
|
-
function HMR(cb) {
|
|
371
|
-
if (_chunkGHFSIZUOjs.IS_HMR) _optionalChain([globalThis, 'access', _ => _.__PS_HMR__, 'optionalAccess', _2 => _2.push, 'call', _3 => _3(cb)]);
|
|
372
|
-
}
|
|
373
|
-
_chunkGHFSIZUOjs.__name.call(void 0, HMR, "HMR");
|
|
374
|
-
|
|
375
|
-
// src/server/helper.ts
|
|
376
|
-
function resolveDep(ret, key) {
|
|
377
|
-
if (key) return _optionalChain([ret, 'optionalAccess', _4 => _4[key]]);
|
|
378
|
-
return ret;
|
|
379
|
-
}
|
|
380
|
-
_chunkGHFSIZUOjs.__name.call(void 0, resolveDep, "resolveDep");
|
|
381
|
-
function argToReq(params, args, headers) {
|
|
382
|
-
const req = {
|
|
383
|
-
body: {},
|
|
384
|
-
query: {},
|
|
385
|
-
params: {},
|
|
386
|
-
headers
|
|
387
|
-
};
|
|
388
|
-
params.forEach((param) => {
|
|
389
|
-
if (param.key) req[param.type][param.key] = args[param.index];
|
|
390
|
-
else req[param.type] = args[param.index];
|
|
391
|
-
});
|
|
392
|
-
return req;
|
|
393
|
-
}
|
|
394
|
-
_chunkGHFSIZUOjs.__name.call(void 0, argToReq, "argToReq");
|
|
395
|
-
|
|
396
|
-
// src/rpc/helper.ts
|
|
397
|
-
var _os = require('os');
|
|
398
|
-
function genClientQueue(key) {
|
|
399
|
-
return `PS-${key ? `${key}-` : ""}${_os.hostname.call(void 0, )}-${process.pid}`;
|
|
400
|
-
}
|
|
401
|
-
_chunkGHFSIZUOjs.__name.call(void 0, genClientQueue, "genClientQueue");
|
|
402
|
-
|
|
403
|
-
// src/decorators/helper.ts
|
|
404
|
-
function shallowClone(obj) {
|
|
405
|
-
return {
|
|
406
|
-
...obj
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
_chunkGHFSIZUOjs.__name.call(void 0, shallowClone, "shallowClone");
|
|
410
|
-
function mergeObject(...args) {
|
|
411
|
-
return Object.assign({}, ...args);
|
|
412
|
-
}
|
|
413
|
-
_chunkGHFSIZUOjs.__name.call(void 0, mergeObject, "mergeObject");
|
|
414
|
-
|
|
415
|
-
// src/helper.ts
|
|
416
|
-
function createControllerMetaMap(meta, filter) {
|
|
417
|
-
const metaMap = /* @__PURE__ */ new Map();
|
|
418
|
-
function handleMeta() {
|
|
419
|
-
metaMap.clear();
|
|
420
|
-
for (const item of meta) {
|
|
421
|
-
const { tag, func } = item.data;
|
|
422
|
-
if (!filter(item)) continue;
|
|
423
|
-
if (metaMap.has(tag)) metaMap.get(tag)[func] = item;
|
|
424
|
-
else metaMap.set(tag, {
|
|
425
|
-
[func]: item
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
_chunkGHFSIZUOjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
430
|
-
handleMeta();
|
|
431
|
-
HMR(handleMeta);
|
|
432
|
-
return metaMap;
|
|
433
|
-
}
|
|
434
|
-
_chunkGHFSIZUOjs.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
|
|
435
|
-
function detectAopDep(meta, { guards, interceptors, plugins } = {}, controller = "http") {
|
|
436
|
-
const pluginSet = /* @__PURE__ */ new Set();
|
|
437
|
-
const guardSet = /* @__PURE__ */ new Set();
|
|
438
|
-
const interceptorSet = /* @__PURE__ */ new Set();
|
|
439
|
-
const pipeSet = /* @__PURE__ */ new Set();
|
|
440
|
-
const filterSet = /* @__PURE__ */ new Set();
|
|
441
|
-
const warningSet = /* @__PURE__ */ new Set();
|
|
442
|
-
function handleMeta() {
|
|
443
|
-
pluginSet.clear();
|
|
444
|
-
guardSet.clear();
|
|
445
|
-
interceptorSet.clear();
|
|
446
|
-
pipeSet.clear();
|
|
447
|
-
filterSet.clear();
|
|
448
|
-
warningSet.clear();
|
|
449
|
-
_optionalChain([plugins, 'optionalAccess', _5 => _5.forEach, 'call', _6 => _6((item) => {
|
|
450
|
-
pluginSet.add(item);
|
|
451
|
-
})]);
|
|
452
|
-
_optionalChain([guards, 'optionalAccess', _7 => _7.forEach, 'call', _8 => _8((item) => {
|
|
453
|
-
guardSet.add(item);
|
|
454
|
-
})]);
|
|
455
|
-
_optionalChain([interceptors, 'optionalAccess', _9 => _9.forEach, 'call', _10 => _10((item) => {
|
|
456
|
-
interceptorSet.add(item);
|
|
457
|
-
})]);
|
|
458
|
-
meta.forEach(({ data }) => {
|
|
459
|
-
if (data.controller !== controller) {
|
|
460
|
-
if (data[controller]) warningSet.add(`Module "${data.tag === data.name ? data.name : `${data.name}(${data.tag})`}" should use ${controller} controller to decorate class or remove ${controller} decorator on method "${data.func}"`);
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
if (data.filter) filterSet.add(data.filter);
|
|
464
|
-
data.interceptors.forEach((i) => interceptorSet.add(i));
|
|
465
|
-
data.guards.forEach((i) => guardSet.add(i));
|
|
466
|
-
data.plugins.forEach((i) => pluginSet.add(i));
|
|
467
|
-
data.params.forEach((i) => {
|
|
468
|
-
if (i.pipe) pipeSet.add(i.pipe);
|
|
469
|
-
});
|
|
470
|
-
});
|
|
471
|
-
const missPlugins = [
|
|
472
|
-
...pluginSet
|
|
473
|
-
].filter((i) => !Context.pluginRecord[i]);
|
|
474
|
-
const missGuards = [
|
|
475
|
-
...guardSet
|
|
476
|
-
].filter((i) => !Context.guardRecord[i]);
|
|
477
|
-
const missInterceptors = [
|
|
478
|
-
...interceptorSet
|
|
479
|
-
].filter((i) => !Context.interceptorRecord[i]);
|
|
480
|
-
const missPipes = [
|
|
481
|
-
...pipeSet
|
|
482
|
-
].filter((i) => !Context.pipeRecord[i]);
|
|
483
|
-
const missFilters = [
|
|
484
|
-
...filterSet
|
|
485
|
-
].filter((i) => !Context.filterRecord[i]);
|
|
486
|
-
if (missPlugins.length) _chunkGHFSIZUOjs.log.call(void 0, `${_picocolors2.default.white(`Plugin [${missPlugins.join(",")}]`)} doesn't exist`, "warn");
|
|
487
|
-
if (missGuards.length) _chunkGHFSIZUOjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
|
|
488
|
-
if (missInterceptors.length) _chunkGHFSIZUOjs.log.call(void 0, `${_picocolors2.default.cyan(`Interceptor [${missInterceptors.join(",")}]`)} doesn't exist`, "warn");
|
|
489
|
-
if (missPipes.length) _chunkGHFSIZUOjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
|
|
490
|
-
if (missFilters.length) _chunkGHFSIZUOjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
|
|
491
|
-
warningSet.forEach((warn) => _chunkGHFSIZUOjs.log.call(void 0, warn, "warn"));
|
|
492
|
-
}
|
|
493
|
-
_chunkGHFSIZUOjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
494
|
-
handleMeta();
|
|
495
|
-
HMR(handleMeta);
|
|
496
|
-
return {
|
|
497
|
-
pluginSet,
|
|
498
|
-
guardSet,
|
|
499
|
-
interceptorSet,
|
|
500
|
-
pipeSet,
|
|
501
|
-
filterSet
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
_chunkGHFSIZUOjs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
exports.defaultPipe = defaultPipe; exports.Exception = Exception; exports.UndefinedException = UndefinedException; exports.ValidateException = ValidateException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.TimerException = TimerException; exports.WorkerException = WorkerException; exports.Context = Context; exports.addPlugin = addPlugin; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addInterceptor = addInterceptor; exports.HMR = HMR; exports.resolveDep = resolveDep; exports.argToReq = argToReq; exports.genClientQueue = genClientQueue; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep;
|