phecda-server 5.1.0 → 5.2.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/README.md +10 -10
- package/assets/ps.json +25 -0
- package/{bin → assets}/schema.json +55 -55
- package/assets/tsconfig.json +21 -0
- package/bin/cli.mjs +150 -189
- package/dist/{chunk-6UQYEBAN.js → chunk-5BVUCNMA.js} +19 -20
- package/dist/{chunk-QG4X6H5Y.js → chunk-BSE2DSDK.js} +121 -124
- package/dist/{chunk-OTHER3YM.mjs → chunk-CKQW3FDK.mjs} +4 -5
- package/dist/{chunk-6W7CGOZC.mjs → chunk-JE6BBDXW.mjs} +64 -67
- package/dist/{chunk-5DOVDDO7.mjs → chunk-V3WIKOP3.mjs} +11 -6
- package/dist/{chunk-H4N6SHNG.mjs → chunk-VLV3AO3H.mjs} +0 -1
- package/dist/{chunk-GHOKWS5V.js → chunk-VMLHTEW3.js} +48 -43
- package/dist/{chunk-Z4YJHEXT.js → chunk-ZP7HNASU.js} +0 -1
- package/dist/core-7f6d2be6.d.ts +27 -0
- package/dist/{helper-fcbf6aa8.d.ts → helper-49c7213c.d.ts} +1 -1
- package/dist/{helper-867a598d.d.ts → helper-5d755442.d.ts} +1 -1
- package/dist/helper.d.ts +25 -0
- package/dist/helper.js +21 -0
- package/dist/helper.mjs +21 -0
- package/dist/index.d.ts +5 -25
- package/dist/index.js +39 -58
- package/dist/index.mjs +6 -25
- package/dist/rpc/bullmq/index.d.ts +3 -2
- package/dist/rpc/bullmq/index.js +12 -13
- package/dist/rpc/bullmq/index.mjs +2 -3
- package/dist/rpc/kafka/index.d.ts +3 -2
- package/dist/rpc/kafka/index.js +10 -11
- package/dist/rpc/kafka/index.mjs +2 -3
- package/dist/rpc/nats/index.d.ts +3 -2
- package/dist/rpc/nats/index.js +11 -12
- package/dist/rpc/nats/index.mjs +2 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -2
- package/dist/rpc/rabbitmq/index.js +13 -14
- package/dist/rpc/rabbitmq/index.mjs +2 -3
- package/dist/rpc/redis/index.d.ts +3 -2
- package/dist/rpc/redis/index.js +11 -12
- package/dist/rpc/redis/index.mjs +2 -3
- package/dist/server/elysia/index.d.ts +3 -2
- package/dist/server/elysia/index.js +20 -21
- package/dist/server/elysia/index.mjs +3 -4
- package/dist/server/express/index.d.ts +3 -2
- package/dist/server/express/index.js +18 -19
- package/dist/server/express/index.mjs +2 -3
- package/dist/server/fastify/index.d.ts +3 -2
- package/dist/server/fastify/index.js +19 -20
- package/dist/server/fastify/index.mjs +3 -4
- package/dist/server/h3/index.d.ts +3 -2
- package/dist/server/h3/index.js +16 -17
- package/dist/server/h3/index.mjs +2 -3
- package/dist/server/hono/index.d.ts +3 -2
- package/dist/server/hono/index.js +17 -18
- package/dist/server/hono/index.mjs +2 -3
- package/dist/server/hyper-express/index.d.ts +3 -2
- package/dist/server/hyper-express/index.js +17 -18
- package/dist/server/hyper-express/index.mjs +2 -3
- package/dist/server/koa/index.d.ts +3 -2
- package/dist/server/koa/index.js +18 -19
- package/dist/server/koa/index.mjs +2 -3
- package/dist/test.d.ts +2 -1
- package/dist/test.js +6 -7
- package/dist/test.mjs +2 -3
- package/dist/{core-fd134ffa.d.ts → types-81be0ba3.d.ts} +2 -24
- package/package.json +62 -54
- package/register/index.mjs +40 -40
- package/register/loader.mjs +367 -341
- package/register/utils.mjs +56 -81
- package/dist/chunk-423JPSEB.js +0 -253
- package/dist/chunk-423JPSEB.js.map +0 -1
- package/dist/chunk-4R55T3HG.js +0 -253
- package/dist/chunk-4R55T3HG.js.map +0 -1
- package/dist/chunk-4YVAW3L4.mjs +0 -76
- package/dist/chunk-4YVAW3L4.mjs.map +0 -1
- package/dist/chunk-5DOVDDO7.mjs.map +0 -1
- package/dist/chunk-5WQ2SMIK.js +0 -295
- package/dist/chunk-5WQ2SMIK.js.map +0 -1
- package/dist/chunk-6MQP6OHU.mjs +0 -295
- package/dist/chunk-6MQP6OHU.mjs.map +0 -1
- package/dist/chunk-6Q2PCC3A.mjs +0 -295
- package/dist/chunk-6Q2PCC3A.mjs.map +0 -1
- package/dist/chunk-6UQYEBAN.js.map +0 -1
- package/dist/chunk-6W7CGOZC.mjs.map +0 -1
- package/dist/chunk-7Y37NSBM.js +0 -88
- package/dist/chunk-7Y37NSBM.js.map +0 -1
- package/dist/chunk-BQBSVGMG.mjs +0 -253
- package/dist/chunk-BQBSVGMG.mjs.map +0 -1
- package/dist/chunk-BZP6GKM6.mjs +0 -565
- package/dist/chunk-BZP6GKM6.mjs.map +0 -1
- package/dist/chunk-C5JAHCS2.mjs +0 -88
- package/dist/chunk-C5JAHCS2.mjs.map +0 -1
- package/dist/chunk-DTBKDALR.mjs +0 -295
- package/dist/chunk-DTBKDALR.mjs.map +0 -1
- package/dist/chunk-GHOKWS5V.js.map +0 -1
- package/dist/chunk-H4N6SHNG.mjs.map +0 -1
- package/dist/chunk-ICYHM4UM.js +0 -565
- package/dist/chunk-ICYHM4UM.js.map +0 -1
- package/dist/chunk-LOLXPM4J.mjs +0 -529
- package/dist/chunk-LOLXPM4J.mjs.map +0 -1
- package/dist/chunk-MSS6A2TU.js +0 -585
- package/dist/chunk-MSS6A2TU.js.map +0 -1
- package/dist/chunk-NEM3FY7C.mjs +0 -537
- package/dist/chunk-NEM3FY7C.mjs.map +0 -1
- package/dist/chunk-OTHER3YM.mjs.map +0 -1
- package/dist/chunk-Q2FYFIEY.js +0 -295
- package/dist/chunk-Q2FYFIEY.js.map +0 -1
- package/dist/chunk-QG4X6H5Y.js.map +0 -1
- package/dist/chunk-QIEZ6YTG.mjs +0 -295
- package/dist/chunk-QIEZ6YTG.mjs.map +0 -1
- package/dist/chunk-QOAKHCM7.js +0 -295
- package/dist/chunk-QOAKHCM7.js.map +0 -1
- package/dist/chunk-QVUD6L5X.js +0 -565
- package/dist/chunk-QVUD6L5X.js.map +0 -1
- package/dist/chunk-RGLTGKAU.js +0 -537
- package/dist/chunk-RGLTGKAU.js.map +0 -1
- package/dist/chunk-SHRK3TVB.js +0 -295
- package/dist/chunk-SHRK3TVB.js.map +0 -1
- package/dist/chunk-TCH6S42Z.js +0 -529
- package/dist/chunk-TCH6S42Z.js.map +0 -1
- package/dist/chunk-UCGRFVHC.mjs +0 -253
- package/dist/chunk-UCGRFVHC.mjs.map +0 -1
- package/dist/chunk-VOISXWVF.mjs +0 -295
- package/dist/chunk-VOISXWVF.mjs.map +0 -1
- package/dist/chunk-W6BC5INO.mjs +0 -295
- package/dist/chunk-W6BC5INO.mjs.map +0 -1
- package/dist/chunk-X5WQRO4R.js +0 -295
- package/dist/chunk-X5WQRO4R.js.map +0 -1
- package/dist/chunk-XDMCVVD3.mjs +0 -585
- package/dist/chunk-XDMCVVD3.mjs.map +0 -1
- package/dist/chunk-XNTMYLK6.js +0 -76
- package/dist/chunk-XNTMYLK6.js.map +0 -1
- package/dist/chunk-Y6LI4FDO.js +0 -537
- package/dist/chunk-Y6LI4FDO.js.map +0 -1
- package/dist/chunk-YZ2AQ6IL.mjs +0 -537
- package/dist/chunk-YZ2AQ6IL.mjs.map +0 -1
- package/dist/chunk-Z4YJHEXT.js.map +0 -1
- package/dist/chunk-ZE336SKZ.js +0 -295
- package/dist/chunk-ZE336SKZ.js.map +0 -1
- package/dist/chunk-ZJD235TO.mjs +0 -565
- package/dist/chunk-ZJD235TO.mjs.map +0 -1
- package/dist/core-39f27fe8.d.ts +0 -131
- package/dist/core-930ea883.d.ts +0 -131
- package/dist/core-eb646fe5.d.ts +0 -139
- package/dist/helper-06d25b37.d.ts +0 -19
- package/dist/helper-48454c0b.d.ts +0 -20
- package/dist/helper-6133f78f.d.ts +0 -18
- package/dist/helper-73e8d2f0.d.ts +0 -18
- package/dist/helper-88b19c66.d.ts +0 -12
- package/dist/helper-9e206c66.d.ts +0 -12
- package/dist/helper-f29f082f.d.ts +0 -19
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/rpc/bullmq/index.js.map +0 -1
- package/dist/rpc/bullmq/index.mjs.map +0 -1
- package/dist/rpc/kafka/index.js.map +0 -1
- package/dist/rpc/kafka/index.mjs.map +0 -1
- package/dist/rpc/nats/index.js.map +0 -1
- package/dist/rpc/nats/index.mjs.map +0 -1
- package/dist/rpc/rabbitmq/index.js.map +0 -1
- package/dist/rpc/rabbitmq/index.mjs.map +0 -1
- package/dist/rpc/redis/index.js.map +0 -1
- package/dist/rpc/redis/index.mjs.map +0 -1
- package/dist/server/elysia/index.js.map +0 -1
- package/dist/server/elysia/index.mjs.map +0 -1
- package/dist/server/express/index.js.map +0 -1
- package/dist/server/express/index.mjs.map +0 -1
- package/dist/server/fastify/index.js.map +0 -1
- package/dist/server/fastify/index.mjs.map +0 -1
- package/dist/server/h3/index.js.map +0 -1
- package/dist/server/h3/index.mjs.map +0 -1
- package/dist/server/hono/index.js.map +0 -1
- package/dist/server/hono/index.mjs.map +0 -1
- package/dist/server/hyper-express/index.js.map +0 -1
- package/dist/server/hyper-express/index.mjs.map +0 -1
- package/dist/server/koa/index.js.map +0 -1
- package/dist/server/koa/index.mjs.map +0 -1
- package/dist/test.js.map +0 -1
- package/dist/test.mjs.map +0 -1
package/dist/server/koa/index.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkBSE2DSDKjs = require('../../chunk-BSE2DSDK.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkZP7HNASUjs = require('../../chunk-ZP7HNASU.js');
|
|
12
12
|
|
|
13
13
|
// src/server/koa/bind.ts
|
|
14
14
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -17,14 +17,14 @@ function bind(router, data, opts = {}) {
|
|
|
17
17
|
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
19
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
20
|
-
const metaMap =
|
|
20
|
+
const metaMap = _chunkBSE2DSDKjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
21
21
|
const { controller, http, func, tag } = meta2.data;
|
|
22
22
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
23
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
_chunkBSE2DSDKjs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
plugins: [
|
|
29
29
|
...globalPlugins,
|
|
30
30
|
...parallelPlugins
|
|
@@ -34,28 +34,28 @@ function bind(router, data, opts = {}) {
|
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
36
|
async function registerRoute() {
|
|
37
|
-
|
|
37
|
+
_chunkBSE2DSDKjs.Context.usePlugin(globalPlugins, "koa").forEach((p) => router.use(p));
|
|
38
38
|
if (parallelRoute) {
|
|
39
|
-
router.post(parallelRoute, ...
|
|
39
|
+
router.post(parallelRoute, ..._chunkBSE2DSDKjs.Context.usePlugin(parallelPlugins, "koa"), async (ctx, next) => {
|
|
40
40
|
const { body } = ctx.request;
|
|
41
41
|
async function errorHandler(e) {
|
|
42
|
-
const error = await
|
|
42
|
+
const error = await _chunkBSE2DSDKjs.Context.filterRecord.default(e);
|
|
43
43
|
ctx.status = error.status;
|
|
44
44
|
ctx.body = error;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
_chunkZP7HNASUjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
47
|
if (!Array.isArray(body))
|
|
48
|
-
return errorHandler(new (0,
|
|
48
|
+
return errorHandler(new (0, _chunkBSE2DSDKjs.BadRequestException)("data format should be an array"));
|
|
49
49
|
try {
|
|
50
50
|
return Promise.all(body.map((item, i) => {
|
|
51
51
|
return new Promise(async (resolve) => {
|
|
52
52
|
const { tag, func } = item;
|
|
53
53
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
54
54
|
if (!metaMap.has(tag))
|
|
55
|
-
return resolve(await
|
|
55
|
+
return resolve(await _chunkBSE2DSDKjs.Context.filterRecord.default(new (0, _chunkBSE2DSDKjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
56
56
|
const meta2 = metaMap.get(tag)[func];
|
|
57
57
|
if (!meta2)
|
|
58
|
-
return resolve(await
|
|
58
|
+
return resolve(await _chunkBSE2DSDKjs.Context.filterRecord.default(new (0, _chunkBSE2DSDKjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
59
|
const { data: { params } } = meta2;
|
|
60
60
|
const contextData = {
|
|
61
61
|
type: "koa",
|
|
@@ -66,11 +66,11 @@ function bind(router, data, opts = {}) {
|
|
|
66
66
|
parallel: true,
|
|
67
67
|
next,
|
|
68
68
|
app: router,
|
|
69
|
-
...
|
|
69
|
+
..._chunkBSE2DSDKjs.argToReq.call(void 0, params, item.args, ctx.headers),
|
|
70
70
|
tag,
|
|
71
71
|
func
|
|
72
72
|
};
|
|
73
|
-
const context = new (0,
|
|
73
|
+
const context = new (0, _chunkBSE2DSDKjs.Context)(contextData);
|
|
74
74
|
context.run({
|
|
75
75
|
globalGuards,
|
|
76
76
|
globalInterceptors,
|
|
@@ -92,7 +92,7 @@ function bind(router, data, opts = {}) {
|
|
|
92
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, ..._chunkBSE2DSDKjs.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, data, opts = {}) {
|
|
|
108
108
|
headers: ctx.headers,
|
|
109
109
|
next
|
|
110
110
|
};
|
|
111
|
-
const context = new (0,
|
|
111
|
+
const context = new (0, _chunkBSE2DSDKjs.Context)(contextData);
|
|
112
112
|
if (http.headers) {
|
|
113
113
|
for (const name in http.headers)
|
|
114
114
|
ctx.set(name, http.headers[name]);
|
|
@@ -132,14 +132,13 @@ function bind(router, data, opts = {}) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
_chunkZP7HNASUjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
136
|
+
_chunkBSE2DSDKjs.HMR.call(void 0, async () => {
|
|
137
137
|
router.stack = originStack;
|
|
138
138
|
registerRoute();
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
_chunkZP7HNASUjs.__name.call(void 0, bind, "bind");
|
|
142
142
|
|
|
143
143
|
|
|
144
144
|
exports.bind = bind;
|
|
145
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
7
|
detectAopDep
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-JE6BBDXW.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-VLV3AO3H.mjs";
|
|
12
12
|
|
|
13
13
|
// src/server/koa/bind.ts
|
|
14
14
|
import Debug from "debug";
|
|
@@ -142,4 +142,3 @@ __name(bind, "bind");
|
|
|
142
142
|
export {
|
|
143
143
|
bind
|
|
144
144
|
};
|
|
145
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/test.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ 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
|
|
5
|
+
import { F as Factory } from './core-7f6d2be6.js';
|
|
6
|
+
import { P as PickFunc } from './types-81be0ba3.js';
|
|
6
7
|
|
|
7
8
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
8
9
|
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 _chunk5BVUCNMAjs = require('./chunk-5BVUCNMA.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 _chunk5BVUCNMAjs.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,13 +67,12 @@ 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
|
|
|
78
78
|
exports.TestFactory = TestFactory; exports.TestHttp = TestHttp;
|
|
79
|
-
//# sourceMappingURL=test.js.map
|
package/dist/test.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Factory
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CKQW3FDK.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VLV3AO3H.mjs";
|
|
7
7
|
|
|
8
8
|
// src/test.ts
|
|
9
9
|
import { getTag } from "phecda-core";
|
|
@@ -76,4 +76,3 @@ export {
|
|
|
76
76
|
TestFactory,
|
|
77
77
|
TestHttp
|
|
78
78
|
};
|
|
79
|
-
//# sourceMappingURL=test.mjs.map
|
|
@@ -19,7 +19,7 @@ interface ControllerMetaData extends ServiceMetaData {
|
|
|
19
19
|
queue?: string;
|
|
20
20
|
isEvent?: boolean;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
ctxs?: string[];
|
|
23
23
|
params: {
|
|
24
24
|
type: string;
|
|
25
25
|
index: number;
|
|
@@ -105,26 +105,4 @@ declare class CustomResponse<Value> {
|
|
|
105
105
|
}
|
|
106
106
|
type ExtractResponse<Class extends CustomResponse<any>> = Class extends CustomResponse<infer Value> ? Value : never;
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
path: string;
|
|
110
|
-
constructor(path: string);
|
|
111
|
-
abstract name: string;
|
|
112
|
-
abstract generateCode(meta: MetaData[]): string;
|
|
113
|
-
output(meta: Meta[]): Promise<void>;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
declare const emitter: Emitter;
|
|
117
|
-
declare function Factory(models: (new (...args: any) => any)[], opts?: {
|
|
118
|
-
parseModule?: (module: any) => any;
|
|
119
|
-
parseMeta?: (meta: Meta) => Meta | null | undefined;
|
|
120
|
-
generators?: Generator[];
|
|
121
|
-
}): Promise<{
|
|
122
|
-
moduleMap: Map<PropertyKey, any>;
|
|
123
|
-
constructorMap: Map<any, any>;
|
|
124
|
-
meta: Meta[];
|
|
125
|
-
add: (Model: Construct) => Promise<void>;
|
|
126
|
-
del: (tag: PropertyKey) => Promise<any>;
|
|
127
|
-
destroy: () => Promise<void>;
|
|
128
|
-
}>;
|
|
129
|
-
|
|
130
|
-
export { BaseContext as B, ControllerMetaData as C, DefaultOptions as D, Emitter as E, Factory as F, Generator as G, IS_HMR as I, LOG_LEVEL as L, Meta as M, OmitFunction as O, PickFunc as P, ServiceMetaData as S, ToClientMap as T, UNMOUNT_SYMBOL as U, MetaData as a, BaseError as b, ToClientInstance as c, ToClientFn as d, BaseReturn as e, BaseRequestType as f, CustomResponse as g, ExtractResponse as h, emitter as i, ControllerMeta as j, ERROR_SYMBOL as k, IS_ONLY_GENERATE as l, IS_STRICT as m, PS_EXIT_CODE as n };
|
|
108
|
+
export { BaseContext as B, ControllerMetaData as C, DefaultOptions as D, Emitter as E, IS_HMR as I, LOG_LEVEL as L, MetaData as M, OmitFunction as O, PickFunc as P, ServiceMetaData as S, ToClientMap as T, UNMOUNT_SYMBOL as U, BaseError as a, ToClientInstance as b, ToClientFn as c, BaseReturn as d, BaseRequestType as e, CustomResponse as f, ExtractResponse as g, Meta as h, ControllerMeta as i, ERROR_SYMBOL as j, IS_ONLY_GENERATE as k, IS_STRICT as l, PS_EXIT_CODE as m };
|
package/package.json
CHANGED
|
@@ -1,74 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
5
|
+
"author": "fgsreally",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": "https://github.com/fgsreally/phecda/tree/main/packages/server",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"server",
|
|
10
|
+
"IOC",
|
|
11
|
+
"rpc",
|
|
12
|
+
"types-share"
|
|
13
|
+
],
|
|
11
14
|
"exports": {
|
|
12
15
|
".": {
|
|
13
|
-
"import": "./dist/index.mjs",
|
|
14
16
|
"require": "./dist/index.js",
|
|
17
|
+
"import": "./dist/index.mjs",
|
|
15
18
|
"node": "./dist/index.js"
|
|
16
19
|
},
|
|
20
|
+
"./helper": {
|
|
21
|
+
"require": "./dist/helper.js",
|
|
22
|
+
"import": "./dist/helper.mjs"
|
|
23
|
+
},
|
|
17
24
|
"./test": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
25
|
+
"require": "./dist/test.js",
|
|
26
|
+
"import": "./dist/test.mjs"
|
|
20
27
|
},
|
|
21
28
|
"./h3": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
29
|
+
"require": "./dist/server/h3/index.js",
|
|
30
|
+
"import": "./dist/server/h3/index.mjs"
|
|
24
31
|
},
|
|
25
32
|
"./express": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
33
|
+
"require": "./dist/server/express/index.js",
|
|
34
|
+
"import": "./dist/server/express/index.mjs"
|
|
28
35
|
},
|
|
29
36
|
"./koa": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
37
|
+
"require": "./dist/server/koa/index.js",
|
|
38
|
+
"import": "./dist/server/koa/index.mjs"
|
|
32
39
|
},
|
|
33
40
|
"./fastify": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
41
|
+
"require": "./dist/server/fastify/index.js",
|
|
42
|
+
"import": "./dist/server/fastify/index.mjs"
|
|
36
43
|
},
|
|
37
44
|
"./hyper-express": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
45
|
+
"require": "./dist/server/hyper-express/index.js",
|
|
46
|
+
"import": "./dist/server/hyper-express/index.mjs"
|
|
40
47
|
},
|
|
41
48
|
"./hono": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
49
|
+
"require": "./dist/server/hono/index.js",
|
|
50
|
+
"import": "./dist/server/hono/index.mjs"
|
|
44
51
|
},
|
|
45
52
|
"./elysia": {
|
|
46
|
-
"
|
|
47
|
-
"
|
|
53
|
+
"require": "./dist/server/elysia/index.js",
|
|
54
|
+
"import": "./dist/server/elysia/index.mjs"
|
|
48
55
|
},
|
|
49
56
|
"./redis": {
|
|
50
|
-
"
|
|
51
|
-
"
|
|
57
|
+
"require": "./dist/rpc/redis/index.js",
|
|
58
|
+
"import": "./dist/rpc/redis/index.mjs"
|
|
52
59
|
},
|
|
53
60
|
"./kafka": {
|
|
54
|
-
"
|
|
55
|
-
"
|
|
61
|
+
"require": "./dist/rpc/kafka/index.js",
|
|
62
|
+
"import": "./dist/rpc/kafka/index.mjs"
|
|
56
63
|
},
|
|
57
64
|
"./rabbitmq": {
|
|
58
|
-
"
|
|
59
|
-
"
|
|
65
|
+
"require": "./dist/rpc/rabbitmq/index.js",
|
|
66
|
+
"import": "./dist/rpc/rabbitmq/index.mjs"
|
|
60
67
|
},
|
|
61
68
|
"./bullmq": {
|
|
62
|
-
"
|
|
63
|
-
"
|
|
69
|
+
"require": "./dist/rpc/bullmq/index.js",
|
|
70
|
+
"import": "./dist/rpc/bullmq/index.mjs"
|
|
64
71
|
},
|
|
65
72
|
"./nats": {
|
|
66
|
-
"
|
|
67
|
-
"
|
|
73
|
+
"require": "./dist/rpc/nats/index.js",
|
|
74
|
+
"import": "./dist/rpc/nats/index.mjs"
|
|
68
75
|
},
|
|
69
76
|
"./register": "./register/index.mjs",
|
|
70
77
|
"./*": "./*"
|
|
71
78
|
},
|
|
79
|
+
"main": "dist/index.js",
|
|
80
|
+
"module": "dist/index.mjs",
|
|
81
|
+
"types": "dist/index.d.ts",
|
|
72
82
|
"typesVersions": {
|
|
73
83
|
"*": {
|
|
74
84
|
".": [
|
|
@@ -77,6 +87,9 @@
|
|
|
77
87
|
"test": [
|
|
78
88
|
"dist/test.d.ts"
|
|
79
89
|
],
|
|
90
|
+
"helper": [
|
|
91
|
+
"dist/helper.d.ts"
|
|
92
|
+
],
|
|
80
93
|
"h3": [
|
|
81
94
|
"dist/server/h3/index.d.ts"
|
|
82
95
|
],
|
|
@@ -115,20 +128,25 @@
|
|
|
115
128
|
]
|
|
116
129
|
}
|
|
117
130
|
},
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
"rpc",
|
|
122
|
-
"types-share"
|
|
123
|
-
],
|
|
124
|
-
"author": "fgsreally",
|
|
125
|
-
"repository": "https://github.com/fgsreally/phecda/tree/main/packages/server",
|
|
131
|
+
"bin": {
|
|
132
|
+
"phecda": "bin/cli.mjs"
|
|
133
|
+
},
|
|
126
134
|
"files": [
|
|
127
135
|
"dist",
|
|
136
|
+
"assets",
|
|
128
137
|
"register",
|
|
129
138
|
"bin"
|
|
130
139
|
],
|
|
131
|
-
"
|
|
140
|
+
"dependencies": {
|
|
141
|
+
"@swc-node/core": "^1.10.6",
|
|
142
|
+
"cac": "^6.7.14",
|
|
143
|
+
"chokidar": "^3.5.3",
|
|
144
|
+
"debug": "^4.3.4",
|
|
145
|
+
"fs-extra": "^11.2.0",
|
|
146
|
+
"picocolors": "^1.0.0",
|
|
147
|
+
"reflect-metadata": "^0.1.13",
|
|
148
|
+
"phecda-core": "3.0.0"
|
|
149
|
+
},
|
|
132
150
|
"devDependencies": {
|
|
133
151
|
"@koa/router": "^12.0.1",
|
|
134
152
|
"@nucleoidjs/kafkajs-mock": "^0.0.1",
|
|
@@ -156,19 +174,9 @@
|
|
|
156
174
|
"nats": "^2.22.0",
|
|
157
175
|
"supertest": "^6.3.3",
|
|
158
176
|
"tsup": "^6.5.0",
|
|
159
|
-
"typescript": "^5.
|
|
177
|
+
"typescript": "^5.4.5",
|
|
160
178
|
"unimport": "^3.7.1"
|
|
161
179
|
},
|
|
162
|
-
"dependencies": {
|
|
163
|
-
"@swc-node/core": "^1.10.6",
|
|
164
|
-
"cac": "^6.7.14",
|
|
165
|
-
"chokidar": "^3.5.3",
|
|
166
|
-
"debug": "^4.3.4",
|
|
167
|
-
"fs-extra": "^11.2.0",
|
|
168
|
-
"picocolors": "^1.0.0",
|
|
169
|
-
"reflect-metadata": "^0.1.13",
|
|
170
|
-
"phecda-core": "3.0.0"
|
|
171
|
-
},
|
|
172
180
|
"scripts": {
|
|
173
181
|
"dev": "tsup --watch",
|
|
174
182
|
"build": "tsup"
|
package/register/index.mjs
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { register } from 'node:module'
|
|
2
|
-
import { MessageChannel } from 'node:worker_threads'
|
|
3
|
-
import { log } from '../dist/index.mjs'
|
|
4
|
-
const { port1, port2 } = new MessageChannel()
|
|
5
|
-
|
|
6
|
-
register('./loader.mjs', {
|
|
7
|
-
parentURL: import.meta.url,
|
|
8
|
-
data: { port: port2 },
|
|
9
|
-
transferList: [port2],
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
let isRunning = true
|
|
13
|
-
|
|
14
|
-
port1.on('message', async (data) => {
|
|
15
|
-
const { type, files } = JSON.parse(data)
|
|
16
|
-
|
|
17
|
-
if (!isRunning || !globalThis.__PS_HMR__ || type === 'relaunch')
|
|
18
|
-
return process.exit(2)// file change -> relaunch
|
|
19
|
-
|
|
20
|
-
if (type === 'change') {
|
|
21
|
-
log('reload module...')
|
|
22
|
-
|
|
23
|
-
for (const cb of globalThis.__PS_HMR__) await cb(files)
|
|
24
|
-
|
|
25
|
-
log('reload done')
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
process.on('uncaughtException', (err) => {
|
|
30
|
-
log('Uncaught Exception:', 'error')
|
|
31
|
-
isRunning = false
|
|
32
|
-
console.error(err)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
process.on('unhandledRejection', (err) => {
|
|
36
|
-
log('Unhandled Promise Rejection:', 'error')
|
|
37
|
-
isRunning = false
|
|
38
|
-
|
|
39
|
-
console.error(err)
|
|
40
|
-
})
|
|
1
|
+
import { register } from 'node:module'
|
|
2
|
+
import { MessageChannel } from 'node:worker_threads'
|
|
3
|
+
import { log } from '../dist/index.mjs'
|
|
4
|
+
const { port1, port2 } = new MessageChannel()
|
|
5
|
+
|
|
6
|
+
register('./loader.mjs', {
|
|
7
|
+
parentURL: import.meta.url,
|
|
8
|
+
data: { port: port2 },
|
|
9
|
+
transferList: [port2],
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
let isRunning = true
|
|
13
|
+
|
|
14
|
+
port1.on('message', async (data) => {
|
|
15
|
+
const { type, files } = JSON.parse(data)
|
|
16
|
+
|
|
17
|
+
if (!isRunning || !globalThis.__PS_HMR__ || type === 'relaunch')
|
|
18
|
+
return process.exit(2)// file change -> relaunch
|
|
19
|
+
|
|
20
|
+
if (type === 'change') {
|
|
21
|
+
log('reload module...')
|
|
22
|
+
|
|
23
|
+
for (const cb of globalThis.__PS_HMR__) await cb(files)
|
|
24
|
+
|
|
25
|
+
log('reload done')
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
process.on('uncaughtException', (err) => {
|
|
30
|
+
log('Uncaught Exception:', 'error')
|
|
31
|
+
isRunning = false
|
|
32
|
+
console.error(err)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
process.on('unhandledRejection', (err) => {
|
|
36
|
+
log('Unhandled Promise Rejection:', 'error')
|
|
37
|
+
isRunning = false
|
|
38
|
+
|
|
39
|
+
console.error(err)
|
|
40
|
+
})
|