phecda-server 7.0.0-alpha.9 → 7.0.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/schema.json +12 -9
- package/bin/cli.mjs +96 -37
- package/dist/chunk-5SUY5UVC.js +258 -0
- package/dist/chunk-5SUY5UVC.js.map +1 -0
- package/dist/{chunk-7ZGYJ5OW.mjs → chunk-6JAHCTOT.mjs} +7 -2
- package/dist/chunk-6JAHCTOT.mjs.map +1 -0
- package/dist/{chunk-V5EYXVJT.js → chunk-EDAWJVJ4.js} +42 -25
- package/dist/chunk-EDAWJVJ4.js.map +1 -0
- package/dist/{chunk-FX3LDQII.js → chunk-H7OCHDZT.js} +61 -70
- package/dist/chunk-H7OCHDZT.js.map +1 -0
- package/dist/chunk-KRUOHWFR.js +306 -0
- package/dist/chunk-KRUOHWFR.js.map +1 -0
- package/dist/{chunk-KJUD2BKE.js → chunk-KUGU3UGO.js} +23 -18
- package/dist/chunk-KUGU3UGO.js.map +1 -0
- package/dist/{chunk-CVPZWDXU.mjs → chunk-LBH4RXQQ.mjs} +11 -20
- package/dist/chunk-LBH4RXQQ.mjs.map +1 -0
- package/dist/{chunk-FXTJ3BJ6.mjs → chunk-MDPW6WGF.mjs} +10 -4
- package/dist/chunk-MDPW6WGF.mjs.map +1 -0
- package/dist/{chunk-5RBTN33A.js → chunk-RLFCI3RG.js} +11 -5
- package/dist/chunk-RLFCI3RG.js.map +1 -0
- package/dist/{chunk-ODVWOXVB.mjs → chunk-TTHYUNOT.mjs} +18 -1
- package/dist/chunk-TTHYUNOT.mjs.map +1 -0
- package/dist/chunk-VDOICQ2U.mjs +258 -0
- package/dist/chunk-VDOICQ2U.mjs.map +1 -0
- package/dist/chunk-WTJKTICN.mjs +306 -0
- package/dist/chunk-WTJKTICN.mjs.map +1 -0
- package/dist/{core-D_cz0tKa.d.ts → core-BOo3uGFX.d.ts} +2 -2
- package/dist/{core-BDkhrEyf.d.mts → core-CF45G79J.d.mts} +2 -2
- package/dist/core-DbqWh47p.d.mts +50 -0
- package/dist/core-Rq7BhPHE.d.ts +50 -0
- package/dist/helper.d.mts +3 -5
- package/dist/helper.d.ts +3 -5
- package/dist/helper.js +4 -5
- package/dist/helper.js.map +1 -0
- package/dist/helper.mjs +3 -4
- package/dist/helper.mjs.map +1 -0
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +42 -40
- package/dist/http/elysia/index.js.map +1 -0
- package/dist/http/elysia/index.mjs +5 -3
- package/dist/http/elysia/index.mjs.map +1 -0
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +39 -37
- package/dist/http/express/index.js.map +1 -0
- package/dist/http/express/index.mjs +4 -2
- package/dist/http/express/index.mjs.map +1 -0
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +40 -38
- package/dist/http/fastify/index.js.map +1 -0
- package/dist/http/fastify/index.mjs +5 -3
- package/dist/http/fastify/index.mjs.map +1 -0
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +40 -38
- package/dist/http/h3/index.js.map +1 -0
- package/dist/http/h3/index.mjs +4 -2
- package/dist/http/h3/index.mjs.map +1 -0
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +36 -34
- package/dist/http/hono/index.js.map +1 -0
- package/dist/http/hono/index.mjs +4 -2
- package/dist/http/hono/index.mjs.map +1 -0
- package/dist/http/hyper-express/index.d.mts +3 -3
- package/dist/http/hyper-express/index.d.ts +3 -3
- package/dist/http/hyper-express/index.js +37 -35
- package/dist/http/hyper-express/index.js.map +1 -0
- package/dist/http/hyper-express/index.mjs +4 -2
- package/dist/http/hyper-express/index.mjs.map +1 -0
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +39 -37
- package/dist/http/koa/index.js.map +1 -0
- package/dist/http/koa/index.mjs +4 -2
- package/dist/http/koa/index.mjs.map +1 -0
- package/dist/index.d.mts +76 -12
- package/dist/index.d.ts +76 -12
- package/dist/index.js +105 -49
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +68 -12
- package/dist/index.mjs.map +1 -0
- package/dist/{meta-BX5jhe4Z.d.mts → meta-BoS1E-Nz.d.mts} +6 -23
- package/dist/{meta-BX5jhe4Z.d.ts → meta-BoS1E-Nz.d.ts} +6 -23
- package/dist/rpc/bullmq/index.d.mts +4 -6
- package/dist/rpc/bullmq/index.d.ts +4 -6
- package/dist/rpc/bullmq/index.js +13 -80
- package/dist/rpc/bullmq/index.js.map +1 -0
- package/dist/rpc/bullmq/index.mjs +5 -72
- package/dist/rpc/bullmq/index.mjs.map +1 -0
- package/dist/rpc/electron/index.d.mts +13 -0
- package/dist/rpc/electron/index.d.ts +13 -0
- package/dist/rpc/electron/index.js +73 -0
- package/dist/rpc/electron/index.js.map +1 -0
- package/dist/rpc/electron/index.mjs +73 -0
- package/dist/rpc/electron/index.mjs.map +1 -0
- package/dist/rpc/kafka/index.d.mts +4 -9
- package/dist/rpc/kafka/index.d.ts +4 -9
- package/dist/rpc/kafka/index.js +12 -90
- package/dist/rpc/kafka/index.js.map +1 -0
- package/dist/rpc/kafka/index.mjs +5 -83
- package/dist/rpc/kafka/index.mjs.map +1 -0
- package/dist/rpc/nats/index.d.mts +4 -6
- package/dist/rpc/nats/index.d.ts +4 -6
- package/dist/rpc/nats/index.js +13 -72
- package/dist/rpc/nats/index.js.map +1 -0
- package/dist/rpc/nats/index.mjs +4 -63
- package/dist/rpc/nats/index.mjs.map +1 -0
- package/dist/rpc/rabbitmq/index.d.mts +4 -6
- package/dist/rpc/rabbitmq/index.d.ts +4 -6
- package/dist/rpc/rabbitmq/index.js +14 -79
- package/dist/rpc/rabbitmq/index.js.map +1 -0
- package/dist/rpc/rabbitmq/index.mjs +5 -70
- package/dist/rpc/rabbitmq/index.mjs.map +1 -0
- package/dist/rpc/redis/index.d.mts +4 -9
- package/dist/rpc/redis/index.d.ts +4 -9
- package/dist/rpc/redis/index.js +12 -78
- package/dist/rpc/redis/index.js.map +1 -0
- package/dist/rpc/redis/index.mjs +5 -71
- package/dist/rpc/redis/index.mjs.map +1 -0
- package/dist/rpc/web-ext/index.d.mts +2 -0
- package/dist/rpc/web-ext/index.d.ts +2 -0
- package/dist/rpc/web-ext/index.js +1 -0
- package/dist/rpc/web-ext/index.js.map +1 -0
- package/dist/rpc/web-ext/index.mjs +1 -0
- package/dist/rpc/web-ext/index.mjs.map +1 -0
- package/dist/rpc/ws/index.d.mts +14 -0
- package/dist/rpc/ws/index.d.ts +14 -0
- package/dist/rpc/ws/index.js +74 -0
- package/dist/rpc/ws/index.js.map +1 -0
- package/dist/rpc/ws/index.mjs +74 -0
- package/dist/rpc/ws/index.mjs.map +1 -0
- package/dist/test.d.mts +7 -3
- package/dist/test.d.ts +7 -3
- package/dist/test.js +7 -6
- package/dist/test.js.map +1 -0
- package/dist/test.mjs +3 -2
- package/dist/test.mjs.map +1 -0
- package/dist/types-CInz3bD0.d.ts +14 -0
- package/dist/types-E-rqlg3-.d.mts +14 -0
- package/dist/{types-DKVhyZk_.d.mts → types-SCJZFCYt.d.mts} +1 -1
- package/dist/{types-CMeuFoyd.d.ts → types-xruyYmyu.d.ts} +1 -1
- package/package.json +24 -8
- package/register/export.mjs +30 -0
- package/register/index.mjs +2 -3
- package/register/loader.mjs +83 -90
- package/register/utils.mjs +36 -6
- package/assets/ps.json +0 -24
- package/assets/tsconfig.json +0 -21
- package/dist/types-B-rUM9Fm.d.mts +0 -19
- package/dist/types-MxxtkZXw.d.ts +0 -19
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkH7OCHDZTjs = require('../../chunk-H7OCHDZT.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkRLFCI3RGjs = require('../../chunk-RLFCI3RG.js');
|
|
9
|
+
|
|
10
|
+
// src/rpc/ws/bind.ts
|
|
11
|
+
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
12
|
+
var debug = _debug2.default.call(void 0, "phecda-server/ws");
|
|
13
|
+
function bind(wss, data, opts = {}) {
|
|
14
|
+
const { globalGuards, globalAddons, globalFilter, globalPipe } = opts;
|
|
15
|
+
const { moduleMap, meta } = data;
|
|
16
|
+
const metaMap = _chunkH7OCHDZTjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
17
|
+
const { controller, rpc, func, tag } = meta2.data;
|
|
18
|
+
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
|
|
19
|
+
debug(`register method "${func}" in module "${tag}"`);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
_chunkH7OCHDZTjs.detectAopDep.call(void 0, meta, {
|
|
24
|
+
guards: globalGuards,
|
|
25
|
+
addons: globalAddons
|
|
26
|
+
}, "rpc");
|
|
27
|
+
wss.on("connection", (ws) => {
|
|
28
|
+
ws.on("message", async (raw) => {
|
|
29
|
+
try {
|
|
30
|
+
const data2 = JSON.parse(raw.toString());
|
|
31
|
+
const { func, id, tag, _ps, args, queue } = data2;
|
|
32
|
+
if (_ps !== 1) return;
|
|
33
|
+
const meta2 = metaMap.get(tag)[func];
|
|
34
|
+
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
35
|
+
const aop = _chunkH7OCHDZTjs.Context.getAop(meta2, {
|
|
36
|
+
globalFilter,
|
|
37
|
+
globalGuards,
|
|
38
|
+
globalPipe
|
|
39
|
+
});
|
|
40
|
+
const context = new (0, _chunkH7OCHDZTjs.Context)({
|
|
41
|
+
type: "ws",
|
|
42
|
+
category: "rpc",
|
|
43
|
+
meta: meta2,
|
|
44
|
+
moduleMap,
|
|
45
|
+
tag,
|
|
46
|
+
func,
|
|
47
|
+
args,
|
|
48
|
+
id,
|
|
49
|
+
queue,
|
|
50
|
+
wss,
|
|
51
|
+
ws
|
|
52
|
+
});
|
|
53
|
+
return await context.run(aop, (returnData) => {
|
|
54
|
+
if (!isEvent) ws.send(JSON.stringify({
|
|
55
|
+
id,
|
|
56
|
+
data: returnData
|
|
57
|
+
}));
|
|
58
|
+
}, (err) => {
|
|
59
|
+
if (!isEvent) ws.send(JSON.stringify({
|
|
60
|
+
id,
|
|
61
|
+
data: err,
|
|
62
|
+
error: true
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
} catch (e) {
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
_chunkRLFCI3RGjs.__name.call(void 0, bind, "bind");
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
exports.bind = bind;
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\myproject\\phecda\\packages\\server\\dist\\rpc\\ws\\index.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;AACA,4EAAyB;AACzB,IAAI,MAAM,EAAE,6BAAK,kBAAmB,CAAC;AACrC,SAAS,IAAI,CAAC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AAC;AACpB;AACE;AACF,oBAAC","file":"D:\\myproject\\phecda\\packages\\server\\dist\\rpc\\ws\\index.js","sourcesContent":[null]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Context,
|
|
3
|
+
createControllerMetaMap,
|
|
4
|
+
detectAopDep
|
|
5
|
+
} from "../../chunk-LBH4RXQQ.mjs";
|
|
6
|
+
import {
|
|
7
|
+
__name
|
|
8
|
+
} from "../../chunk-MDPW6WGF.mjs";
|
|
9
|
+
|
|
10
|
+
// src/rpc/ws/bind.ts
|
|
11
|
+
import Debug from "debug";
|
|
12
|
+
var debug = Debug("phecda-server/ws");
|
|
13
|
+
function bind(wss, data, opts = {}) {
|
|
14
|
+
const { globalGuards, globalAddons, globalFilter, globalPipe } = opts;
|
|
15
|
+
const { moduleMap, meta } = data;
|
|
16
|
+
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
17
|
+
const { controller, rpc, func, tag } = meta2.data;
|
|
18
|
+
if (controller === "rpc" && rpc?.queue !== void 0) {
|
|
19
|
+
debug(`register method "${func}" in module "${tag}"`);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
detectAopDep(meta, {
|
|
24
|
+
guards: globalGuards,
|
|
25
|
+
addons: globalAddons
|
|
26
|
+
}, "rpc");
|
|
27
|
+
wss.on("connection", (ws) => {
|
|
28
|
+
ws.on("message", async (raw) => {
|
|
29
|
+
try {
|
|
30
|
+
const data2 = JSON.parse(raw.toString());
|
|
31
|
+
const { func, id, tag, _ps, args, queue } = data2;
|
|
32
|
+
if (_ps !== 1) return;
|
|
33
|
+
const meta2 = metaMap.get(tag)[func];
|
|
34
|
+
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
35
|
+
const aop = Context.getAop(meta2, {
|
|
36
|
+
globalFilter,
|
|
37
|
+
globalGuards,
|
|
38
|
+
globalPipe
|
|
39
|
+
});
|
|
40
|
+
const context = new Context({
|
|
41
|
+
type: "ws",
|
|
42
|
+
category: "rpc",
|
|
43
|
+
meta: meta2,
|
|
44
|
+
moduleMap,
|
|
45
|
+
tag,
|
|
46
|
+
func,
|
|
47
|
+
args,
|
|
48
|
+
id,
|
|
49
|
+
queue,
|
|
50
|
+
wss,
|
|
51
|
+
ws
|
|
52
|
+
});
|
|
53
|
+
return await context.run(aop, (returnData) => {
|
|
54
|
+
if (!isEvent) ws.send(JSON.stringify({
|
|
55
|
+
id,
|
|
56
|
+
data: returnData
|
|
57
|
+
}));
|
|
58
|
+
}, (err) => {
|
|
59
|
+
if (!isEvent) ws.send(JSON.stringify({
|
|
60
|
+
id,
|
|
61
|
+
data: err,
|
|
62
|
+
error: true
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
} catch (e) {
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
__name(bind, "bind");
|
|
71
|
+
export {
|
|
72
|
+
bind
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/rpc/ws/bind.ts"],"sourcesContent":["import type WS from 'ws'\r\nimport Debug from 'debug'\r\n\r\nimport { createControllerMetaMap, detectAopDep } from '../../helper'\r\nimport { Factory } from '../../core'\r\nimport { Context } from '../../context'\r\nimport { RpcCtx, RpcServerOptions } from '../types'\r\nconst debug = Debug('phecda-server/ws')\r\n\r\nexport interface WsCtx extends RpcCtx {\r\n type: 'ws'\r\n ws: WS\r\n wss: WS.Server\r\n}\r\n\r\nexport function bind(wss: WS.Server, data: Awaited<ReturnType<typeof Factory>>, opts: RpcServerOptions = {}) {\r\n const { globalGuards, globalAddons, globalFilter, globalPipe } = opts\r\n const { moduleMap, meta } = data\r\n\r\n const metaMap = createControllerMetaMap(meta, (meta) => {\r\n const { controller, rpc, func, tag } = meta.data\r\n if (controller === 'rpc' && rpc?.queue !== undefined) {\r\n debug(`register method \"${func}\" in module \"${tag}\"`)\r\n return true\r\n }\r\n })\r\n\r\n detectAopDep(meta, {\r\n guards: globalGuards,\r\n addons: globalAddons,\r\n }, 'rpc')\r\n\r\n wss.on('connection', (ws) => {\r\n ws.on('message', async (raw) => {\r\n try {\r\n const data = JSON.parse(raw.toString())\r\n const { func, id, tag, _ps, args, queue } = data\r\n\r\n if (_ps !== 1)\r\n return\r\n\r\n const meta = metaMap.get(tag)![func]\r\n\r\n const {\r\n data: { rpc: { isEvent } = {} },\r\n } = meta\r\n\r\n const aop = Context.getAop(meta, {\r\n globalFilter,\r\n globalGuards,\r\n globalPipe,\r\n })\r\n\r\n const context = new Context<WsCtx>({\r\n type: 'ws' as const,\r\n category: 'rpc' as const,\r\n meta,\r\n moduleMap,\r\n tag,\r\n func,\r\n args,\r\n id,\r\n queue,\r\n wss,\r\n ws,\r\n })\r\n\r\n return await context.run(aop, (returnData) => {\r\n if (!isEvent)\r\n ws.send(JSON.stringify({ id, data: returnData }))\r\n }, (err) => {\r\n if (!isEvent)\r\n\r\n ws.send(JSON.stringify({ id, data: err, error: true }))\r\n })\r\n }\r\n catch (e) {\r\n // not a phecda-client request\r\n }\r\n })\r\n })\r\n}\r\n"],"mappings":";;;;;;;;;;AACA,OAAOA,WAAW;AAMlB,IAAMC,QAAQC,MAAM,kBAAA;AAQb,SAASC,KAAKC,KAAgBC,MAA2CC,OAAyB,CAAC,GAAC;AACzG,QAAM,EAAEC,cAAcC,cAAcC,cAAcC,WAAU,IAAKJ;AACjE,QAAM,EAAEK,WAAWC,KAAI,IAAKP;AAE5B,QAAMQ,UAAUC,wBAAwBF,MAAM,CAACA,UAAAA;AAC7C,UAAM,EAAEG,YAAYC,KAAKC,MAAMC,IAAG,IAAKN,MAAKP;AAC5C,QAAIU,eAAe,SAASC,KAAKG,UAAUC,QAAW;AACpDnB,YAAM,oBAAoBgB,IAAAA,gBAAoBC,GAAAA,GAAM;AACpD,aAAO;IACT;EACF,CAAA;AAEAG,eAAaT,MAAM;IACjBU,QAAQf;IACRgB,QAAQf;EACV,GAAG,KAAA;AAEHJ,MAAIoB,GAAG,cAAc,CAACC,OAAAA;AACpBA,OAAGD,GAAG,WAAW,OAAOE,QAAAA;AACtB,UAAI;AACF,cAAMrB,QAAOsB,KAAKC,MAAMF,IAAIG,SAAQ,CAAA;AACpC,cAAM,EAAEZ,MAAMa,IAAIZ,KAAKa,KAAKC,MAAMb,MAAK,IAAKd;AAE5C,YAAI0B,QAAQ,EACV;AAEF,cAAMnB,QAAOC,QAAQoB,IAAIf,GAAAA,EAAMD,IAAAA;AAE/B,cAAM,EACJZ,MAAM,EAAEW,KAAK,EAAEkB,QAAO,IAAK,CAAC,EAAC,EAAE,IAC7BtB;AAEJ,cAAMuB,MAAMC,QAAQC,OAAOzB,OAAM;UAC/BH;UACAF;UACAG;QACF,CAAA;AAEA,cAAM4B,UAAU,IAAIF,QAAe;UACjCG,MAAM;UACNC,UAAU;UACV5B,MAAAA;UACAD;UACAO;UACAD;UACAe;UACAF;UACAX;UACAf;UACAqB;QACF,CAAA;AAEA,eAAO,MAAMa,QAAQG,IAAIN,KAAK,CAACO,eAAAA;AAC7B,cAAI,CAACR,QACHT,IAAGkB,KAAKhB,KAAKiB,UAAU;YAAEd;YAAIzB,MAAMqC;UAAW,CAAA,CAAA;QAClD,GAAG,CAACG,QAAAA;AACF,cAAI,CAACX,QAEHT,IAAGkB,KAAKhB,KAAKiB,UAAU;YAAEd;YAAIzB,MAAMwC;YAAKC,OAAO;UAAK,CAAA,CAAA;QACxD,CAAA;MACF,SACOC,GAAG;MAEV;IACF,CAAA;EACF,CAAA;AACF;AAlEgB5C;","names":["Debug","debug","Debug","bind","wss","data","opts","globalGuards","globalAddons","globalFilter","globalPipe","moduleMap","meta","metaMap","createControllerMetaMap","controller","rpc","func","tag","queue","undefined","detectAopDep","guards","addons","on","ws","raw","JSON","parse","toString","id","_ps","args","get","isEvent","aop","Context","getAop","context","type","category","run","returnData","send","stringify","err","error","e"]}
|
package/dist/test.d.mts
CHANGED
|
@@ -2,9 +2,13 @@ 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 } from './core-
|
|
6
|
-
import {
|
|
5
|
+
import { F as Factory } from './core-DbqWh47p.mjs';
|
|
6
|
+
import { C as CustomResponse } from './meta-BoS1E-Nz.mjs';
|
|
7
7
|
|
|
8
|
+
type PickFuncKeys<Type> = {
|
|
9
|
+
[Key in keyof Type]: Type[Key] extends (...args: any) => any ? (ReturnType<Type[Key]> extends CustomResponse<any> ? never : Key) : never;
|
|
10
|
+
}[keyof Type];
|
|
11
|
+
type PickFunc<Instance> = Pick<Instance, PickFuncKeys<Instance>>;
|
|
8
12
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
9
13
|
get<C extends T[number]>(Model: C): InstanceType<C>;
|
|
10
14
|
}>;
|
|
@@ -15,4 +19,4 @@ declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<Return
|
|
|
15
19
|
module: <T extends Construct>(Module: T) => SuperTestRequest<PickFunc<InstanceType<T>>>;
|
|
16
20
|
}>;
|
|
17
21
|
|
|
18
|
-
export { type SuperTestRequest, TestFactory, TestHttp };
|
|
22
|
+
export { type PickFunc, type SuperTestRequest, TestFactory, TestHttp };
|
package/dist/test.d.ts
CHANGED
|
@@ -2,9 +2,13 @@ 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 } from './core-
|
|
6
|
-
import {
|
|
5
|
+
import { F as Factory } from './core-Rq7BhPHE.js';
|
|
6
|
+
import { C as CustomResponse } from './meta-BoS1E-Nz.js';
|
|
7
7
|
|
|
8
|
+
type PickFuncKeys<Type> = {
|
|
9
|
+
[Key in keyof Type]: Type[Key] extends (...args: any) => any ? (ReturnType<Type[Key]> extends CustomResponse<any> ? never : Key) : never;
|
|
10
|
+
}[keyof Type];
|
|
11
|
+
type PickFunc<Instance> = Pick<Instance, PickFuncKeys<Instance>>;
|
|
8
12
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
9
13
|
get<C extends T[number]>(Model: C): InstanceType<C>;
|
|
10
14
|
}>;
|
|
@@ -15,4 +19,4 @@ declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<Return
|
|
|
15
19
|
module: <T extends Construct>(Module: T) => SuperTestRequest<PickFunc<InstanceType<T>>>;
|
|
16
20
|
}>;
|
|
17
21
|
|
|
18
|
-
export { type SuperTestRequest, TestFactory, TestHttp };
|
|
22
|
+
export { type PickFunc, type SuperTestRequest, TestFactory, TestHttp };
|
package/dist/test.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkKRUOHWFRjs = require('./chunk-KRUOHWFR.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkRLFCI3RGjs = require('./chunk-RLFCI3RG.js');
|
|
7
7
|
|
|
8
8
|
// src/test.ts
|
|
9
9
|
var _phecdacore = require('phecda-core');
|
|
10
10
|
async function TestFactory(...Modules) {
|
|
11
|
-
const { moduleMap, modelMap } = await
|
|
11
|
+
const { moduleMap, modelMap } = await _chunkKRUOHWFRjs.Factory.call(void 0, Modules);
|
|
12
12
|
return {
|
|
13
13
|
get(Model) {
|
|
14
14
|
const tag = _phecdacore.getTag.call(void 0, Model);
|
|
@@ -19,7 +19,7 @@ async function TestFactory(...Modules) {
|
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
_chunkRLFCI3RGjs.__name.call(void 0, TestFactory, "TestFactory");
|
|
23
23
|
async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
24
24
|
const { default: request, agent } = await Promise.resolve().then(() => _interopRequireWildcard(require("supertest")));
|
|
25
25
|
const Agent = agent(app);
|
|
@@ -59,12 +59,13 @@ async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
_chunkRLFCI3RGjs.__name.call(void 0, module, "module");
|
|
63
63
|
Agent.module = module;
|
|
64
64
|
return Agent;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
_chunkRLFCI3RGjs.__name.call(void 0, TestHttp, "TestHttp");
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
exports.TestFactory = TestFactory; exports.TestHttp = TestHttp;
|
|
71
|
+
//# sourceMappingURL=test.js.map
|
package/dist/test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\myproject\\phecda\\packages\\server\\dist\\test.js"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;AACA,yCAAoC;AACpC,MAAM,SAAS,WAAW,CAAC,GAAG,OAAO,EAAE;AACvC,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,MAAM,sCAAO,OAAQ,CAAC;AACxD,EAAE,OAAO;AACT,IAAI,GAAG,CAAC,KAAK,EAAE;AACf,MAAM,MAAM,IAAI,EAAE,gCAAM,KAAM,CAAC;AAC/B,MAAM,MAAM,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC;AACvC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,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AAQ,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG;AAC5B,UAAU,MAAM,IAAI,EAAE;AACtB,YAAY,IAAI,EAAE,CAAC,CAAC;AACpB,YAAY,OAAO,EAAE,CAAC,CAAC;AACvB,YAAY,KAAK,EAAE,CAAC,CAAC;AACrB,YAAY,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;AAChC,YAAY,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC;AAC9C,UAAU,CAAC;AACX,UAAU,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,GAAG;AACxC,YAAY,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,QAAQ,EAAE;AACxC,cAAc,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;AACA,cAAA;AACA,YAAA;AACA,YAAA;AACA,cAAA;AACA,cAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,QAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA","file":"D:\\myproject\\phecda\\packages\\server\\dist\\test.js","sourcesContent":[null]}
|
package/dist/test.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Factory
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WTJKTICN.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-MDPW6WGF.mjs";
|
|
7
7
|
|
|
8
8
|
// src/test.ts
|
|
9
9
|
import { getTag } from "phecda-core";
|
|
@@ -68,3 +68,4 @@ export {
|
|
|
68
68
|
TestFactory,
|
|
69
69
|
TestHttp
|
|
70
70
|
};
|
|
71
|
+
//# sourceMappingURL=test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/test.ts"],"sourcesContent":["import type { Server } from 'node:http'\r\nimport type { SuperAgentTest, Test } from 'supertest'\r\nimport { type Construct, getTag } from 'phecda-core'\r\nimport { Factory } from './core'\r\n\r\nimport type { ControllerMeta } from './meta'\r\nimport { CustomResponse } from './types'\r\n\r\ntype PickFuncKeys<Type> = { [Key in keyof Type]: Type[Key] extends (...args: any) => any ? (ReturnType<Type[Key]> extends CustomResponse<any> ? never : Key) : never }[keyof Type]\r\nexport type PickFunc<Instance> = Pick<Instance, PickFuncKeys<Instance>>\r\nexport async function TestFactory<T extends Construct[]>(...Modules: T) {\r\n const { moduleMap, modelMap } = await Factory(Modules)\r\n\r\n return {\r\n get<C extends T[number]>(Model: C): InstanceType<C> {\r\n const tag = getTag(Model)\r\n const module = moduleMap.get(tag)\r\n\r\n if (!module)\r\n throw new Error(`module \"${String(tag)}\" doesn't exist`)\r\n\r\n if (modelMap.get(module) !== Model)\r\n throw new Error(`module \"${Model.name}\" and \"${String(tag)}\" in modulemap are different modules`)\r\n\r\n return module\r\n },\r\n }\r\n}\r\n\r\nexport type SuperTestRequest<T> = {\r\n [K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;\r\n}\r\n\r\nexport async function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent = true) {\r\n const { default: request, agent } = await import('supertest')\r\n const Agent = agent(app) as SuperAgentTest & { module: typeof module }\r\n\r\n function module<T extends Construct>(Module: T): SuperTestRequest<PickFunc<InstanceType<T>>> {\r\n const tag = getTag(Module)\r\n\r\n const module = moduleMap.get(tag)\r\n if (!module)\r\n throw new Error(`module \"${String(tag)}\" doesn't exist`)\r\n\r\n return new Proxy({}, {\r\n get(_target, p) {\r\n const { data } = (meta as ControllerMeta[]).find(({ data }) => data.name === Module.name && data.func === p && data.tag === tag)!\r\n return (...args: any) => {\r\n const ret = { body: {}, headers: {}, query: {}, func: data.http!.type, url: data.http!.prefix + data.http!.route } as any\r\n\r\n data.params.forEach((item) => {\r\n if (item.type === 'params') {\r\n ret.url = ret.url.replace(`:${item.key}`, args[item.index])\r\n return\r\n }\r\n if (item.type === 'query') {\r\n ret.query[item.key] = args[item.index]\r\n return\r\n }\r\n\r\n // body\r\n if (item.key)\r\n ret[item.type][item.key] = args[item.index]\r\n else\r\n ret[item.type] = args[item.index]\r\n })\r\n // @ts-expect-error @todo miss type\r\n let agent = (isAgent ? Agent : request(app))[ret.func](ret.url)\r\n if (Object.keys(ret.query).length > 0)\r\n agent = agent.query(ret.query)\r\n\r\n if (Object.keys(ret.headers).length > 0)\r\n agent = agent.set(ret.headers)\r\n\r\n if (Object.keys(ret.body).length > 0)\r\n agent = agent.send(ret.body)\r\n\r\n return agent\r\n }\r\n },\r\n }) as any\r\n }\r\n\r\n Agent.module = module\r\n\r\n return Agent\r\n}\r\n"],"mappings":";;;;;;;;AAEA,SAAyBA,cAAc;AAQvC,eAAsBC,eAAsCC,SAAU;AACpE,QAAM,EAAEC,WAAWC,SAAQ,IAAK,MAAMC,QAAQH,OAAAA;AAE9C,SAAO;IACLI,IAAyBC,OAAQ;AAC/B,YAAMC,MAAMC,OAAOF,KAAAA;AACnB,YAAMG,SAASP,UAAUG,IAAIE,GAAAA;AAE7B,UAAI,CAACE,OACH,OAAM,IAAIC,MAAM,WAAWC,OAAOJ,GAAAA,CAAAA,iBAAqB;AAEzD,UAAIJ,SAASE,IAAII,MAAAA,MAAYH,MAC3B,OAAM,IAAII,MAAM,WAAWJ,MAAMM,IAAI,UAAUD,OAAOJ,GAAAA,CAAAA,sCAA0C;AAElG,aAAOE;IACT;EACF;AACF;AAjBsBT;AAuBtB,eAAsBa,SAASC,KAAmB,EAAEZ,WAAWa,KAAI,GAAyCC,UAAU,MAAI;AACxH,QAAM,EAAEC,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9D,cAAIS,OAAOC,KAAKhB,IAAIG,KAAK,EAAEc,SAAS,EAClC3B,CAAAA,SAAQA,OAAMa,MAAMH,IAAIG,KAAK;AAE/B,cAAIY,OAAOC,KAAKhB,IAAIE,OAAO,EAAEe,SAAS,EACpC3B,CAAAA,SAAQA,OAAM4B,IAAIlB,IAAIE,OAAO;AAE/B,cAAIa,OAAOC,KAAKhB,IAAIC,IAAI,EAAEgB,SAAS,EACjC3B,CAAAA,SAAQA,OAAM6B,KAAKnB,IAAIC,IAAI;AAE7B,iBAAOX;QACT;MACF;IACF,CAAA;EACF;AA5CSV;AA8CTW,QAAMX,SAASA;AAEf,SAAOW;AACT;AArDsBP;","names":["getTag","TestFactory","Modules","moduleMap","modelMap","Factory","get","Model","tag","getTag","module","Error","String","name","TestHttp","app","meta","isAgent","default","request","agent","Agent","Module","Proxy","_target","p","data","find","func","args","ret","body","headers","query","http","type","url","prefix","route","params","forEach","item","replace","key","index","Object","keys","length","set","send"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { B as BaseCtx, D as DefaultOptions } from './meta-BoS1E-Nz.js';
|
|
2
|
+
|
|
3
|
+
interface RpcServerOptions extends DefaultOptions {
|
|
4
|
+
defaultQueue?: string;
|
|
5
|
+
}
|
|
6
|
+
interface RpcCtx extends BaseCtx {
|
|
7
|
+
args: any[];
|
|
8
|
+
id: string;
|
|
9
|
+
queue: string;
|
|
10
|
+
isEvent?: boolean;
|
|
11
|
+
category: 'rpc';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type { RpcCtx as R, RpcServerOptions as a };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { B as BaseCtx, D as DefaultOptions } from './meta-BoS1E-Nz.mjs';
|
|
2
|
+
|
|
3
|
+
interface RpcServerOptions extends DefaultOptions {
|
|
4
|
+
defaultQueue?: string;
|
|
5
|
+
}
|
|
6
|
+
interface RpcCtx extends BaseCtx {
|
|
7
|
+
args: any[];
|
|
8
|
+
id: string;
|
|
9
|
+
queue: string;
|
|
10
|
+
isEvent?: boolean;
|
|
11
|
+
category: 'rpc';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type { RpcCtx as R, RpcServerOptions as a };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import {
|
|
2
|
+
import { B as BaseCtx, D as DefaultOptions } from './meta-BoS1E-Nz.mjs';
|
|
3
3
|
|
|
4
4
|
interface HttpOptions extends DefaultOptions {
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import {
|
|
2
|
+
import { B as BaseCtx, D as DefaultOptions } from './meta-BoS1E-Nz.js';
|
|
3
3
|
|
|
4
4
|
interface HttpOptions extends DefaultOptions {
|
|
5
5
|
/**
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
|
|
5
5
|
"author": "fgsreally",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "https://github.com/fgsreally/phecda/tree/main/packages/server",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"server",
|
|
10
|
+
"http",
|
|
10
11
|
"IOC",
|
|
11
12
|
"rpc",
|
|
12
|
-
"types-
|
|
13
|
+
"types-safe"
|
|
13
14
|
],
|
|
14
15
|
"exports": {
|
|
15
16
|
".": {
|
|
16
17
|
"require": "./dist/index.js",
|
|
17
|
-
"import": "./dist/index.mjs"
|
|
18
|
-
"node": "./dist/index.js"
|
|
18
|
+
"import": "./dist/index.mjs"
|
|
19
19
|
},
|
|
20
20
|
"./helper": {
|
|
21
21
|
"require": "./dist/helper.js",
|
|
@@ -73,6 +73,18 @@
|
|
|
73
73
|
"require": "./dist/rpc/nats/index.js",
|
|
74
74
|
"import": "./dist/rpc/nats/index.mjs"
|
|
75
75
|
},
|
|
76
|
+
"./electron": {
|
|
77
|
+
"require": "./dist/rpc/electron/index.js",
|
|
78
|
+
"import": "./dist/rpc/electron/index.mjs"
|
|
79
|
+
},
|
|
80
|
+
"./ws": {
|
|
81
|
+
"require": "./dist/rpc/ws/index.js",
|
|
82
|
+
"import": "./dist/rpc/ws/index.mjs"
|
|
83
|
+
},
|
|
84
|
+
"./web-ext": {
|
|
85
|
+
"require": "./dist/rpc/web-ext/index.js",
|
|
86
|
+
"import": "./dist/rpc/web-ext/index.mjs"
|
|
87
|
+
},
|
|
76
88
|
"./register": "./register/index.mjs",
|
|
77
89
|
"./*": "./*"
|
|
78
90
|
},
|
|
@@ -144,27 +156,30 @@
|
|
|
144
156
|
"chokidar": "^3.5.3",
|
|
145
157
|
"debug": "^4.3.4",
|
|
146
158
|
"fs-extra": "^11.2.0",
|
|
147
|
-
"h3": "^1.12.0",
|
|
148
159
|
"picocolors": "^1.0.0",
|
|
149
160
|
"reflect-metadata": "^0.1.13",
|
|
150
161
|
"ts-mixer": "^6.0.4",
|
|
151
|
-
"phecda-core": "4.1.0
|
|
162
|
+
"phecda-core": "4.1.0"
|
|
152
163
|
},
|
|
153
164
|
"devDependencies": {
|
|
154
165
|
"@koa/router": "^12.0.1",
|
|
155
166
|
"@nucleoidjs/kafkajs-mock": "^0.0.1",
|
|
156
167
|
"@types/amqplib": "^0.10.1",
|
|
168
|
+
"@types/chrome": "^0.0.309",
|
|
157
169
|
"@types/debug": "^4.1.12",
|
|
158
170
|
"@types/express": "^4.17.17",
|
|
159
171
|
"@types/fs-extra": "^11.0.4",
|
|
160
172
|
"@types/koa": "^2.13.12",
|
|
161
173
|
"@types/koa__router": "^12.0.4",
|
|
162
174
|
"@types/supertest": "^2.0.12",
|
|
175
|
+
"@types/ws": "^8.5.13",
|
|
163
176
|
"amqplib": "^0.10.3",
|
|
164
177
|
"bullmq": "^5.7.1",
|
|
178
|
+
"electron": "^33.2.1",
|
|
165
179
|
"elysia": "^1.0.17",
|
|
166
180
|
"express": "^4.18.2",
|
|
167
181
|
"fastify": "^4.25.1",
|
|
182
|
+
"h3": "^1.12.0",
|
|
168
183
|
"hono": "^4.3.4",
|
|
169
184
|
"hyper-express": "^6.15.2",
|
|
170
185
|
"ioredis": "^5.3.2",
|
|
@@ -176,8 +191,9 @@
|
|
|
176
191
|
"nats": "^2.22.0",
|
|
177
192
|
"supertest": "^6.3.3",
|
|
178
193
|
"tsup": "^8.1.0",
|
|
179
|
-
"typescript": "^5.
|
|
180
|
-
"unimport": "^3.7.1"
|
|
194
|
+
"typescript": "^5.8.3",
|
|
195
|
+
"unimport": "^3.7.1",
|
|
196
|
+
"ws": "^8.18.0"
|
|
181
197
|
},
|
|
182
198
|
"scripts": {
|
|
183
199
|
"dev": "tsup --watch",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default ['Addon', 'Arg', 'Assign', 'BadGatewayException', 'BadRequestException',
|
|
2
|
+
'Base', 'Body', 'Clear',
|
|
3
|
+
'ConflictException', 'Controller',
|
|
4
|
+
'Ctx', 'CustomResponse',
|
|
5
|
+
'Delete',
|
|
6
|
+
'Define',
|
|
7
|
+
'ERROR_SYMBOL',
|
|
8
|
+
'Effect', 'Empty', 'Err', 'Exception', 'Expose', 'Factory', 'Filter', 'ForbiddenException',
|
|
9
|
+
'FrameworkException',
|
|
10
|
+
'Generator', 'Get', 'Global', 'Guard', 'HTTPGenerator', 'Head', 'Header', 'HttpBase',
|
|
11
|
+
'If', 'Init', 'Inject', 'Injectable',
|
|
12
|
+
'InvalidInputException', 'Isolate',
|
|
13
|
+
'Mixin',
|
|
14
|
+
'NotFoundException', 'PAddon', 'PExtension', 'PFilter', 'PGuard',
|
|
15
|
+
'PPipe', 'Param', 'Patch', 'PayloadLargeException', 'Pipe', 'Pipeline', 'Post',
|
|
16
|
+
'Provide', 'Put', 'Query', 'Queue', 'RPCGenerator', 'Route',
|
|
17
|
+
'Rpc', 'RpcBase', 'Search', 'ServerBase', 'ServerPhecda', 'ServiceUnavailableException', 'Storage',
|
|
18
|
+
'Tag', 'TimeoutException', 'TimerException', 'UnauthorizedException', 'UndefinedException',
|
|
19
|
+
'Unique', 'Unmount', 'UnsupportedMediaTypeException', 'ValidateException',
|
|
20
|
+
'Watcher', 'WorkerException',
|
|
21
|
+
'addAddon', 'addDecoToClass',
|
|
22
|
+
'addFilter', 'addGuard', 'addPipe', 'emitter',
|
|
23
|
+
'getMergedMeta',
|
|
24
|
+
'getMeta', 'getMetaKey', 'getMetaParams', 'getOwnMeta', 'getOwnMetaKey', 'getOwnMetaParams',
|
|
25
|
+
'getTag',
|
|
26
|
+
'isPhecda', 'log', 'phecdaNamespace', 'runMiddleware',
|
|
27
|
+
'setInject',
|
|
28
|
+
'setLogger',
|
|
29
|
+
'setMeta',
|
|
30
|
+
'useS', 'wait', 'OneFile', 'ManyFiles']
|
package/register/index.mjs
CHANGED
|
@@ -16,9 +16,8 @@ const fileModelMap = new Map()
|
|
|
16
16
|
|
|
17
17
|
port1.on('message', async (data) => {
|
|
18
18
|
const { type, files } = JSON.parse(data)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return RELAUNCH()// file change -> relaunch
|
|
19
|
+
if ((!isRunning && type !== 'init') || type === 'relaunch')
|
|
20
|
+
return RELAUNCH()
|
|
22
21
|
|
|
23
22
|
if (type === 'change' || type === 'init') {
|
|
24
23
|
if (!files.length)
|