phecda-server 5.0.0 → 5.0.1
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-5VMFQOJ7.mjs → chunk-AB4OX3WV.mjs} +13 -5
- package/dist/{chunk-VMXI3KFJ.js → chunk-BXLBWRHS.js} +12 -12
- package/dist/{chunk-C7MN5B36.mjs → chunk-W5EOVGQD.mjs} +1 -1
- package/dist/{chunk-5YYZLGGN.js → chunk-YERBWZCS.js} +13 -5
- package/dist/{core-eb646fe5.d.ts → core-fd134ffa.d.ts} +6 -15
- package/dist/helper-73e8d2f0.d.ts +18 -0
- package/dist/helper-f29f082f.d.ts +19 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +23 -23
- package/dist/index.mjs +2 -2
- package/dist/rpc/bullmq/index.d.ts +2 -3
- package/dist/rpc/bullmq/index.js +14 -17
- package/dist/rpc/bullmq/index.mjs +9 -12
- package/dist/rpc/kafka/index.d.ts +2 -3
- package/dist/rpc/kafka/index.js +14 -17
- package/dist/rpc/kafka/index.mjs +9 -12
- package/dist/rpc/nats/index.d.ts +2 -3
- package/dist/rpc/nats/index.js +13 -16
- package/dist/rpc/nats/index.mjs +9 -12
- package/dist/rpc/rabbitmq/index.d.ts +2 -3
- package/dist/rpc/rabbitmq/index.js +14 -17
- package/dist/rpc/rabbitmq/index.mjs +9 -12
- package/dist/rpc/redis/index.d.ts +2 -3
- package/dist/rpc/redis/index.js +14 -17
- package/dist/rpc/redis/index.mjs +9 -12
- package/dist/server/elysia/index.d.ts +4 -4
- package/dist/server/elysia/index.js +30 -30
- package/dist/server/elysia/index.mjs +17 -17
- package/dist/server/express/index.d.ts +4 -4
- package/dist/server/express/index.js +28 -28
- package/dist/server/express/index.mjs +16 -16
- package/dist/server/fastify/index.d.ts +4 -4
- package/dist/server/fastify/index.js +30 -30
- package/dist/server/fastify/index.mjs +17 -17
- package/dist/server/h3/index.d.ts +5 -10
- package/dist/server/h3/index.js +28 -28
- package/dist/server/h3/index.mjs +16 -16
- package/dist/server/hono/index.d.ts +4 -4
- package/dist/server/hono/index.js +28 -28
- package/dist/server/hono/index.mjs +16 -16
- package/dist/server/hyper-express/index.d.ts +4 -4
- package/dist/server/hyper-express/index.js +28 -28
- package/dist/server/hyper-express/index.mjs +16 -16
- package/dist/server/koa/index.d.ts +4 -4
- package/dist/server/koa/index.js +28 -28
- package/dist/server/koa/index.mjs +16 -16
- package/dist/test.d.ts +1 -2
- package/package.json +2 -2
- package/dist/helper-88b19c66.d.ts +0 -12
- package/dist/helper-9e206c66.d.ts +0 -12
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkYERBWZCSjs = require('../../chunk-YERBWZCS.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
@@ -12,13 +12,11 @@ var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
|
12
12
|
// src/server/hyper-express/bind.ts
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
14
14
|
var debug = _debug2.default.call(void 0, "phecda-server/hyper-express");
|
|
15
|
-
function bind(router, { moduleMap, meta },
|
|
16
|
-
const { globalGuards, globalInterceptors, route, plugins } = {
|
|
15
|
+
function bind(router, { moduleMap, meta }, opts = {}) {
|
|
16
|
+
const { globalGuards, globalInterceptors, route, plugins, globalFilter, globalPipe } = {
|
|
17
17
|
route: "/__PHECDA_SERVER__",
|
|
18
|
-
globalGuards: [],
|
|
19
|
-
globalInterceptors: [],
|
|
20
18
|
plugins: [],
|
|
21
|
-
...
|
|
19
|
+
...opts
|
|
22
20
|
};
|
|
23
21
|
const metaMap = /* @__PURE__ */ new Map();
|
|
24
22
|
function handleMeta() {
|
|
@@ -28,14 +26,6 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
28
26
|
if (controller !== "http" || !_optionalChain([http, 'optionalAccess', _ => _.type]))
|
|
29
27
|
continue;
|
|
30
28
|
debug(`register method "${func}" in module "${tag}"`);
|
|
31
|
-
item.data.guards = [
|
|
32
|
-
...globalGuards,
|
|
33
|
-
...item.data.guards
|
|
34
|
-
];
|
|
35
|
-
item.data.interceptors = [
|
|
36
|
-
...globalInterceptors,
|
|
37
|
-
...item.data.interceptors
|
|
38
|
-
];
|
|
39
29
|
if (metaMap.has(tag))
|
|
40
30
|
metaMap.get(tag)[func] = item;
|
|
41
31
|
else
|
|
@@ -48,27 +38,27 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
48
38
|
async function createRoute() {
|
|
49
39
|
router.post(route, {
|
|
50
40
|
middlewares: [
|
|
51
|
-
...
|
|
41
|
+
..._chunkYERBWZCSjs.Context.usePlugin(plugins)
|
|
52
42
|
]
|
|
53
43
|
}, async (req, res, next) => {
|
|
54
44
|
const body = await req.json();
|
|
55
45
|
async function errorHandler(e) {
|
|
56
|
-
const error = await
|
|
46
|
+
const error = await _chunkYERBWZCSjs.Context.filterRecord.default(e);
|
|
57
47
|
return res.status(error.status).json(error);
|
|
58
48
|
}
|
|
59
49
|
_chunkYR5Q5F2Kjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
60
50
|
if (!Array.isArray(body))
|
|
61
|
-
return errorHandler(new (0,
|
|
51
|
+
return errorHandler(new (0, _chunkYERBWZCSjs.BadRequestException)("data format should be an array"));
|
|
62
52
|
try {
|
|
63
53
|
return Promise.all(body.map((item, i) => {
|
|
64
54
|
return new Promise(async (resolve) => {
|
|
65
55
|
const { tag, func } = item;
|
|
66
56
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
67
57
|
if (!metaMap.has(tag))
|
|
68
|
-
return resolve(await
|
|
58
|
+
return resolve(await _chunkYERBWZCSjs.Context.filterRecord.default(new (0, _chunkYERBWZCSjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
69
59
|
const meta2 = metaMap.get(tag)[func];
|
|
70
60
|
if (!meta2)
|
|
71
|
-
return resolve(await
|
|
61
|
+
return resolve(await _chunkYERBWZCSjs.Context.filterRecord.default(new (0, _chunkYERBWZCSjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
72
62
|
const { data: { params } } = meta2;
|
|
73
63
|
const contextData = {
|
|
74
64
|
type: "hyper-express",
|
|
@@ -82,10 +72,15 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
82
72
|
func,
|
|
83
73
|
next,
|
|
84
74
|
app: router,
|
|
85
|
-
...
|
|
75
|
+
..._chunkYERBWZCSjs.argToReq.call(void 0, params, item.args, req.headers)
|
|
86
76
|
};
|
|
87
|
-
const context = new (0,
|
|
88
|
-
context.run(
|
|
77
|
+
const context = new (0, _chunkYERBWZCSjs.Context)(contextData);
|
|
78
|
+
context.run({
|
|
79
|
+
globalGuards,
|
|
80
|
+
globalInterceptors,
|
|
81
|
+
globalFilter,
|
|
82
|
+
globalPipe
|
|
83
|
+
}, resolve, resolve);
|
|
89
84
|
});
|
|
90
85
|
})).then((ret) => {
|
|
91
86
|
res.json(ret);
|
|
@@ -101,7 +96,7 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
101
96
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
|
|
102
97
|
continue;
|
|
103
98
|
const needBody = params.some((item) => item.type === "body");
|
|
104
|
-
router[http.type](http.prefix + http.route, ...
|
|
99
|
+
router[http.type](http.prefix + http.route, ..._chunkYERBWZCSjs.Context.usePlugin(plugins2), async (req, res, next) => {
|
|
105
100
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
106
101
|
const contextData = {
|
|
107
102
|
type: "hyper-express",
|
|
@@ -118,12 +113,17 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
118
113
|
headers: req.headers,
|
|
119
114
|
next
|
|
120
115
|
};
|
|
121
|
-
const context = new (0,
|
|
116
|
+
const context = new (0, _chunkYERBWZCSjs.Context)(contextData);
|
|
122
117
|
if (http.headers) {
|
|
123
118
|
for (const name in http.headers)
|
|
124
119
|
res.set(name, http.headers[name]);
|
|
125
120
|
}
|
|
126
|
-
await context.run(
|
|
121
|
+
await context.run({
|
|
122
|
+
globalGuards,
|
|
123
|
+
globalInterceptors,
|
|
124
|
+
globalFilter,
|
|
125
|
+
globalPipe
|
|
126
|
+
}, (returnData) => {
|
|
127
127
|
if (res.writableEnded)
|
|
128
128
|
return;
|
|
129
129
|
if (typeof returnData === "string")
|
|
@@ -140,15 +140,15 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
_chunkYR5Q5F2Kjs.__name.call(void 0, createRoute, "createRoute");
|
|
143
|
-
|
|
143
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
144
144
|
plugins,
|
|
145
145
|
guards: globalGuards,
|
|
146
146
|
interceptors: globalInterceptors
|
|
147
147
|
});
|
|
148
148
|
handleMeta();
|
|
149
149
|
createRoute();
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
_chunkYERBWZCSjs.HMR.call(void 0, () => {
|
|
151
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
152
152
|
plugins,
|
|
153
153
|
guards: globalGuards,
|
|
154
154
|
interceptors: globalInterceptors
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
HMR,
|
|
5
5
|
argToReq,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-AB4OX3WV.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
10
|
} from "../../chunk-ITTD2GBR.mjs";
|
|
@@ -12,13 +12,11 @@ import {
|
|
|
12
12
|
// src/server/hyper-express/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
14
14
|
var debug = Debug("phecda-server/hyper-express");
|
|
15
|
-
function bind(router, { moduleMap, meta },
|
|
16
|
-
const { globalGuards, globalInterceptors, route, plugins } = {
|
|
15
|
+
function bind(router, { moduleMap, meta }, opts = {}) {
|
|
16
|
+
const { globalGuards, globalInterceptors, route, plugins, globalFilter, globalPipe } = {
|
|
17
17
|
route: "/__PHECDA_SERVER__",
|
|
18
|
-
globalGuards: [],
|
|
19
|
-
globalInterceptors: [],
|
|
20
18
|
plugins: [],
|
|
21
|
-
...
|
|
19
|
+
...opts
|
|
22
20
|
};
|
|
23
21
|
const metaMap = /* @__PURE__ */ new Map();
|
|
24
22
|
function handleMeta() {
|
|
@@ -28,14 +26,6 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
28
26
|
if (controller !== "http" || !http?.type)
|
|
29
27
|
continue;
|
|
30
28
|
debug(`register method "${func}" in module "${tag}"`);
|
|
31
|
-
item.data.guards = [
|
|
32
|
-
...globalGuards,
|
|
33
|
-
...item.data.guards
|
|
34
|
-
];
|
|
35
|
-
item.data.interceptors = [
|
|
36
|
-
...globalInterceptors,
|
|
37
|
-
...item.data.interceptors
|
|
38
|
-
];
|
|
39
29
|
if (metaMap.has(tag))
|
|
40
30
|
metaMap.get(tag)[func] = item;
|
|
41
31
|
else
|
|
@@ -85,7 +75,12 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
85
75
|
...argToReq(params, item.args, req.headers)
|
|
86
76
|
};
|
|
87
77
|
const context = new Context(contextData);
|
|
88
|
-
context.run(
|
|
78
|
+
context.run({
|
|
79
|
+
globalGuards,
|
|
80
|
+
globalInterceptors,
|
|
81
|
+
globalFilter,
|
|
82
|
+
globalPipe
|
|
83
|
+
}, resolve, resolve);
|
|
89
84
|
});
|
|
90
85
|
})).then((ret) => {
|
|
91
86
|
res.json(ret);
|
|
@@ -123,7 +118,12 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
123
118
|
for (const name in http.headers)
|
|
124
119
|
res.set(name, http.headers[name]);
|
|
125
120
|
}
|
|
126
|
-
await context.run(
|
|
121
|
+
await context.run({
|
|
122
|
+
globalGuards,
|
|
123
|
+
globalInterceptors,
|
|
124
|
+
globalFilter,
|
|
125
|
+
globalPipe
|
|
126
|
+
}, (returnData) => {
|
|
127
127
|
if (res.writableEnded)
|
|
128
128
|
return;
|
|
129
129
|
if (typeof returnData === "string")
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { a as HttpContext, H as HttpOptions } from '../../helper-f29f082f.js';
|
|
4
|
+
import { F as Factory } from '../../core-fd134ffa.js';
|
|
5
|
+
import 'node:http';
|
|
5
6
|
import 'phecda-core';
|
|
6
|
-
import 'http';
|
|
7
7
|
|
|
8
8
|
interface KoaCtx extends HttpContext {
|
|
9
9
|
type: 'koa';
|
|
@@ -11,6 +11,6 @@ interface KoaCtx extends HttpContext {
|
|
|
11
11
|
next: Function;
|
|
12
12
|
app: Router;
|
|
13
13
|
}
|
|
14
|
-
declare function bind(router: Router, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>,
|
|
14
|
+
declare function bind(router: Router, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: HttpOptions): void;
|
|
15
15
|
|
|
16
16
|
export { KoaCtx, bind };
|
package/dist/server/koa/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkYERBWZCSjs = require('../../chunk-YERBWZCS.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
@@ -12,13 +12,11 @@ var _chunkYR5Q5F2Kjs = require('../../chunk-YR5Q5F2K.js');
|
|
|
12
12
|
// src/server/koa/bind.ts
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
14
14
|
var debug = _debug2.default.call(void 0, "phecda-server/koa");
|
|
15
|
-
function bind(router, { moduleMap, meta },
|
|
16
|
-
const { globalGuards, globalInterceptors, route, plugins } = {
|
|
15
|
+
function bind(router, { moduleMap, meta }, opts = {}) {
|
|
16
|
+
const { globalGuards, globalInterceptors, route, plugins, globalFilter, globalPipe } = {
|
|
17
17
|
route: "/__PHECDA_SERVER__",
|
|
18
|
-
globalGuards: [],
|
|
19
|
-
globalInterceptors: [],
|
|
20
18
|
plugins: [],
|
|
21
|
-
...
|
|
19
|
+
...opts
|
|
22
20
|
};
|
|
23
21
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
24
22
|
const metaMap = /* @__PURE__ */ new Map();
|
|
@@ -29,14 +27,6 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
29
27
|
if (controller !== "http" || !_optionalChain([http, 'optionalAccess', _ => _.type]))
|
|
30
28
|
continue;
|
|
31
29
|
debug(`register method "${func}" in module "${tag}"`);
|
|
32
|
-
item.data.guards = [
|
|
33
|
-
...globalGuards,
|
|
34
|
-
...item.data.guards
|
|
35
|
-
];
|
|
36
|
-
item.data.interceptors = [
|
|
37
|
-
...globalInterceptors,
|
|
38
|
-
...item.data.interceptors
|
|
39
|
-
];
|
|
40
30
|
if (metaMap.has(tag))
|
|
41
31
|
metaMap.get(tag)[func] = item;
|
|
42
32
|
else
|
|
@@ -47,26 +37,26 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
47
37
|
}
|
|
48
38
|
_chunkYR5Q5F2Kjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
49
39
|
async function createRoute() {
|
|
50
|
-
router.post(route, ...
|
|
40
|
+
router.post(route, ..._chunkYERBWZCSjs.Context.usePlugin(plugins), async (ctx, next) => {
|
|
51
41
|
const { body } = ctx.request;
|
|
52
42
|
async function errorHandler(e) {
|
|
53
|
-
const error = await
|
|
43
|
+
const error = await _chunkYERBWZCSjs.Context.filterRecord.default(e);
|
|
54
44
|
ctx.status = error.status;
|
|
55
45
|
ctx.body = error;
|
|
56
46
|
}
|
|
57
47
|
_chunkYR5Q5F2Kjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
58
48
|
if (!Array.isArray(body))
|
|
59
|
-
return errorHandler(new (0,
|
|
49
|
+
return errorHandler(new (0, _chunkYERBWZCSjs.BadRequestException)("data format should be an array"));
|
|
60
50
|
try {
|
|
61
51
|
return Promise.all(body.map((item, i) => {
|
|
62
52
|
return new Promise(async (resolve) => {
|
|
63
53
|
const { tag, func } = item;
|
|
64
54
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
65
55
|
if (!metaMap.has(tag))
|
|
66
|
-
return resolve(await
|
|
56
|
+
return resolve(await _chunkYERBWZCSjs.Context.filterRecord.default(new (0, _chunkYERBWZCSjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
67
57
|
const meta2 = metaMap.get(tag)[func];
|
|
68
58
|
if (!meta2)
|
|
69
|
-
return resolve(await
|
|
59
|
+
return resolve(await _chunkYERBWZCSjs.Context.filterRecord.default(new (0, _chunkYERBWZCSjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
70
60
|
const { data: { params } } = meta2;
|
|
71
61
|
const contextData = {
|
|
72
62
|
type: "koa",
|
|
@@ -77,12 +67,17 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
77
67
|
parallel: true,
|
|
78
68
|
next,
|
|
79
69
|
app: router,
|
|
80
|
-
...
|
|
70
|
+
..._chunkYERBWZCSjs.argToReq.call(void 0, params, item.args, ctx.headers),
|
|
81
71
|
tag,
|
|
82
72
|
func
|
|
83
73
|
};
|
|
84
|
-
const context = new (0,
|
|
85
|
-
context.run(
|
|
74
|
+
const context = new (0, _chunkYERBWZCSjs.Context)(contextData);
|
|
75
|
+
context.run({
|
|
76
|
+
globalGuards,
|
|
77
|
+
globalInterceptors,
|
|
78
|
+
globalFilter,
|
|
79
|
+
globalPipe
|
|
80
|
+
}, resolve, resolve);
|
|
86
81
|
});
|
|
87
82
|
})).then((ret) => {
|
|
88
83
|
ctx.body = ret;
|
|
@@ -97,7 +92,7 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
97
92
|
const { data: { plugins: plugins2, http } } = meta2;
|
|
98
93
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
|
|
99
94
|
continue;
|
|
100
|
-
router[http.type](http.prefix + http.route, ...
|
|
95
|
+
router[http.type](http.prefix + http.route, ..._chunkYERBWZCSjs.Context.usePlugin(plugins2), async (ctx, next) => {
|
|
101
96
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
102
97
|
const contextData = {
|
|
103
98
|
type: "koa",
|
|
@@ -113,12 +108,17 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
113
108
|
headers: ctx.headers,
|
|
114
109
|
next
|
|
115
110
|
};
|
|
116
|
-
const context = new (0,
|
|
111
|
+
const context = new (0, _chunkYERBWZCSjs.Context)(contextData);
|
|
117
112
|
if (http.headers) {
|
|
118
113
|
for (const name in http.headers)
|
|
119
114
|
ctx.set(name, http.headers[name]);
|
|
120
115
|
}
|
|
121
|
-
await context.run(
|
|
116
|
+
await context.run({
|
|
117
|
+
globalGuards,
|
|
118
|
+
globalInterceptors,
|
|
119
|
+
globalFilter,
|
|
120
|
+
globalPipe
|
|
121
|
+
}, (returnData) => {
|
|
122
122
|
if (ctx.res.writableEnded)
|
|
123
123
|
return;
|
|
124
124
|
ctx.body = returnData;
|
|
@@ -133,16 +133,16 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
_chunkYR5Q5F2Kjs.__name.call(void 0, createRoute, "createRoute");
|
|
136
|
-
|
|
136
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
137
137
|
plugins,
|
|
138
138
|
guards: globalGuards,
|
|
139
139
|
interceptors: globalInterceptors
|
|
140
140
|
});
|
|
141
141
|
handleMeta();
|
|
142
142
|
createRoute();
|
|
143
|
-
|
|
143
|
+
_chunkYERBWZCSjs.HMR.call(void 0, async () => {
|
|
144
144
|
router.stack = originStack;
|
|
145
|
-
|
|
145
|
+
_chunkYERBWZCSjs.detectAopDep.call(void 0, meta, {
|
|
146
146
|
plugins,
|
|
147
147
|
guards: globalGuards,
|
|
148
148
|
interceptors: globalInterceptors
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
HMR,
|
|
5
5
|
argToReq,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-AB4OX3WV.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
10
|
} from "../../chunk-ITTD2GBR.mjs";
|
|
@@ -12,13 +12,11 @@ import {
|
|
|
12
12
|
// src/server/koa/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
14
14
|
var debug = Debug("phecda-server/koa");
|
|
15
|
-
function bind(router, { moduleMap, meta },
|
|
16
|
-
const { globalGuards, globalInterceptors, route, plugins } = {
|
|
15
|
+
function bind(router, { moduleMap, meta }, opts = {}) {
|
|
16
|
+
const { globalGuards, globalInterceptors, route, plugins, globalFilter, globalPipe } = {
|
|
17
17
|
route: "/__PHECDA_SERVER__",
|
|
18
|
-
globalGuards: [],
|
|
19
|
-
globalInterceptors: [],
|
|
20
18
|
plugins: [],
|
|
21
|
-
...
|
|
19
|
+
...opts
|
|
22
20
|
};
|
|
23
21
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
24
22
|
const metaMap = /* @__PURE__ */ new Map();
|
|
@@ -29,14 +27,6 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
29
27
|
if (controller !== "http" || !http?.type)
|
|
30
28
|
continue;
|
|
31
29
|
debug(`register method "${func}" in module "${tag}"`);
|
|
32
|
-
item.data.guards = [
|
|
33
|
-
...globalGuards,
|
|
34
|
-
...item.data.guards
|
|
35
|
-
];
|
|
36
|
-
item.data.interceptors = [
|
|
37
|
-
...globalInterceptors,
|
|
38
|
-
...item.data.interceptors
|
|
39
|
-
];
|
|
40
30
|
if (metaMap.has(tag))
|
|
41
31
|
metaMap.get(tag)[func] = item;
|
|
42
32
|
else
|
|
@@ -82,7 +72,12 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
82
72
|
func
|
|
83
73
|
};
|
|
84
74
|
const context = new Context(contextData);
|
|
85
|
-
context.run(
|
|
75
|
+
context.run({
|
|
76
|
+
globalGuards,
|
|
77
|
+
globalInterceptors,
|
|
78
|
+
globalFilter,
|
|
79
|
+
globalPipe
|
|
80
|
+
}, resolve, resolve);
|
|
86
81
|
});
|
|
87
82
|
})).then((ret) => {
|
|
88
83
|
ctx.body = ret;
|
|
@@ -118,7 +113,12 @@ function bind(router, { moduleMap, meta }, ServerOptions = {}) {
|
|
|
118
113
|
for (const name in http.headers)
|
|
119
114
|
ctx.set(name, http.headers[name]);
|
|
120
115
|
}
|
|
121
|
-
await context.run(
|
|
116
|
+
await context.run({
|
|
117
|
+
globalGuards,
|
|
118
|
+
globalInterceptors,
|
|
119
|
+
globalFilter,
|
|
120
|
+
globalPipe
|
|
121
|
+
}, (returnData) => {
|
|
122
122
|
if (ctx.res.writableEnded)
|
|
123
123
|
return;
|
|
124
124
|
ctx.body = returnData;
|
package/dist/test.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import * as supertest from 'supertest';
|
|
|
2
2
|
import { Test } from 'supertest';
|
|
3
3
|
import { Server } from 'node:http';
|
|
4
4
|
import { Construct } from 'phecda-core';
|
|
5
|
-
import { F as Factory, P as PickFunc } from './core-
|
|
6
|
-
import 'http';
|
|
5
|
+
import { F as Factory, P as PickFunc } from './core-fd134ffa.js';
|
|
7
6
|
|
|
8
7
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
9
8
|
get<C extends T[number]>(Module: C): InstanceType<C>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "5.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
|
+
"description": "server framework that provide IOC/type-reuse/http&rpc-adaptor ",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { C as ControllerMetaData } from './core-eb646fe5.js';
|
|
2
|
-
|
|
3
|
-
declare function resolveDep(ret: any, key: string): any;
|
|
4
|
-
interface ServerOptions {
|
|
5
|
-
route?: string;
|
|
6
|
-
globalGuards?: string[];
|
|
7
|
-
globalInterceptors?: string[];
|
|
8
|
-
plugins?: string[];
|
|
9
|
-
}
|
|
10
|
-
declare function argToReq(params: ControllerMetaData['params'], args: any[], headers: Record<string, any>): any;
|
|
11
|
-
|
|
12
|
-
export { ServerOptions as S, argToReq as a, resolveDep as r };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare function genClientQueue(key?: string): string;
|
|
2
|
-
interface RpcServerOptions {
|
|
3
|
-
globalGuards?: string[];
|
|
4
|
-
globalInterceptors?: string[];
|
|
5
|
-
}
|
|
6
|
-
interface RpcClientOptions {
|
|
7
|
-
key?: string;
|
|
8
|
-
timeout?: number;
|
|
9
|
-
max?: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { RpcServerOptions as R, RpcClientOptions as a, genClientQueue as g };
|