phecda-server 7.0.0-alpha.7 → 7.0.0-alpha.9
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/bin/cli.mjs +10 -1
- package/dist/{chunk-M5HGFUCV.js → chunk-5RBTN33A.js} +23 -3
- package/dist/{chunk-RGSKKTHD.mjs → chunk-7ZGYJ5OW.mjs} +88 -54
- package/dist/{chunk-IRXNF6ZE.mjs → chunk-CVPZWDXU.mjs} +39 -30
- package/dist/{chunk-MENRZSGW.js → chunk-FX3LDQII.js} +88 -79
- package/dist/{chunk-C5BVKEGW.mjs → chunk-FXTJ3BJ6.mjs} +25 -5
- package/dist/{chunk-XSMUJ77A.js → chunk-KJUD2BKE.js} +103 -69
- package/dist/{chunk-JPSXNDXP.mjs → chunk-ODVWOXVB.mjs} +1 -1
- package/dist/{chunk-VYMSCWXC.js → chunk-V5EYXVJT.js} +24 -24
- package/dist/{core-DU7gQKSk.d.mts → core-BDkhrEyf.d.mts} +4 -3
- package/dist/{core-CzElxZoF.d.ts → core-D_cz0tKa.d.ts} +4 -3
- package/dist/helper.d.mts +7 -5
- package/dist/helper.d.ts +7 -5
- package/dist/helper.js +8 -3
- package/dist/helper.mjs +10 -5
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +41 -44
- package/dist/http/elysia/index.mjs +7 -10
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +38 -41
- package/dist/http/express/index.mjs +7 -10
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +39 -42
- package/dist/http/fastify/index.mjs +7 -10
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +39 -42
- package/dist/http/h3/index.mjs +7 -10
- package/dist/http/hono/index.d.mts +4 -4
- package/dist/http/hono/index.d.ts +4 -4
- package/dist/http/hono/index.js +35 -39
- package/dist/http/hono/index.mjs +3 -7
- package/dist/http/hyper-express/index.d.mts +4 -4
- package/dist/http/hyper-express/index.d.ts +4 -4
- package/dist/http/hyper-express/index.js +36 -39
- package/dist/http/hyper-express/index.mjs +6 -9
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +38 -41
- package/dist/http/koa/index.mjs +7 -10
- package/dist/index.d.mts +35 -33
- package/dist/index.d.ts +35 -33
- package/dist/index.js +42 -43
- package/dist/index.mjs +15 -16
- package/dist/{meta-BTnLXuCa.d.ts → meta-BX5jhe4Z.d.mts} +3 -4
- package/dist/{meta-BTnLXuCa.d.mts → meta-BX5jhe4Z.d.ts} +3 -4
- package/dist/rpc/bullmq/index.d.mts +4 -4
- package/dist/rpc/bullmq/index.d.ts +4 -4
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +3 -3
- package/dist/rpc/kafka/index.d.mts +4 -4
- package/dist/rpc/kafka/index.d.ts +4 -4
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +4 -4
- package/dist/rpc/nats/index.d.ts +4 -4
- package/dist/rpc/nats/index.js +13 -13
- package/dist/rpc/nats/index.mjs +3 -3
- package/dist/rpc/rabbitmq/index.d.mts +4 -4
- package/dist/rpc/rabbitmq/index.d.ts +4 -4
- package/dist/rpc/rabbitmq/index.js +15 -15
- package/dist/rpc/rabbitmq/index.mjs +3 -3
- package/dist/rpc/redis/index.d.mts +4 -4
- package/dist/rpc/redis/index.d.ts +4 -4
- package/dist/rpc/redis/index.js +13 -13
- package/dist/rpc/redis/index.mjs +3 -3
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types-CbfaGkPA.d.ts → types-B-rUM9Fm.d.mts} +3 -3
- package/dist/{types--E-OCZhC.d.ts → types-CMeuFoyd.d.ts} +3 -3
- package/dist/{types-BxlzVoRv.d.mts → types-DKVhyZk_.d.mts} +3 -3
- package/dist/{types-BYqBeqrs.d.mts → types-MxxtkZXw.d.ts} +3 -3
- package/package.json +3 -2
- package/register/index.mjs +20 -11
- package/register/loader.mjs +13 -28
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 _chunkKJUD2BKEjs = require('./chunk-KJUD2BKE.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk5RBTN33Ajs = require('./chunk-5RBTN33A.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 _chunkKJUD2BKEjs.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
|
+
_chunk5RBTN33Ajs.__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,11 +59,11 @@ async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
_chunk5RBTN33Ajs.__name.call(void 0, module, "module");
|
|
63
63
|
Agent.module = module;
|
|
64
64
|
return Agent;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
_chunk5RBTN33Ajs.__name.call(void 0, TestHttp, "TestHttp");
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
|
package/dist/test.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DefaultOptions, B as
|
|
1
|
+
import { D as DefaultOptions, B as BaseCtx } from './meta-BX5jhe4Z.mjs';
|
|
2
2
|
|
|
3
3
|
interface RpcServerOptions extends DefaultOptions {
|
|
4
4
|
defaultQueue?: string;
|
|
@@ -8,7 +8,7 @@ interface RpcClientOptions {
|
|
|
8
8
|
timeout?: number;
|
|
9
9
|
max?: number;
|
|
10
10
|
}
|
|
11
|
-
interface
|
|
11
|
+
interface RpcCtx extends BaseCtx {
|
|
12
12
|
args: any[];
|
|
13
13
|
id: string;
|
|
14
14
|
queue: string;
|
|
@@ -16,4 +16,4 @@ interface RpcContext extends BaseContext {
|
|
|
16
16
|
category: 'rpc';
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export type {
|
|
19
|
+
export type { RpcCtx as R, RpcServerOptions as a, RpcClientOptions as b };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { D as DefaultOptions, B as
|
|
2
|
+
import { D as DefaultOptions, B as BaseCtx } from './meta-BX5jhe4Z.js';
|
|
3
3
|
|
|
4
4
|
interface HttpOptions extends DefaultOptions {
|
|
5
5
|
/**
|
|
@@ -15,7 +15,7 @@ interface HttpOptions extends DefaultOptions {
|
|
|
15
15
|
*/
|
|
16
16
|
dynamic?: boolean;
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
interface HttpCtx extends BaseCtx {
|
|
19
19
|
parallel?: true;
|
|
20
20
|
index?: number;
|
|
21
21
|
query: Record<string, any>;
|
|
@@ -45,4 +45,4 @@ interface CookieSerializeOptions {
|
|
|
45
45
|
partitioned?: boolean;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export type { CookieSerializeOptions as C,
|
|
48
|
+
export type { CookieSerializeOptions as C, HttpCtx as H, HttpOptions as a };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { D as DefaultOptions, B as
|
|
2
|
+
import { D as DefaultOptions, B as BaseCtx } from './meta-BX5jhe4Z.mjs';
|
|
3
3
|
|
|
4
4
|
interface HttpOptions extends DefaultOptions {
|
|
5
5
|
/**
|
|
@@ -15,7 +15,7 @@ interface HttpOptions extends DefaultOptions {
|
|
|
15
15
|
*/
|
|
16
16
|
dynamic?: boolean;
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
interface HttpCtx extends BaseCtx {
|
|
19
19
|
parallel?: true;
|
|
20
20
|
index?: number;
|
|
21
21
|
query: Record<string, any>;
|
|
@@ -45,4 +45,4 @@ interface CookieSerializeOptions {
|
|
|
45
45
|
partitioned?: boolean;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export type { CookieSerializeOptions as C,
|
|
48
|
+
export type { CookieSerializeOptions as C, HttpCtx as H, HttpOptions as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DefaultOptions, B as
|
|
1
|
+
import { D as DefaultOptions, B as BaseCtx } from './meta-BX5jhe4Z.js';
|
|
2
2
|
|
|
3
3
|
interface RpcServerOptions extends DefaultOptions {
|
|
4
4
|
defaultQueue?: string;
|
|
@@ -8,7 +8,7 @@ interface RpcClientOptions {
|
|
|
8
8
|
timeout?: number;
|
|
9
9
|
max?: number;
|
|
10
10
|
}
|
|
11
|
-
interface
|
|
11
|
+
interface RpcCtx extends BaseCtx {
|
|
12
12
|
args: any[];
|
|
13
13
|
id: string;
|
|
14
14
|
queue: string;
|
|
@@ -16,4 +16,4 @@ interface RpcContext extends BaseContext {
|
|
|
16
16
|
category: 'rpc';
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export type {
|
|
19
|
+
export type { RpcCtx as R, RpcServerOptions as a, RpcClientOptions as b };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.9",
|
|
4
4
|
"description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
|
|
5
5
|
"author": "fgsreally",
|
|
6
6
|
"license": "MIT",
|
|
@@ -129,7 +129,8 @@
|
|
|
129
129
|
}
|
|
130
130
|
},
|
|
131
131
|
"bin": {
|
|
132
|
-
"phecda": "bin/cli.mjs"
|
|
132
|
+
"phecda": "bin/cli.mjs",
|
|
133
|
+
"phecda-server": "bin/cli.mjs"
|
|
133
134
|
},
|
|
134
135
|
"files": [
|
|
135
136
|
"dist",
|
package/register/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { register } from 'node:module'
|
|
2
2
|
import { MessageChannel } from 'node:worker_threads'
|
|
3
|
-
import { log } from '../dist/index.mjs'
|
|
4
|
-
|
|
3
|
+
import { isPhecda, log } from '../dist/index.mjs'
|
|
4
|
+
import { RELAUNCH, RELOAD } from '../dist/helper.mjs'
|
|
5
5
|
const { port1, port2 } = new MessageChannel()
|
|
6
6
|
|
|
7
7
|
register('./loader.mjs', {
|
|
@@ -12,18 +12,27 @@ register('./loader.mjs', {
|
|
|
12
12
|
|
|
13
13
|
let isRunning = true
|
|
14
14
|
|
|
15
|
+
const fileModelMap = new Map()
|
|
16
|
+
|
|
15
17
|
port1.on('message', async (data) => {
|
|
16
18
|
const { type, files } = JSON.parse(data)
|
|
17
19
|
|
|
18
|
-
if (!isRunning ||
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
if (type === 'change') {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
if (!isRunning || type === 'relaunch')
|
|
21
|
+
return RELAUNCH()// file change -> relaunch
|
|
22
|
+
|
|
23
|
+
if (type === 'change' || type === 'init') {
|
|
24
|
+
if (!files.length)
|
|
25
|
+
return
|
|
26
|
+
const oldModels = []
|
|
27
|
+
const newModels = []
|
|
28
|
+
for (const file of files) {
|
|
29
|
+
oldModels.push(...fileModelMap.get(file) || [])
|
|
30
|
+
const models = Object.values(await import(file)).filter(isPhecda)
|
|
31
|
+
fileModelMap.set(file, models)
|
|
32
|
+
newModels.push(...models)
|
|
33
|
+
}
|
|
34
|
+
if (type === 'change')
|
|
35
|
+
return RELOAD(oldModels, newModels)
|
|
27
36
|
}
|
|
28
37
|
})
|
|
29
38
|
|
package/register/loader.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { createRequire } from 'module'
|
|
|
12
12
|
import { existsSync } from 'fs'
|
|
13
13
|
import ts from 'typescript'
|
|
14
14
|
import chokidar from 'chokidar'
|
|
15
|
-
import { log } from '../dist/index.mjs'
|
|
15
|
+
import { IS_DEV, log } from '../dist/index.mjs'
|
|
16
16
|
import { compile, genUnImportRet, handleClassTypes, slash } from './utils.mjs'
|
|
17
17
|
|
|
18
18
|
let port
|
|
@@ -75,7 +75,7 @@ export async function initialize(data) {
|
|
|
75
75
|
if (!config.paths)
|
|
76
76
|
config.paths = {}
|
|
77
77
|
|
|
78
|
-
if (
|
|
78
|
+
if (IS_DEV) {
|
|
79
79
|
chokidar.watch(configPath, { persistent: true }).on('change', () => {
|
|
80
80
|
port.postMessage(
|
|
81
81
|
JSON.stringify({
|
|
@@ -254,32 +254,17 @@ export const load = async (url, context, nextLoad) => {
|
|
|
254
254
|
&& !isLowVersion
|
|
255
255
|
) {
|
|
256
256
|
watchFiles.add(url)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
// }),
|
|
269
|
-
// )
|
|
270
|
-
// }
|
|
271
|
-
// catch (e) {
|
|
272
|
-
// port.postMessage(
|
|
273
|
-
// JSON.stringify({
|
|
274
|
-
// type: 'relaunch',
|
|
275
|
-
// }),
|
|
276
|
-
// )
|
|
277
|
-
// }
|
|
278
|
-
// }
|
|
279
|
-
// }),
|
|
280
|
-
// )
|
|
281
|
-
|
|
282
|
-
if (!process.env.PS_HMR_BAN) {
|
|
257
|
+
|
|
258
|
+
if (IS_DEV) {
|
|
259
|
+
if (isModuleFileUrl(url)) {
|
|
260
|
+
port.postMessage(
|
|
261
|
+
JSON.stringify({
|
|
262
|
+
type: 'init',
|
|
263
|
+
files: [fileURLToPath(url)],
|
|
264
|
+
}),
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
|
|
283
268
|
chokidar.watch(fileURLToPath(url), { persistent: true }).on(
|
|
284
269
|
'change',
|
|
285
270
|
debounce(() => {
|