phecda-server 5.0.2 → 5.1.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/README.md +4 -102
- package/bin/cli.mjs +17 -14
- package/dist/{chunk-RCTOVYZY.mjs → chunk-2HKQPZDT.mjs} +1 -1
- package/dist/{chunk-BXLBWRHS.js → chunk-3BV2GRS7.js} +38 -38
- package/dist/{chunk-AB4OX3WV.mjs → chunk-665MB62T.mjs} +127 -99
- package/dist/{chunk-YERBWZCS.js → chunk-FSBD5R22.js} +180 -152
- package/dist/{chunk-F5YWXY5W.js → chunk-HMPTPTFL.js} +17 -17
- package/dist/{chunk-W5EOVGQD.mjs → chunk-UU6RHGRF.mjs} +2 -2
- package/dist/{chunk-ITTD2GBR.mjs → chunk-VLV3AO3H.mjs} +7 -19
- package/dist/{chunk-YR5Q5F2K.js → chunk-ZP7HNASU.js} +7 -19
- package/dist/{core-fd134ffa.d.ts → core-39f27fe8.d.ts} +4 -3
- package/dist/{helper-73e8d2f0.d.ts → helper-6133f78f.d.ts} +1 -1
- package/dist/{helper-f29f082f.d.ts → helper-fcbf6aa8.d.ts} +4 -3
- package/dist/index.d.ts +27 -32
- package/dist/index.js +44 -40
- package/dist/index.mjs +14 -10
- package/dist/rpc/bullmq/index.d.ts +10 -6
- package/dist/rpc/bullmq/index.js +32 -53
- package/dist/rpc/bullmq/index.mjs +26 -47
- package/dist/rpc/kafka/index.d.ts +10 -4
- package/dist/rpc/kafka/index.js +20 -37
- package/dist/rpc/kafka/index.mjs +15 -32
- package/dist/rpc/nats/index.d.ts +2 -2
- package/dist/rpc/nats/index.js +20 -34
- package/dist/rpc/nats/index.mjs +13 -27
- package/dist/rpc/rabbitmq/index.d.ts +2 -2
- package/dist/rpc/rabbitmq/index.js +23 -37
- package/dist/rpc/rabbitmq/index.mjs +14 -28
- package/dist/rpc/redis/index.d.ts +10 -4
- package/dist/rpc/redis/index.js +23 -37
- package/dist/rpc/redis/index.mjs +16 -30
- package/dist/server/elysia/index.d.ts +4 -3
- package/dist/server/elysia/index.js +77 -94
- package/dist/server/elysia/index.mjs +74 -91
- package/dist/server/express/index.d.ts +5 -4
- package/dist/server/express/index.js +79 -93
- package/dist/server/express/index.mjs +77 -91
- package/dist/server/fastify/index.d.ts +8 -5
- package/dist/server/fastify/index.js +83 -102
- package/dist/server/fastify/index.mjs +79 -98
- package/dist/server/h3/index.d.ts +5 -4
- package/dist/server/h3/index.js +81 -97
- package/dist/server/h3/index.mjs +80 -96
- package/dist/server/hono/index.d.ts +5 -4
- package/dist/server/hono/index.js +73 -90
- package/dist/server/hono/index.mjs +72 -89
- package/dist/server/hyper-express/index.d.ts +6 -5
- package/dist/server/hyper-express/index.js +78 -96
- package/dist/server/hyper-express/index.mjs +77 -95
- package/dist/server/koa/index.d.ts +5 -4
- package/dist/server/koa/index.js +79 -92
- package/dist/server/koa/index.mjs +76 -89
- package/dist/test.d.ts +1 -1
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/package.json +9 -8
- package/register/loader.mjs +19 -5
package/dist/server/koa/index.js
CHANGED
|
@@ -4,95 +4,95 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var _chunkYERBWZCSjs = require('../../chunk-YERBWZCS.js');
|
|
8
7
|
|
|
8
|
+
var _chunkFSBD5R22js = require('../../chunk-FSBD5R22.js');
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
var _chunkZP7HNASUjs = require('../../chunk-ZP7HNASU.js');
|
|
11
12
|
|
|
12
13
|
// src/server/koa/bind.ts
|
|
13
14
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
14
15
|
var debug = _debug2.default.call(void 0, "phecda-server/koa");
|
|
15
|
-
function bind(router,
|
|
16
|
-
const { globalGuards, globalInterceptors,
|
|
17
|
-
|
|
18
|
-
plugins: [],
|
|
19
|
-
...opts
|
|
20
|
-
};
|
|
16
|
+
function bind(router, data, opts = {}) {
|
|
17
|
+
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
18
|
+
const { moduleMap, meta } = data;
|
|
21
19
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
22
|
-
const metaMap =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for (const item of meta) {
|
|
26
|
-
const { tag, func, controller, http } = item.data;
|
|
27
|
-
if (controller !== "http" || !_optionalChain([http, 'optionalAccess', _ => _.type]))
|
|
28
|
-
continue;
|
|
20
|
+
const metaMap = _chunkFSBD5R22js.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
21
|
+
const { controller, http, func, tag } = meta2.data;
|
|
22
|
+
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
29
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
30
|
-
|
|
31
|
-
metaMap.get(tag)[func] = item;
|
|
32
|
-
else
|
|
33
|
-
metaMap.set(tag, {
|
|
34
|
-
[func]: item
|
|
35
|
-
});
|
|
24
|
+
return true;
|
|
36
25
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
26
|
+
});
|
|
27
|
+
_chunkFSBD5R22js.detectAopDep.call(void 0, meta, {
|
|
28
|
+
plugins: [
|
|
29
|
+
...globalPlugins,
|
|
30
|
+
...parallelPlugins
|
|
31
|
+
],
|
|
32
|
+
guards: globalGuards,
|
|
33
|
+
interceptors: globalInterceptors
|
|
34
|
+
});
|
|
35
|
+
registerRoute();
|
|
36
|
+
async function registerRoute() {
|
|
37
|
+
_chunkFSBD5R22js.Context.usePlugin(globalPlugins, "koa").forEach((p) => router.use(p));
|
|
38
|
+
if (parallelRoute) {
|
|
39
|
+
router.post(parallelRoute, ..._chunkFSBD5R22js.Context.usePlugin(parallelPlugins, "koa"), async (ctx, next) => {
|
|
40
|
+
const { body } = ctx.request;
|
|
41
|
+
async function errorHandler(e) {
|
|
42
|
+
const error = await _chunkFSBD5R22js.Context.filterRecord.default(e);
|
|
43
|
+
ctx.status = error.status;
|
|
44
|
+
ctx.body = error;
|
|
45
|
+
}
|
|
46
|
+
_chunkZP7HNASUjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
|
+
if (!Array.isArray(body))
|
|
48
|
+
return errorHandler(new (0, _chunkFSBD5R22js.BadRequestException)("data format should be an array"));
|
|
49
|
+
try {
|
|
50
|
+
return Promise.all(body.map((item, i) => {
|
|
51
|
+
return new Promise(async (resolve) => {
|
|
52
|
+
const { tag, func } = item;
|
|
53
|
+
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
54
|
+
if (!metaMap.has(tag))
|
|
55
|
+
return resolve(await _chunkFSBD5R22js.Context.filterRecord.default(new (0, _chunkFSBD5R22js.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
56
|
+
const meta2 = metaMap.get(tag)[func];
|
|
57
|
+
if (!meta2)
|
|
58
|
+
return resolve(await _chunkFSBD5R22js.Context.filterRecord.default(new (0, _chunkFSBD5R22js.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
|
+
const { data: { params } } = meta2;
|
|
60
|
+
const contextData = {
|
|
61
|
+
type: "koa",
|
|
62
|
+
index: i,
|
|
63
|
+
ctx,
|
|
64
|
+
meta: meta2,
|
|
65
|
+
moduleMap,
|
|
66
|
+
parallel: true,
|
|
67
|
+
next,
|
|
68
|
+
app: router,
|
|
69
|
+
..._chunkFSBD5R22js.argToReq.call(void 0, params, item.args, ctx.headers),
|
|
70
|
+
tag,
|
|
71
|
+
func
|
|
72
|
+
};
|
|
73
|
+
const context = new (0, _chunkFSBD5R22js.Context)(contextData);
|
|
74
|
+
context.run({
|
|
75
|
+
globalGuards,
|
|
76
|
+
globalInterceptors,
|
|
77
|
+
globalFilter,
|
|
78
|
+
globalPipe
|
|
79
|
+
}, resolve, resolve);
|
|
80
|
+
});
|
|
81
|
+
})).then((ret) => {
|
|
82
|
+
ctx.body = ret;
|
|
81
83
|
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
});
|
|
84
|
+
} catch (e) {
|
|
85
|
+
return errorHandler(e);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
89
|
for (const [tag, record] of metaMap) {
|
|
90
90
|
for (const func in record) {
|
|
91
91
|
const meta2 = metaMap.get(tag)[func];
|
|
92
|
-
const { data: { plugins
|
|
92
|
+
const { data: { plugins, http } } = meta2;
|
|
93
93
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
|
|
94
94
|
continue;
|
|
95
|
-
router[http.type](http.prefix + http.route, ...
|
|
95
|
+
router[http.type](http.prefix + http.route, ..._chunkFSBD5R22js.Context.usePlugin(plugins, "koa"), async (ctx, next) => {
|
|
96
96
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
97
97
|
const contextData = {
|
|
98
98
|
type: "koa",
|
|
@@ -108,7 +108,7 @@ function bind(router, { moduleMap, meta }, opts = {}) {
|
|
|
108
108
|
headers: ctx.headers,
|
|
109
109
|
next
|
|
110
110
|
};
|
|
111
|
-
const context = new (0,
|
|
111
|
+
const context = new (0, _chunkFSBD5R22js.Context)(contextData);
|
|
112
112
|
if (http.headers) {
|
|
113
113
|
for (const name in http.headers)
|
|
114
114
|
ctx.set(name, http.headers[name]);
|
|
@@ -132,26 +132,13 @@ function bind(router, { moduleMap, meta }, opts = {}) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
plugins,
|
|
138
|
-
guards: globalGuards,
|
|
139
|
-
interceptors: globalInterceptors
|
|
140
|
-
});
|
|
141
|
-
handleMeta();
|
|
142
|
-
createRoute();
|
|
143
|
-
_chunkYERBWZCSjs.HMR.call(void 0, async () => {
|
|
135
|
+
_chunkZP7HNASUjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
136
|
+
_chunkFSBD5R22js.HMR.call(void 0, async () => {
|
|
144
137
|
router.stack = originStack;
|
|
145
|
-
|
|
146
|
-
plugins,
|
|
147
|
-
guards: globalGuards,
|
|
148
|
-
interceptors: globalInterceptors
|
|
149
|
-
});
|
|
150
|
-
handleMeta();
|
|
151
|
-
createRoute();
|
|
138
|
+
registerRoute();
|
|
152
139
|
});
|
|
153
140
|
}
|
|
154
|
-
|
|
141
|
+
_chunkZP7HNASUjs.__name.call(void 0, bind, "bind");
|
|
155
142
|
|
|
156
143
|
|
|
157
144
|
exports.bind = bind;
|
|
@@ -3,96 +3,96 @@ import {
|
|
|
3
3
|
Context,
|
|
4
4
|
HMR,
|
|
5
5
|
argToReq,
|
|
6
|
+
createControllerMetaMap,
|
|
6
7
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-665MB62T.mjs";
|
|
8
9
|
import {
|
|
9
10
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-VLV3AO3H.mjs";
|
|
11
12
|
|
|
12
13
|
// src/server/koa/bind.ts
|
|
13
14
|
import Debug from "debug";
|
|
14
15
|
var debug = Debug("phecda-server/koa");
|
|
15
|
-
function bind(router,
|
|
16
|
-
const { globalGuards, globalInterceptors,
|
|
17
|
-
|
|
18
|
-
plugins: [],
|
|
19
|
-
...opts
|
|
20
|
-
};
|
|
16
|
+
function bind(router, data, opts = {}) {
|
|
17
|
+
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
18
|
+
const { moduleMap, meta } = data;
|
|
21
19
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
22
|
-
const metaMap =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for (const item of meta) {
|
|
26
|
-
const { tag, func, controller, http } = item.data;
|
|
27
|
-
if (controller !== "http" || !http?.type)
|
|
28
|
-
continue;
|
|
20
|
+
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
21
|
+
const { controller, http, func, tag } = meta2.data;
|
|
22
|
+
if (controller === "http" && http?.type) {
|
|
29
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
30
|
-
|
|
31
|
-
metaMap.get(tag)[func] = item;
|
|
32
|
-
else
|
|
33
|
-
metaMap.set(tag, {
|
|
34
|
-
[func]: item
|
|
35
|
-
});
|
|
24
|
+
return true;
|
|
36
25
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
26
|
+
});
|
|
27
|
+
detectAopDep(meta, {
|
|
28
|
+
plugins: [
|
|
29
|
+
...globalPlugins,
|
|
30
|
+
...parallelPlugins
|
|
31
|
+
],
|
|
32
|
+
guards: globalGuards,
|
|
33
|
+
interceptors: globalInterceptors
|
|
34
|
+
});
|
|
35
|
+
registerRoute();
|
|
36
|
+
async function registerRoute() {
|
|
37
|
+
Context.usePlugin(globalPlugins, "koa").forEach((p) => router.use(p));
|
|
38
|
+
if (parallelRoute) {
|
|
39
|
+
router.post(parallelRoute, ...Context.usePlugin(parallelPlugins, "koa"), async (ctx, next) => {
|
|
40
|
+
const { body } = ctx.request;
|
|
41
|
+
async function errorHandler(e) {
|
|
42
|
+
const error = await Context.filterRecord.default(e);
|
|
43
|
+
ctx.status = error.status;
|
|
44
|
+
ctx.body = error;
|
|
45
|
+
}
|
|
46
|
+
__name(errorHandler, "errorHandler");
|
|
47
|
+
if (!Array.isArray(body))
|
|
48
|
+
return errorHandler(new BadRequestException("data format should be an array"));
|
|
49
|
+
try {
|
|
50
|
+
return Promise.all(body.map((item, i) => {
|
|
51
|
+
return new Promise(async (resolve) => {
|
|
52
|
+
const { tag, func } = item;
|
|
53
|
+
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
54
|
+
if (!metaMap.has(tag))
|
|
55
|
+
return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
56
|
+
const meta2 = metaMap.get(tag)[func];
|
|
57
|
+
if (!meta2)
|
|
58
|
+
return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
|
+
const { data: { params } } = meta2;
|
|
60
|
+
const contextData = {
|
|
61
|
+
type: "koa",
|
|
62
|
+
index: i,
|
|
63
|
+
ctx,
|
|
64
|
+
meta: meta2,
|
|
65
|
+
moduleMap,
|
|
66
|
+
parallel: true,
|
|
67
|
+
next,
|
|
68
|
+
app: router,
|
|
69
|
+
...argToReq(params, item.args, ctx.headers),
|
|
70
|
+
tag,
|
|
71
|
+
func
|
|
72
|
+
};
|
|
73
|
+
const context = new Context(contextData);
|
|
74
|
+
context.run({
|
|
75
|
+
globalGuards,
|
|
76
|
+
globalInterceptors,
|
|
77
|
+
globalFilter,
|
|
78
|
+
globalPipe
|
|
79
|
+
}, resolve, resolve);
|
|
80
|
+
});
|
|
81
|
+
})).then((ret) => {
|
|
82
|
+
ctx.body = ret;
|
|
81
83
|
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
});
|
|
84
|
+
} catch (e) {
|
|
85
|
+
return errorHandler(e);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
89
|
for (const [tag, record] of metaMap) {
|
|
90
90
|
for (const func in record) {
|
|
91
91
|
const meta2 = metaMap.get(tag)[func];
|
|
92
|
-
const { data: { plugins
|
|
92
|
+
const { data: { plugins, http } } = meta2;
|
|
93
93
|
if (!http?.type)
|
|
94
94
|
continue;
|
|
95
|
-
router[http.type](http.prefix + http.route, ...Context.usePlugin(
|
|
95
|
+
router[http.type](http.prefix + http.route, ...Context.usePlugin(plugins, "koa"), async (ctx, next) => {
|
|
96
96
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
97
97
|
const contextData = {
|
|
98
98
|
type: "koa",
|
|
@@ -132,23 +132,10 @@ function bind(router, { moduleMap, meta }, opts = {}) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
__name(
|
|
136
|
-
detectAopDep(meta, {
|
|
137
|
-
plugins,
|
|
138
|
-
guards: globalGuards,
|
|
139
|
-
interceptors: globalInterceptors
|
|
140
|
-
});
|
|
141
|
-
handleMeta();
|
|
142
|
-
createRoute();
|
|
135
|
+
__name(registerRoute, "registerRoute");
|
|
143
136
|
HMR(async () => {
|
|
144
137
|
router.stack = originStack;
|
|
145
|
-
|
|
146
|
-
plugins,
|
|
147
|
-
guards: globalGuards,
|
|
148
|
-
interceptors: globalInterceptors
|
|
149
|
-
});
|
|
150
|
-
handleMeta();
|
|
151
|
-
createRoute();
|
|
138
|
+
registerRoute();
|
|
152
139
|
});
|
|
153
140
|
}
|
|
154
141
|
__name(bind, "bind");
|
package/dist/test.d.ts
CHANGED
|
@@ -2,7 +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-
|
|
5
|
+
import { F as Factory, P as PickFunc } from './core-39f27fe8.js';
|
|
6
6
|
|
|
7
7
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
8
8
|
get<C extends T[number]>(Module: C): InstanceType<C>;
|
package/dist/test.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkHMPTPTFLjs = require('./chunk-HMPTPTFL.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkZP7HNASUjs = require('./chunk-ZP7HNASU.js');
|
|
7
7
|
|
|
8
8
|
// src/test.ts
|
|
9
9
|
var _phecdacore = require('phecda-core');
|
|
10
10
|
async function TestFactory(...Modules) {
|
|
11
|
-
const { moduleMap, constructorMap } = await
|
|
11
|
+
const { moduleMap, constructorMap } = await _chunkHMPTPTFLjs.Factory.call(void 0, Modules);
|
|
12
12
|
return {
|
|
13
13
|
get(Module) {
|
|
14
14
|
const tag = _phecdacore.getTag.call(void 0, Module);
|
|
@@ -21,7 +21,7 @@ async function TestFactory(...Modules) {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
_chunkZP7HNASUjs.__name.call(void 0, TestFactory, "TestFactory");
|
|
25
25
|
async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
26
26
|
const { default: request, agent } = await Promise.resolve().then(() => require("supertest"));
|
|
27
27
|
const Agent = agent(app);
|
|
@@ -67,11 +67,11 @@ async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
_chunkZP7HNASUjs.__name.call(void 0, module, "module");
|
|
71
71
|
Agent.module = module;
|
|
72
72
|
return Agent;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
_chunkZP7HNASUjs.__name.call(void 0, TestHttp, "TestHttp");
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
|
package/dist/test.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "5.
|
|
4
|
-
"description": "server framework that provide IOC/type-reuse/http&rpc-adaptor
|
|
3
|
+
"version": "5.1.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",
|
|
@@ -117,11 +117,12 @@
|
|
|
117
117
|
},
|
|
118
118
|
"keywords": [
|
|
119
119
|
"server",
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
120
|
+
"IOC",
|
|
121
|
+
"rpc",
|
|
122
|
+
"types-share"
|
|
123
123
|
],
|
|
124
|
-
"author": "",
|
|
124
|
+
"author": "fgsreally",
|
|
125
|
+
"repository": "https://github.com/fgsreally/phecda/tree/main/packages/server",
|
|
125
126
|
"files": [
|
|
126
127
|
"dist",
|
|
127
128
|
"register",
|
|
@@ -143,7 +144,7 @@
|
|
|
143
144
|
"elysia": "^1.0.17",
|
|
144
145
|
"express": "^4.18.2",
|
|
145
146
|
"fastify": "^4.25.1",
|
|
146
|
-
"h3": "^1.
|
|
147
|
+
"h3": "^1.11.1",
|
|
147
148
|
"hono": "^4.3.4",
|
|
148
149
|
"hyper-express": "^6.15.2",
|
|
149
150
|
"ioredis": "^5.3.2",
|
|
@@ -155,7 +156,7 @@
|
|
|
155
156
|
"nats": "^2.22.0",
|
|
156
157
|
"supertest": "^6.3.3",
|
|
157
158
|
"tsup": "^6.5.0",
|
|
158
|
-
"typescript": "^5.
|
|
159
|
+
"typescript": "^5.4.5",
|
|
159
160
|
"unimport": "^3.7.1"
|
|
160
161
|
},
|
|
161
162
|
"dependencies": {
|
package/register/loader.mjs
CHANGED
|
@@ -67,9 +67,10 @@ export async function initialize(data) {
|
|
|
67
67
|
if (!config.unimport)
|
|
68
68
|
return
|
|
69
69
|
unimportRet = await genUnImportRet(config.unimport)
|
|
70
|
-
await unimportRet.init()
|
|
71
70
|
if (unimportRet) {
|
|
72
71
|
log('auto import...')
|
|
72
|
+
await unimportRet.init()
|
|
73
|
+
|
|
73
74
|
writeFile(
|
|
74
75
|
config.unimport.dtsPath || dtsPath,
|
|
75
76
|
handleClassTypes(await unimportRet.generateTypeDeclarations()),
|
|
@@ -120,9 +121,9 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
// url import
|
|
124
|
+
// it seems useless
|
|
123
125
|
if (/^file:\/\/\//.test(specifier) && extname(specifier) === '.ts') {
|
|
124
126
|
const url = addUrlToGraph(specifier, context.parentURL.split('?')[0])
|
|
125
|
-
|
|
126
127
|
return {
|
|
127
128
|
format: 'ts',
|
|
128
129
|
url,
|
|
@@ -151,7 +152,8 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
151
152
|
host,
|
|
152
153
|
moduleResolutionCache,
|
|
153
154
|
)
|
|
154
|
-
|
|
155
|
+
|
|
156
|
+
// import between loacl projects
|
|
155
157
|
if (
|
|
156
158
|
resolvedModule
|
|
157
159
|
&& !resolvedModule.resolvedFileName.includes('/node_modules/')
|
|
@@ -184,7 +186,13 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
184
186
|
}
|
|
185
187
|
}
|
|
186
188
|
|
|
187
|
-
|
|
189
|
+
const resolveRet = await nextResolve(specifier)
|
|
190
|
+
|
|
191
|
+
// ts resolve fail in some cases
|
|
192
|
+
if (isAbsolute(resolveRet.url))
|
|
193
|
+
resolveRet.url = pathToFileURL(resolveRet.url).href
|
|
194
|
+
|
|
195
|
+
return resolveRet
|
|
188
196
|
}
|
|
189
197
|
// @todo the first params may be url or path, need to distinguish
|
|
190
198
|
|
|
@@ -271,7 +279,13 @@ export const load = async (url, context, nextLoad) => {
|
|
|
271
279
|
return {
|
|
272
280
|
format: 'module',
|
|
273
281
|
source: (
|
|
274
|
-
await injectImports(
|
|
282
|
+
await injectImports(
|
|
283
|
+
compiled,
|
|
284
|
+
(url.startsWith('file://') ? fileURLToPath(url) : url).replace(
|
|
285
|
+
/\\/g,
|
|
286
|
+
'/',
|
|
287
|
+
),
|
|
288
|
+
)
|
|
275
289
|
).code,
|
|
276
290
|
shortCircuit: true,
|
|
277
291
|
}
|