phecda-server 5.0.0-alpha.12 → 5.0.0-alpha.13
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-L5SFPHG6.mjs → chunk-BADPI5WG.mjs} +5 -5
- package/dist/{chunk-27WMBKFH.js → chunk-INPMEA67.js} +16 -20
- package/dist/{chunk-KOWUK5OV.js → chunk-MFCPWVO5.js} +5 -5
- package/dist/{chunk-UXPHQ7OT.mjs → chunk-Y7AOZMC2.mjs} +14 -18
- package/dist/{core-295348b7.d.ts → core-11dd822c.d.ts} +6 -4
- package/dist/index.d.ts +19 -18
- package/dist/index.js +36 -23
- package/dist/index.mjs +16 -3
- package/dist/rpc/kafka/index.d.ts +1 -1
- package/dist/rpc/kafka/index.js +4 -4
- package/dist/rpc/kafka/index.mjs +1 -1
- package/dist/rpc/rabbitmq/index.d.ts +1 -1
- package/dist/rpc/rabbitmq/index.js +4 -4
- package/dist/rpc/rabbitmq/index.mjs +1 -1
- package/dist/rpc/redis/index.d.ts +1 -1
- package/dist/rpc/redis/index.js +4 -4
- package/dist/rpc/redis/index.mjs +1 -1
- package/dist/server/express/index.d.ts +1 -1
- package/dist/server/express/index.js +10 -10
- package/dist/server/express/index.mjs +1 -1
- package/dist/server/fastify/index.d.ts +1 -1
- package/dist/server/fastify/index.js +11 -11
- package/dist/server/fastify/index.mjs +1 -1
- package/dist/server/h3/index.d.ts +1 -1
- package/dist/server/h3/index.js +10 -10
- package/dist/server/h3/index.mjs +1 -1
- package/dist/server/koa/index.d.ts +1 -1
- package/dist/server/koa/index.js +10 -10
- package/dist/server/koa/index.mjs +1 -1
- package/dist/test.d.ts +5 -4
- package/dist/test.js +42 -40
- package/dist/test.mjs +41 -39
- package/package.json +2 -2
package/dist/rpc/kafka/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkMFCPWVO5js = require('../../chunk-MFCPWVO5.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -23,7 +23,7 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
|
|
|
23
23
|
fromBeginning: true
|
|
24
24
|
});
|
|
25
25
|
function handleMeta() {
|
|
26
|
-
_chunkGWLM5DEJjs.IS_DEV &&
|
|
26
|
+
_chunkGWLM5DEJjs.IS_DEV && _chunkMFCPWVO5js.isAopDepInject.call(void 0, meta, {
|
|
27
27
|
guards: globalGuards,
|
|
28
28
|
interceptors: globalInterceptors
|
|
29
29
|
});
|
|
@@ -46,7 +46,7 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
|
|
|
46
46
|
messages: [
|
|
47
47
|
{
|
|
48
48
|
value: JSON.stringify({
|
|
49
|
-
data: new (0,
|
|
49
|
+
data: new (0, _chunkMFCPWVO5js.BadRequestException)(`service "${tag}" doesn't exist`).data,
|
|
50
50
|
error: true,
|
|
51
51
|
id
|
|
52
52
|
})
|
|
@@ -57,7 +57,7 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
|
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
const meta2 = metaMap.get(tag);
|
|
60
|
-
const context = new (0,
|
|
60
|
+
const context = new (0, _chunkMFCPWVO5js.Context)({
|
|
61
61
|
type: "kafka",
|
|
62
62
|
moduleMap,
|
|
63
63
|
meta: meta2,
|
package/dist/rpc/kafka/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkMFCPWVO5js = require('../../chunk-MFCPWVO5.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@ async function bind(ch, queue, { moduleMap, meta }, opts) {
|
|
|
14
14
|
const existQueue = /* @__PURE__ */ new Set();
|
|
15
15
|
const { globalGuards = [], globalInterceptors = [] } = opts || {};
|
|
16
16
|
function handleMeta() {
|
|
17
|
-
_chunkGWLM5DEJjs.IS_DEV &&
|
|
17
|
+
_chunkGWLM5DEJjs.IS_DEV && _chunkMFCPWVO5js.isAopDepInject.call(void 0, meta, {
|
|
18
18
|
guards: globalGuards,
|
|
19
19
|
interceptors: globalInterceptors
|
|
20
20
|
});
|
|
@@ -35,14 +35,14 @@ async function bind(ch, queue, { moduleMap, meta }, opts) {
|
|
|
35
35
|
await ch.assertQueue(queue2);
|
|
36
36
|
if (!metaMap.has(tag)) {
|
|
37
37
|
queue2 && ch.sendToQueue(queue2, Buffer.from(JSON.stringify({
|
|
38
|
-
data: new (0,
|
|
38
|
+
data: new (0, _chunkMFCPWVO5js.BadRequestException)(`service "${tag}" doesn't exist`).data,
|
|
39
39
|
error: true,
|
|
40
40
|
id
|
|
41
41
|
})));
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
const meta2 = metaMap.get(tag);
|
|
45
|
-
const context = new (0,
|
|
45
|
+
const context = new (0, _chunkMFCPWVO5js.Context)({
|
|
46
46
|
type: "rabbitmq",
|
|
47
47
|
moduleMap,
|
|
48
48
|
meta: meta2,
|
package/dist/rpc/redis/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkMFCPWVO5js = require('../../chunk-MFCPWVO5.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ function bind(redis, channel, { moduleMap, meta }, opts) {
|
|
|
15
15
|
const pub = new (0, _ioredis2.default)(redis.options);
|
|
16
16
|
const { globalGuards = [], globalInterceptors = [] } = opts || {};
|
|
17
17
|
function handleMeta() {
|
|
18
|
-
_chunkGWLM5DEJjs.IS_DEV &&
|
|
18
|
+
_chunkGWLM5DEJjs.IS_DEV && _chunkMFCPWVO5js.isAopDepInject.call(void 0, meta, {
|
|
19
19
|
guards: globalGuards,
|
|
20
20
|
interceptors: globalInterceptors
|
|
21
21
|
});
|
|
@@ -34,14 +34,14 @@ function bind(redis, channel, { moduleMap, meta }, opts) {
|
|
|
34
34
|
const { tag, args, id, queue } = data;
|
|
35
35
|
if (!metaMap.has(tag)) {
|
|
36
36
|
queue && pub.publish(queue, JSON.stringify({
|
|
37
|
-
data: new (0,
|
|
37
|
+
data: new (0, _chunkMFCPWVO5js.BadRequestException)(`service "${tag}" doesn't exist`).data,
|
|
38
38
|
error: true,
|
|
39
39
|
id
|
|
40
40
|
}));
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
const meta2 = metaMap.get(tag);
|
|
44
|
-
const context = new (0,
|
|
44
|
+
const context = new (0, _chunkMFCPWVO5js.Context)({
|
|
45
45
|
type: "redis",
|
|
46
46
|
moduleMap,
|
|
47
47
|
redis,
|
package/dist/rpc/redis/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ var _chunkSSZS3GSQjs = require('../../chunk-SSZS3GSQ.js');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkMFCPWVO5js = require('../../chunk-MFCPWVO5.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -24,7 +24,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
24
24
|
plugins: [],
|
|
25
25
|
...options
|
|
26
26
|
};
|
|
27
|
-
_chunkGWLM5DEJjs.IS_DEV &&
|
|
27
|
+
_chunkGWLM5DEJjs.IS_DEV && _chunkMFCPWVO5js.isAopDepInject.call(void 0, meta, {
|
|
28
28
|
plugins,
|
|
29
29
|
guards: globalGuards,
|
|
30
30
|
interceptors: globalInterceptors
|
|
@@ -51,22 +51,22 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
51
51
|
req[_chunkGWLM5DEJjs.MODULE_SYMBOL] = moduleMap;
|
|
52
52
|
req[_chunkGWLM5DEJjs.META_SYMBOL] = meta;
|
|
53
53
|
next();
|
|
54
|
-
}, ...
|
|
54
|
+
}, ..._chunkMFCPWVO5js.Context.usePlugin(plugins), async (req, res) => {
|
|
55
55
|
const { body } = req;
|
|
56
56
|
async function errorHandler(e) {
|
|
57
|
-
const error = await
|
|
57
|
+
const error = await _chunkMFCPWVO5js.Context.filterRecord.default(e);
|
|
58
58
|
return res.status(error.status).json(error);
|
|
59
59
|
}
|
|
60
60
|
_chunkGWLM5DEJjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
61
61
|
if (!Array.isArray(body))
|
|
62
|
-
return errorHandler(new (0,
|
|
62
|
+
return errorHandler(new (0, _chunkMFCPWVO5js.BadRequestException)("data format should be an array"));
|
|
63
63
|
try {
|
|
64
64
|
return Promise.all(body.map((item) => {
|
|
65
65
|
return new Promise(async (resolve) => {
|
|
66
66
|
const { tag } = item;
|
|
67
67
|
const meta2 = metaMap.get(tag);
|
|
68
68
|
if (!meta2)
|
|
69
|
-
return resolve(await
|
|
69
|
+
return resolve(await _chunkMFCPWVO5js.Context.filterRecord.default(new (0, _chunkMFCPWVO5js.BadRequestException)(`"${tag}" doesn't exist`)));
|
|
70
70
|
const contextData = {
|
|
71
71
|
type: "express",
|
|
72
72
|
request: req,
|
|
@@ -76,7 +76,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
76
76
|
parallel: true,
|
|
77
77
|
tag
|
|
78
78
|
};
|
|
79
|
-
const context = new (0,
|
|
79
|
+
const context = new (0, _chunkMFCPWVO5js.Context)(contextData);
|
|
80
80
|
const [name, method] = tag.split("-");
|
|
81
81
|
const { paramsType, handlers, data: { params, guards, interceptors, filter } } = meta2;
|
|
82
82
|
const instance = moduleMap.get(name);
|
|
@@ -127,7 +127,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
127
127
|
req[_chunkGWLM5DEJjs.MODULE_SYMBOL] = moduleMap;
|
|
128
128
|
req[_chunkGWLM5DEJjs.META_SYMBOL] = meta;
|
|
129
129
|
next();
|
|
130
|
-
}, ...
|
|
130
|
+
}, ..._chunkMFCPWVO5js.Context.usePlugin(plugins2), async (req, res) => {
|
|
131
131
|
const instance = moduleMap.get(tag);
|
|
132
132
|
const contextData = {
|
|
133
133
|
type: "express",
|
|
@@ -138,7 +138,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
138
138
|
parallel: false,
|
|
139
139
|
tag: methodTag
|
|
140
140
|
};
|
|
141
|
-
const context = new (0,
|
|
141
|
+
const context = new (0, _chunkMFCPWVO5js.Context)(contextData);
|
|
142
142
|
try {
|
|
143
143
|
for (const name in header)
|
|
144
144
|
res.set(name, header[name]);
|
|
@@ -192,7 +192,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
192
192
|
createRoute();
|
|
193
193
|
if (_chunkGWLM5DEJjs.IS_DEV) {
|
|
194
194
|
_optionalChain([globalThis, 'access', _7 => _7.__PS_HMR__, 'optionalAccess', _8 => _8.push, 'call', _9 => _9(async () => {
|
|
195
|
-
|
|
195
|
+
_chunkMFCPWVO5js.isAopDepInject.call(void 0, meta, {
|
|
196
196
|
plugins,
|
|
197
197
|
guards: globalGuards,
|
|
198
198
|
interceptors: globalInterceptors
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback } from 'fastify';
|
|
2
|
-
import { P, F as Factory } from '../../core-
|
|
2
|
+
import { P, F as Factory } from '../../core-11dd822c.js';
|
|
3
3
|
import 'phecda-core';
|
|
4
4
|
|
|
5
5
|
interface FastifyCtx extends P.BaseContext {
|
|
@@ -5,7 +5,7 @@ var _chunkSSZS3GSQjs = require('../../chunk-SSZS3GSQ.js');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkMFCPWVO5js = require('../../chunk-MFCPWVO5.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -27,7 +27,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
27
27
|
moduleMap,
|
|
28
28
|
meta
|
|
29
29
|
};
|
|
30
|
-
_chunkGWLM5DEJjs.IS_DEV &&
|
|
30
|
+
_chunkGWLM5DEJjs.IS_DEV && _chunkMFCPWVO5js.isAopDepInject.call(void 0, meta, {
|
|
31
31
|
plugins,
|
|
32
32
|
guards: globalGuards,
|
|
33
33
|
interceptors: globalInterceptors
|
|
@@ -52,7 +52,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
52
52
|
};
|
|
53
53
|
fastify.register((fastify2, _opts, done2) => {
|
|
54
54
|
plugins.forEach((p) => {
|
|
55
|
-
const plugin =
|
|
55
|
+
const plugin = _chunkMFCPWVO5js.Context.usePlugin([
|
|
56
56
|
p
|
|
57
57
|
])[0];
|
|
58
58
|
if (plugin) {
|
|
@@ -63,19 +63,19 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
63
63
|
fastify2.post(route, async (req, res) => {
|
|
64
64
|
const { body } = req;
|
|
65
65
|
async function errorHandler(e) {
|
|
66
|
-
const error = await
|
|
66
|
+
const error = await _chunkMFCPWVO5js.Context.filterRecord.default(e);
|
|
67
67
|
return res.status(error.status).send(error);
|
|
68
68
|
}
|
|
69
69
|
_chunkGWLM5DEJjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
70
70
|
if (!Array.isArray(body))
|
|
71
|
-
return errorHandler(new (0,
|
|
71
|
+
return errorHandler(new (0, _chunkMFCPWVO5js.BadRequestException)("data format should be an array"));
|
|
72
72
|
try {
|
|
73
73
|
return Promise.all(body.map((item) => {
|
|
74
74
|
return new Promise(async (resolve) => {
|
|
75
75
|
const { tag } = item;
|
|
76
76
|
const meta2 = metaMap.get(tag);
|
|
77
77
|
if (!meta2)
|
|
78
|
-
return resolve(await
|
|
78
|
+
return resolve(await _chunkMFCPWVO5js.Context.filterRecord.default(new (0, _chunkMFCPWVO5js.BadRequestException)(`"${tag}" doesn't exist`)));
|
|
79
79
|
const contextData = {
|
|
80
80
|
type: "fastify",
|
|
81
81
|
request: req,
|
|
@@ -85,13 +85,13 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
85
85
|
parallel: true,
|
|
86
86
|
tag
|
|
87
87
|
};
|
|
88
|
-
const context = new (0,
|
|
88
|
+
const context = new (0, _chunkMFCPWVO5js.Context)(contextData);
|
|
89
89
|
const [name, method] = tag.split("-");
|
|
90
90
|
const { paramsType, handlers, data: { params, guards, interceptors, filter } } = meta2;
|
|
91
91
|
const instance = moduleMap.get(name);
|
|
92
92
|
try {
|
|
93
93
|
if (!params)
|
|
94
|
-
throw new (0,
|
|
94
|
+
throw new (0, _chunkMFCPWVO5js.BadRequestException)(`"${tag}" doesn't exist`);
|
|
95
95
|
await context.useGuard([
|
|
96
96
|
...globalGuards,
|
|
97
97
|
...guards
|
|
@@ -137,7 +137,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
137
137
|
const methodTag = `${tag}-${method}`;
|
|
138
138
|
const { paramsType, handlers, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
|
|
139
139
|
fastify.register((fastify2, _opts, done2) => {
|
|
140
|
-
|
|
140
|
+
_chunkMFCPWVO5js.Context.usePlugin(plugins2).forEach((p) => {
|
|
141
141
|
p[Symbol.for("skip-override")] = true;
|
|
142
142
|
fastify2.register(p);
|
|
143
143
|
});
|
|
@@ -154,7 +154,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
154
154
|
parallel: false,
|
|
155
155
|
tag: methodTag
|
|
156
156
|
};
|
|
157
|
-
const context = new (0,
|
|
157
|
+
const context = new (0, _chunkMFCPWVO5js.Context)(contextData);
|
|
158
158
|
try {
|
|
159
159
|
for (const name in header)
|
|
160
160
|
res.header(name, header[name]);
|
|
@@ -199,7 +199,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
199
199
|
done();
|
|
200
200
|
if (_chunkGWLM5DEJjs.IS_DEV) {
|
|
201
201
|
_optionalChain([globalThis, 'access', _8 => _8.__PS_HMR__, 'optionalAccess', _9 => _9.push, 'call', _10 => _10(async () => {
|
|
202
|
-
|
|
202
|
+
_chunkMFCPWVO5js.isAopDepInject.call(void 0, meta, {
|
|
203
203
|
plugins,
|
|
204
204
|
guards: globalGuards,
|
|
205
205
|
interceptors: globalInterceptors
|
package/dist/server/h3/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var _chunkSSZS3GSQjs = require('../../chunk-SSZS3GSQ.js');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkMFCPWVO5js = require('../../chunk-MFCPWVO5.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -24,7 +24,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
|
|
|
24
24
|
plugins: [],
|
|
25
25
|
...options
|
|
26
26
|
};
|
|
27
|
-
_chunkGWLM5DEJjs.IS_DEV &&
|
|
27
|
+
_chunkGWLM5DEJjs.IS_DEV && _chunkMFCPWVO5js.isAopDepInject.call(void 0, meta, {
|
|
28
28
|
plugins,
|
|
29
29
|
guards: globalGuards,
|
|
30
30
|
interceptors: globalInterceptors
|
|
@@ -53,27 +53,27 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
|
|
|
53
53
|
router.post(route, _h3.eventHandler.call(void 0, {
|
|
54
54
|
onRequest: [
|
|
55
55
|
prePlugin,
|
|
56
|
-
...
|
|
56
|
+
..._chunkMFCPWVO5js.Context.usePlugin(plugins).map((p) => _h3.defineRequestMiddleware.call(void 0, p))
|
|
57
57
|
],
|
|
58
58
|
handler: async (event) => {
|
|
59
59
|
const body = await _h3.readBody.call(void 0, event, {
|
|
60
60
|
strict: true
|
|
61
61
|
});
|
|
62
62
|
async function errorHandler(e) {
|
|
63
|
-
const error = await
|
|
63
|
+
const error = await _chunkMFCPWVO5js.Context.filterRecord.default(e);
|
|
64
64
|
_h3.setResponseStatus.call(void 0, event, error.status);
|
|
65
65
|
return error;
|
|
66
66
|
}
|
|
67
67
|
_chunkGWLM5DEJjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
68
68
|
if (!Array.isArray(body))
|
|
69
|
-
return errorHandler(new (0,
|
|
69
|
+
return errorHandler(new (0, _chunkMFCPWVO5js.BadRequestException)("data format should be an array"));
|
|
70
70
|
try {
|
|
71
71
|
return Promise.all(body.map((item) => {
|
|
72
72
|
return new Promise(async (resolve) => {
|
|
73
73
|
const { tag } = item;
|
|
74
74
|
const meta2 = metaMap.get(tag);
|
|
75
75
|
if (!meta2)
|
|
76
|
-
return resolve(await
|
|
76
|
+
return resolve(await _chunkMFCPWVO5js.Context.filterRecord.default(new (0, _chunkMFCPWVO5js.BadRequestException)(`"${tag}" doesn't exist`)));
|
|
77
77
|
const contextData = {
|
|
78
78
|
type: "h3",
|
|
79
79
|
event,
|
|
@@ -82,7 +82,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
|
|
|
82
82
|
parallel: true,
|
|
83
83
|
tag
|
|
84
84
|
};
|
|
85
|
-
const context = new (0,
|
|
85
|
+
const context = new (0, _chunkMFCPWVO5js.Context)(contextData);
|
|
86
86
|
const [name, method] = tag.split("-");
|
|
87
87
|
const { paramsType, handlers, data: { params, guards, interceptors, filter } } = metaMap.get(tag);
|
|
88
88
|
const instance = moduleMap.get(name);
|
|
@@ -131,7 +131,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
|
|
|
131
131
|
router[http.type](http.route, _h3.eventHandler.call(void 0, {
|
|
132
132
|
onRequest: [
|
|
133
133
|
prePlugin,
|
|
134
|
-
...
|
|
134
|
+
..._chunkMFCPWVO5js.Context.usePlugin(plugins2).map((p) => _h3.defineRequestMiddleware.call(void 0, p))
|
|
135
135
|
],
|
|
136
136
|
handler: async (event) => {
|
|
137
137
|
const instance = moduleMap.get(tag);
|
|
@@ -143,7 +143,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
|
|
|
143
143
|
parallel: false,
|
|
144
144
|
tag: methodTag
|
|
145
145
|
};
|
|
146
|
-
const context = new (0,
|
|
146
|
+
const context = new (0, _chunkMFCPWVO5js.Context)(contextData);
|
|
147
147
|
try {
|
|
148
148
|
_h3.setHeaders.call(void 0, event, header);
|
|
149
149
|
await context.useGuard([
|
|
@@ -203,7 +203,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
|
|
|
203
203
|
createRoute();
|
|
204
204
|
if (_chunkGWLM5DEJjs.IS_DEV) {
|
|
205
205
|
_optionalChain([globalThis, 'access', _7 => _7.__PS_HMR__, 'optionalAccess', _8 => _8.push, 'call', _9 => _9(async () => {
|
|
206
|
-
|
|
206
|
+
_chunkMFCPWVO5js.isAopDepInject.call(void 0, meta, {
|
|
207
207
|
plugins,
|
|
208
208
|
guards: globalGuards,
|
|
209
209
|
interceptors: globalInterceptors
|
package/dist/server/h3/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
|
-
import { P, F as Factory } from '../../core-
|
|
3
|
+
import { P, F as Factory } from '../../core-11dd822c.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
5
|
|
|
6
6
|
interface KoaCtx extends P.BaseContext {
|
package/dist/server/koa/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var _chunkSSZS3GSQjs = require('../../chunk-SSZS3GSQ.js');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkMFCPWVO5js = require('../../chunk-MFCPWVO5.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -24,7 +24,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
24
24
|
plugins: [],
|
|
25
25
|
...options
|
|
26
26
|
};
|
|
27
|
-
_chunkGWLM5DEJjs.IS_DEV &&
|
|
27
|
+
_chunkGWLM5DEJjs.IS_DEV && _chunkMFCPWVO5js.isAopDepInject.call(void 0, meta, {
|
|
28
28
|
plugins,
|
|
29
29
|
guards: globalGuards,
|
|
30
30
|
interceptors: globalInterceptors
|
|
@@ -51,23 +51,23 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
51
51
|
ctx[_chunkGWLM5DEJjs.MODULE_SYMBOL] = moduleMap;
|
|
52
52
|
ctx[_chunkGWLM5DEJjs.META_SYMBOL] = meta;
|
|
53
53
|
await next();
|
|
54
|
-
}, ...
|
|
54
|
+
}, ..._chunkMFCPWVO5js.Context.usePlugin(plugins), async (ctx) => {
|
|
55
55
|
const { body } = ctx.request;
|
|
56
56
|
async function errorHandler(e) {
|
|
57
|
-
const error = await
|
|
57
|
+
const error = await _chunkMFCPWVO5js.Context.filterRecord.default(e);
|
|
58
58
|
ctx.status = error.status;
|
|
59
59
|
ctx.body = error;
|
|
60
60
|
}
|
|
61
61
|
_chunkGWLM5DEJjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
62
62
|
if (!Array.isArray(body))
|
|
63
|
-
return errorHandler(new (0,
|
|
63
|
+
return errorHandler(new (0, _chunkMFCPWVO5js.BadRequestException)("data format should be an array"));
|
|
64
64
|
try {
|
|
65
65
|
return Promise.all(body.map((item) => {
|
|
66
66
|
return new Promise(async (resolve) => {
|
|
67
67
|
const { tag } = item;
|
|
68
68
|
const meta2 = metaMap.get(tag);
|
|
69
69
|
if (!meta2)
|
|
70
|
-
return resolve(await
|
|
70
|
+
return resolve(await _chunkMFCPWVO5js.Context.filterRecord.default(new (0, _chunkMFCPWVO5js.BadRequestException)(`"${tag}" doesn't exist`)));
|
|
71
71
|
const contextData = {
|
|
72
72
|
type: "koa",
|
|
73
73
|
ctx,
|
|
@@ -76,7 +76,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
76
76
|
parallel: true,
|
|
77
77
|
tag
|
|
78
78
|
};
|
|
79
|
-
const context = new (0,
|
|
79
|
+
const context = new (0, _chunkMFCPWVO5js.Context)(contextData);
|
|
80
80
|
const [name, method] = tag.split("-");
|
|
81
81
|
const { paramsType, handlers, data: { params, guards, interceptors, filter } } = meta2;
|
|
82
82
|
const instance = moduleMap.get(name);
|
|
@@ -127,7 +127,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
127
127
|
ctx[_chunkGWLM5DEJjs.MODULE_SYMBOL] = moduleMap;
|
|
128
128
|
ctx[_chunkGWLM5DEJjs.META_SYMBOL] = meta;
|
|
129
129
|
await next();
|
|
130
|
-
}, ...
|
|
130
|
+
}, ..._chunkMFCPWVO5js.Context.usePlugin(plugins2), async (ctx) => {
|
|
131
131
|
const instance = moduleMap.get(tag);
|
|
132
132
|
const contextData = {
|
|
133
133
|
type: "koa",
|
|
@@ -137,7 +137,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
137
137
|
parallel: false,
|
|
138
138
|
tag: methodTag
|
|
139
139
|
};
|
|
140
|
-
const context = new (0,
|
|
140
|
+
const context = new (0, _chunkMFCPWVO5js.Context)(contextData);
|
|
141
141
|
try {
|
|
142
142
|
for (const name in header)
|
|
143
143
|
ctx.set(name, header[name]);
|
|
@@ -186,7 +186,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
186
186
|
createRoute();
|
|
187
187
|
if (_chunkGWLM5DEJjs.IS_DEV) {
|
|
188
188
|
_optionalChain([globalThis, 'access', _7 => _7.__PS_HMR__, 'optionalAccess', _8 => _8.push, 'call', _9 => _9(async () => {
|
|
189
|
-
|
|
189
|
+
_chunkMFCPWVO5js.isAopDepInject.call(void 0, meta, {
|
|
190
190
|
plugins,
|
|
191
191
|
guards: globalGuards,
|
|
192
192
|
interceptors: globalInterceptors
|
package/dist/test.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as supertest from 'supertest';
|
|
2
2
|
import { Test } from 'supertest';
|
|
3
|
+
import { Server } from 'node:http';
|
|
3
4
|
import { Construct } from 'phecda-core';
|
|
4
|
-
import { F as Factory, c as PickFunc } from './core-
|
|
5
|
+
import { F as Factory, c as PickFunc } from './core-11dd822c.js';
|
|
5
6
|
|
|
6
7
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
7
8
|
get<C extends T[number]>(Module: C): InstanceType<C>;
|
|
@@ -9,8 +10,8 @@ declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
|
9
10
|
type SuperTestRequest<T> = {
|
|
10
11
|
[K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;
|
|
11
12
|
};
|
|
12
|
-
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory
|
|
13
|
-
|
|
13
|
+
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "type" | "key" | "query" | "use" | "on" | "set" | "accept" | "auth" | "withCredentials" | "retry" | "ok" | "redirects" | "timeout" | "buffer" | "serialize" | "parse" | "ca" | "pfx" | "cert"> & {
|
|
14
|
+
module: <T extends Construct>(Module: T) => SuperTestRequest<PickFunc<InstanceType<T>>>;
|
|
14
15
|
}>;
|
|
15
16
|
|
|
16
17
|
export { SuperTestRequest, TestFactory, TestHttp };
|