phecda-server 5.1.1 → 5.2.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/assets/ps.json +24 -0
- package/assets/tsconfig.json +21 -0
- package/bin/cli.mjs +41 -80
- package/dist/{chunk-HMPTPTFL.js → chunk-5BVUCNMA.js} +2 -2
- package/dist/{chunk-FSBD5R22.js → chunk-BSE2DSDK.js} +64 -66
- package/dist/{chunk-2HKQPZDT.mjs → chunk-CKQW3FDK.mjs} +3 -3
- package/dist/{chunk-665MB62T.mjs → chunk-JE6BBDXW.mjs} +63 -65
- package/dist/{chunk-UU6RHGRF.mjs → chunk-V3WIKOP3.mjs} +10 -4
- package/dist/{chunk-3BV2GRS7.js → chunk-VMLHTEW3.js} +22 -16
- package/dist/core-7f6d2be6.d.ts +27 -0
- package/dist/helper.d.ts +27 -0
- package/dist/helper.js +21 -0
- package/dist/helper.mjs +21 -0
- package/dist/index.d.ts +7 -24
- package/dist/index.js +24 -42
- package/dist/index.mjs +5 -23
- package/dist/rpc/bullmq/index.d.ts +3 -2
- package/dist/rpc/bullmq/index.js +6 -6
- package/dist/rpc/bullmq/index.mjs +1 -1
- package/dist/rpc/kafka/index.d.ts +3 -2
- package/dist/rpc/kafka/index.js +5 -5
- package/dist/rpc/kafka/index.mjs +1 -1
- package/dist/rpc/nats/index.d.ts +3 -2
- package/dist/rpc/nats/index.js +5 -5
- package/dist/rpc/nats/index.mjs +1 -1
- package/dist/rpc/rabbitmq/index.d.ts +3 -2
- package/dist/rpc/rabbitmq/index.js +6 -6
- package/dist/rpc/rabbitmq/index.mjs +1 -1
- package/dist/rpc/redis/index.d.ts +3 -2
- package/dist/rpc/redis/index.js +6 -6
- package/dist/rpc/redis/index.mjs +1 -1
- package/dist/server/elysia/index.d.ts +3 -2
- package/dist/server/elysia/index.js +15 -15
- package/dist/server/elysia/index.mjs +2 -2
- package/dist/server/express/index.d.ts +3 -2
- package/dist/server/express/index.js +14 -14
- package/dist/server/express/index.mjs +1 -1
- package/dist/server/fastify/index.d.ts +3 -2
- package/dist/server/fastify/index.js +15 -15
- package/dist/server/fastify/index.mjs +2 -2
- package/dist/server/h3/index.d.ts +3 -2
- package/dist/server/h3/index.js +12 -12
- package/dist/server/h3/index.mjs +1 -1
- package/dist/server/hono/index.d.ts +3 -2
- package/dist/server/hono/index.js +13 -13
- package/dist/server/hono/index.mjs +1 -1
- package/dist/server/hyper-express/index.d.ts +3 -2
- package/dist/server/hyper-express/index.js +13 -13
- package/dist/server/hyper-express/index.mjs +1 -1
- package/dist/server/koa/index.d.ts +3 -2
- package/dist/server/koa/index.js +14 -14
- package/dist/server/koa/index.mjs +1 -1
- package/dist/test.d.ts +3 -2
- package/dist/test.js +2 -2
- package/dist/test.mjs +1 -1
- package/dist/{helper-fcbf6aa8.d.ts → types-68f2ec2a.d.ts} +2 -4
- package/dist/{core-39f27fe8.d.ts → types-81be0ba3.d.ts} +2 -25
- package/dist/{helper-6133f78f.d.ts → types-f3b79218.d.ts} +2 -3
- package/package.json +61 -53
- package/register/loader.mjs +26 -13
- package/register/utils.mjs +6 -31
- /package/{bin → assets}/schema.json +0 -0
package/package.json
CHANGED
|
@@ -1,74 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.1",
|
|
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",
|
|
@@ -159,16 +177,6 @@
|
|
|
159
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/loader.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { createRequire } from 'module'
|
|
|
11
11
|
import ts from 'typescript'
|
|
12
12
|
import chokidar from 'chokidar'
|
|
13
13
|
import { log } from '../dist/index.mjs'
|
|
14
|
-
import { compile, genUnImportRet, handleClassTypes } from './utils.mjs'
|
|
14
|
+
import { compile, genUnImportRet, handleClassTypes, slash } from './utils.mjs'
|
|
15
15
|
|
|
16
16
|
let port
|
|
17
17
|
|
|
@@ -39,17 +39,20 @@ if (isLowVersion)
|
|
|
39
39
|
await initialize()
|
|
40
40
|
|
|
41
41
|
let config
|
|
42
|
+
|
|
43
|
+
const workdir = process.env.PS_WORKDIR || process.cwd()
|
|
44
|
+
|
|
45
|
+
const configPath = resolvePath(
|
|
46
|
+
workdir,
|
|
47
|
+
process.env.PS_CONFIG_FILE || 'ps.json',
|
|
48
|
+
)
|
|
49
|
+
|
|
42
50
|
const require = createRequire(import.meta.url)
|
|
43
51
|
export async function initialize(data) {
|
|
44
52
|
if (data)
|
|
45
53
|
port = data.port
|
|
46
54
|
log('read config...')
|
|
47
55
|
|
|
48
|
-
const configPath = resolvePath(
|
|
49
|
-
process.cwd(),
|
|
50
|
-
process.env.PS_CONFIG_FILE || 'ps.json',
|
|
51
|
-
)
|
|
52
|
-
|
|
53
56
|
config = require(configPath)
|
|
54
57
|
if (!config.virtualFile)
|
|
55
58
|
config.virtualFile = {}
|
|
@@ -72,8 +75,21 @@ export async function initialize(data) {
|
|
|
72
75
|
await unimportRet.init()
|
|
73
76
|
|
|
74
77
|
writeFile(
|
|
75
|
-
config.unimport.dtsPath || dtsPath,
|
|
76
|
-
handleClassTypes(
|
|
78
|
+
resolvePath(workdir, config.unimport.dtsPath || dtsPath),
|
|
79
|
+
handleClassTypes(
|
|
80
|
+
await unimportRet.generateTypeDeclarations({
|
|
81
|
+
resolvePath: (i) => {
|
|
82
|
+
if (i.from.startsWith('.') || isAbsolute(i.from)) {
|
|
83
|
+
const related = slash(
|
|
84
|
+
relative(workdir, i.from).replace(/\.ts(x)?$/, ''),
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
return !related.startsWith('.') ? `./${related}` : related
|
|
88
|
+
}
|
|
89
|
+
return i.from
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
),
|
|
77
93
|
)
|
|
78
94
|
}
|
|
79
95
|
}
|
|
@@ -173,7 +189,7 @@ export const resolve = async (specifier, context, nextResolve) => {
|
|
|
173
189
|
if (resolver) {
|
|
174
190
|
return {
|
|
175
191
|
format: 'ts',
|
|
176
|
-
url: pathToFileURL(resolvePath(
|
|
192
|
+
url: pathToFileURL(resolvePath(workdir, resolver.path)).href,
|
|
177
193
|
shortCircuit: true,
|
|
178
194
|
}
|
|
179
195
|
}
|
|
@@ -281,10 +297,7 @@ export const load = async (url, context, nextLoad) => {
|
|
|
281
297
|
source: (
|
|
282
298
|
await injectImports(
|
|
283
299
|
compiled,
|
|
284
|
-
(url.startsWith('file://') ? fileURLToPath(url) : url)
|
|
285
|
-
/\\/g,
|
|
286
|
-
'/',
|
|
287
|
-
),
|
|
300
|
+
slash(url.startsWith('file://') ? fileURLToPath(url) : url),
|
|
288
301
|
)
|
|
289
302
|
).code,
|
|
290
303
|
shortCircuit: true,
|
package/register/utils.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { basename } from 'path'
|
|
2
2
|
import { transform } from '@swc-node/core'
|
|
3
3
|
const injectInlineSourceMap = ({ code, map }) => {
|
|
4
4
|
if (map) {
|
|
@@ -42,40 +42,15 @@ export async function genUnImportRet(opts) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// function slash(str) {
|
|
46
|
-
// return str.replace(/\\/g, '/')
|
|
47
|
-
// }
|
|
48
|
-
|
|
49
|
-
// async function findWorkspaceExports() {
|
|
50
|
-
// try {
|
|
51
|
-
// const { default: fg } = await import('fast-glob')
|
|
52
|
-
// const { scanExports } = await import('unimport')
|
|
53
|
-
// const result = await fg(
|
|
54
|
-
// '**/*.@(controller|service|module|extension|ext|guard|interceptor|plugin|filter|pipe|edge).ts',
|
|
55
|
-
// {
|
|
56
|
-
// ignore: ['node_modules'],
|
|
57
|
-
// absolute: true,
|
|
58
|
-
// cwd: process.cwd(),
|
|
59
|
-
// onlyFiles: true,
|
|
60
|
-
// followSymbolicLinks: true,
|
|
61
|
-
// },
|
|
62
|
-
// )
|
|
63
|
-
|
|
64
|
-
// const files = Array.from(new Set(result.flat())).map(slash)
|
|
65
|
-
|
|
66
|
-
// return (await Promise.all(files.map(i => scanExports(i, false))))
|
|
67
|
-
// .flat()
|
|
68
|
-
// }
|
|
69
|
-
// catch (e) {
|
|
70
|
-
// return []
|
|
71
|
-
// }
|
|
72
|
-
// }
|
|
73
|
-
|
|
74
45
|
export function handleClassTypes(input) {
|
|
75
46
|
return input.replace(/const\s+(\w+)\s*:\s*typeof\s+import\(['"](.+)['"]\)\['(\w+)'\]/g, (_, n, p, e) => {
|
|
76
|
-
|
|
47
|
+
// TestController in test.controller
|
|
48
|
+
if (p.startsWith('./') && (basename(p).replace('.', '').toLowerCase() === e.toLowerCase()))
|
|
77
49
|
return `${_}\n type ${n} = InstanceType<typeof import('${p}')['${e}']>`
|
|
78
50
|
|
|
79
51
|
return _
|
|
80
52
|
})
|
|
81
53
|
}
|
|
54
|
+
export function slash(str) {
|
|
55
|
+
return str.replace(/\\/g, '/')
|
|
56
|
+
}
|
|
File without changes
|