phecda-server 7.0.0-alpha.11 → 7.0.0-alpha.13
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/schema.json +11 -2
- package/bin/cli.mjs +62 -9
- package/dist/{chunk-G7JFKM2M.js → chunk-IJFIY6QN.js} +1 -9
- package/dist/{chunk-Z7NAAE4M.mjs → chunk-VX4BZEL7.mjs} +0 -8
- package/dist/{core-CUTbX_IS.d.ts → core-CDzIy2g0.d.ts} +1 -1
- package/dist/{core-DIfgUKIU.d.mts → core-jUg1HvYT.d.mts} +1 -1
- package/dist/helper.d.mts +2 -4
- package/dist/helper.d.ts +2 -4
- package/dist/helper.js +2 -4
- package/dist/helper.mjs +1 -3
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +18 -17
- package/dist/http/elysia/index.mjs +2 -1
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +17 -16
- package/dist/http/express/index.mjs +2 -1
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +17 -16
- package/dist/http/fastify/index.mjs +2 -1
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +18 -17
- package/dist/http/h3/index.mjs +2 -1
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +15 -14
- package/dist/http/hono/index.mjs +2 -1
- 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 +16 -15
- package/dist/http/hyper-express/index.mjs +2 -1
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +17 -16
- package/dist/http/koa/index.mjs +2 -1
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +19 -19
- package/dist/index.mjs +1 -1
- package/dist/{meta-CR-D39hQ.d.mts → meta-xvg6V7pH.d.mts} +2 -19
- package/dist/{meta-CR-D39hQ.d.ts → meta-xvg6V7pH.d.ts} +2 -19
- package/dist/rpc/bullmq/index.d.mts +4 -6
- package/dist/rpc/bullmq/index.d.ts +4 -6
- package/dist/rpc/bullmq/index.js +7 -75
- package/dist/rpc/bullmq/index.mjs +3 -71
- package/dist/rpc/electron/index.d.mts +13 -0
- package/dist/rpc/electron/index.d.ts +13 -0
- package/dist/rpc/electron/index.js +72 -0
- package/dist/rpc/electron/index.mjs +72 -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 +7 -86
- package/dist/rpc/kafka/index.mjs +3 -82
- package/dist/rpc/nats/index.d.mts +4 -6
- package/dist/rpc/nats/index.d.ts +4 -6
- package/dist/rpc/nats/index.js +7 -67
- package/dist/rpc/nats/index.mjs +2 -62
- package/dist/rpc/rabbitmq/index.d.mts +4 -6
- package/dist/rpc/rabbitmq/index.d.ts +4 -6
- package/dist/rpc/rabbitmq/index.js +7 -73
- package/dist/rpc/rabbitmq/index.mjs +3 -69
- package/dist/rpc/redis/index.d.mts +4 -9
- package/dist/rpc/redis/index.d.ts +4 -9
- package/dist/rpc/redis/index.js +7 -74
- package/dist/rpc/redis/index.mjs +3 -70
- package/dist/rpc/ws/index.d.mts +14 -0
- package/dist/rpc/ws/index.d.ts +14 -0
- package/dist/rpc/ws/index.js +73 -0
- package/dist/rpc/ws/index.mjs +73 -0
- package/dist/test.d.mts +7 -3
- package/dist/test.d.ts +7 -3
- package/dist/types-6qaaUIKZ.d.mts +14 -0
- package/dist/{types-BF1TDbFV.d.ts → types-B-1OL-3P.d.ts} +1 -1
- package/dist/types-BtXOT5rI.d.ts +14 -0
- package/dist/{types-DYviSl5B.d.mts → types-Ctd6pLNE.d.mts} +1 -1
- package/package.json +13 -2
- package/register/index.mjs +0 -1
- package/register/loader.mjs +12 -52
- package/register/utils.mjs +7 -7
- package/assets/ps.json +0 -24
- package/assets/tsconfig.json +0 -21
- package/dist/types-DYRu0vic.d.ts +0 -19
- package/dist/types-DqH1qA-q.d.mts +0 -19
package/assets/schema.json
CHANGED
|
@@ -46,8 +46,17 @@
|
|
|
46
46
|
"description": "Virtual module, just like in Vite."
|
|
47
47
|
},
|
|
48
48
|
"unimport": {
|
|
49
|
-
"
|
|
50
|
-
|
|
49
|
+
"oneOf": [
|
|
50
|
+
{
|
|
51
|
+
"type": "object",
|
|
52
|
+
"description": "Includes the arguments passed to unimport"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"type": "boolean",
|
|
56
|
+
"enum": [false],
|
|
57
|
+
"description": "Disable unimport"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
51
60
|
}
|
|
52
61
|
},
|
|
53
62
|
|
package/bin/cli.mjs
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
import { fork } from 'child_process'
|
|
3
3
|
import { createRequire } from 'module'
|
|
4
|
-
import { fileURLToPath } from 'url'
|
|
5
|
-
|
|
6
|
-
import { dirname, resolve } from 'path'
|
|
7
4
|
import pc from 'picocolors'
|
|
8
5
|
import cac from 'cac'
|
|
9
6
|
import fse from 'fs-extra'
|
|
@@ -20,8 +17,6 @@ const cli = cac('phecda').option('-c,--config <config>', 'config file', {
|
|
|
20
17
|
default: 'ps.json',
|
|
21
18
|
})
|
|
22
19
|
|
|
23
|
-
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
24
|
-
|
|
25
20
|
const require = createRequire(import.meta.url)
|
|
26
21
|
let child
|
|
27
22
|
|
|
@@ -36,7 +31,7 @@ if (nodeVersion < 18.19) {
|
|
|
36
31
|
}
|
|
37
32
|
|
|
38
33
|
function startChild(file, args) {
|
|
39
|
-
child = fork(file, {
|
|
34
|
+
child = globalThis.PS_CREATE_CHILD?.() || fork(file, {
|
|
40
35
|
env: { ...process.env },
|
|
41
36
|
stdio: 'inherit',
|
|
42
37
|
execArgv: [
|
|
@@ -87,22 +82,80 @@ cli
|
|
|
87
82
|
if (root)
|
|
88
83
|
process.chdir(root)
|
|
89
84
|
|
|
85
|
+
let hasUnimport
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
await import('unimport')
|
|
89
|
+
hasUnimport = true
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
catch (e) {
|
|
93
|
+
hasUnimport = false
|
|
94
|
+
}
|
|
95
|
+
|
|
90
96
|
const tsconfigPath = options.tsconfig
|
|
91
97
|
const psconfigPath = process.env.PS_CONFIG_FILE || options.config
|
|
92
98
|
|
|
93
99
|
if (!fse.existsSync(tsconfigPath)) {
|
|
94
100
|
log(`create ${tsconfigPath}`)
|
|
95
101
|
|
|
96
|
-
await fse.
|
|
97
|
-
resolve(__dirname, '../assets/tsconfig.json'),
|
|
102
|
+
await fse.outputJSON(
|
|
98
103
|
tsconfigPath,
|
|
104
|
+
{
|
|
105
|
+
compilerOptions: {
|
|
106
|
+
target: 'esnext',
|
|
107
|
+
useDefineForClassFields: false,
|
|
108
|
+
experimentalDecorators: true,
|
|
109
|
+
emitDecoratorMetadata: true,
|
|
110
|
+
module: 'esnext',
|
|
111
|
+
lib: ['esnext', 'DOM'],
|
|
112
|
+
strictPropertyInitialization: false,
|
|
113
|
+
moduleResolution: 'bundler',
|
|
114
|
+
strict: true,
|
|
115
|
+
resolveJsonModule: true,
|
|
116
|
+
esModuleInterop: true,
|
|
117
|
+
noEmit: true,
|
|
118
|
+
noUnusedLocals: true,
|
|
119
|
+
noUnusedParameters: true,
|
|
120
|
+
noImplicitReturns: true,
|
|
121
|
+
skipLibCheck: true,
|
|
122
|
+
},
|
|
123
|
+
include: ['.', hasUnimport ? (process.env.PS_DTS_PATH || 'ps.d.ts') : undefined],
|
|
124
|
+
},
|
|
125
|
+
|
|
99
126
|
)
|
|
100
127
|
}
|
|
101
128
|
|
|
102
129
|
if (!fse.existsSync(psconfigPath)) {
|
|
103
130
|
log(`create ${psconfigPath}`)
|
|
104
131
|
|
|
105
|
-
await fse.
|
|
132
|
+
await fse.outputJSON(psconfigPath, {
|
|
133
|
+
$schema: './node_modules/phecda-server/assets/schema.json',
|
|
134
|
+
resolve: [
|
|
135
|
+
{
|
|
136
|
+
source: 'controller',
|
|
137
|
+
importer: 'http',
|
|
138
|
+
path: '.ps/http.js',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
source: 'rpc',
|
|
142
|
+
importer: 'client',
|
|
143
|
+
path: '.ps/rpc.js',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
unimport: hasUnimport && {
|
|
147
|
+
dirs: [
|
|
148
|
+
'.',
|
|
149
|
+
],
|
|
150
|
+
dirsScanOptions: {
|
|
151
|
+
filePatterns: [
|
|
152
|
+
'*.{service,controller,module,rpc,solo,guard,extension,pipe,filter,addon}.ts',
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
virtualFile: {},
|
|
157
|
+
moduleFile: [],
|
|
158
|
+
})
|
|
106
159
|
}
|
|
107
160
|
|
|
108
161
|
log('init finish')
|
|
@@ -386,13 +386,6 @@ function resolveDep(ret, key) {
|
|
|
386
386
|
}
|
|
387
387
|
_chunk4LLLQOMFjs.__name.call(void 0, resolveDep, "resolveDep");
|
|
388
388
|
|
|
389
|
-
// src/rpc/helper.ts
|
|
390
|
-
var _os = require('os');
|
|
391
|
-
function genClientQueue(key) {
|
|
392
|
-
return `PS-${key ? `${key}-` : ""}${_os.hostname.call(void 0, )}-${process.pid}`;
|
|
393
|
-
}
|
|
394
|
-
_chunk4LLLQOMFjs.__name.call(void 0, genClientQueue, "genClientQueue");
|
|
395
|
-
|
|
396
389
|
// src/decorators/helper.ts
|
|
397
390
|
function shallowClone(obj) {
|
|
398
391
|
return {
|
|
@@ -546,5 +539,4 @@ _chunk4LLLQOMFjs.__name.call(void 0, joinUrl, "joinUrl");
|
|
|
546
539
|
|
|
547
540
|
|
|
548
541
|
|
|
549
|
-
|
|
550
|
-
exports.defaultPipe = defaultPipe; exports.Exception = Exception; exports.UndefinedException = UndefinedException; exports.ValidateException = ValidateException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.TimerException = TimerException; exports.WorkerException = WorkerException; exports.Context = Context; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addAddon = addAddon; exports.resolveDep = resolveDep; exports.genClientQueue = genClientQueue; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep; exports.joinUrl = joinUrl;
|
|
542
|
+
exports.defaultPipe = defaultPipe; exports.Exception = Exception; exports.UndefinedException = UndefinedException; exports.ValidateException = ValidateException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.TimerException = TimerException; exports.WorkerException = WorkerException; exports.Context = Context; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addAddon = addAddon; exports.resolveDep = resolveDep; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep; exports.joinUrl = joinUrl;
|
|
@@ -386,13 +386,6 @@ function resolveDep(ret, key) {
|
|
|
386
386
|
}
|
|
387
387
|
__name(resolveDep, "resolveDep");
|
|
388
388
|
|
|
389
|
-
// src/rpc/helper.ts
|
|
390
|
-
import { hostname } from "os";
|
|
391
|
-
function genClientQueue(key) {
|
|
392
|
-
return `PS-${key ? `${key}-` : ""}${hostname()}-${process.pid}`;
|
|
393
|
-
}
|
|
394
|
-
__name(genClientQueue, "genClientQueue");
|
|
395
|
-
|
|
396
389
|
// src/decorators/helper.ts
|
|
397
390
|
function shallowClone(obj) {
|
|
398
391
|
return {
|
|
@@ -541,7 +534,6 @@ export {
|
|
|
541
534
|
addGuard,
|
|
542
535
|
addAddon,
|
|
543
536
|
resolveDep,
|
|
544
|
-
genClientQueue,
|
|
545
537
|
shallowClone,
|
|
546
538
|
mergeObject,
|
|
547
539
|
createControllerMetaMap,
|
package/dist/helper.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Meta, C as ControllerMeta } from './meta-
|
|
1
|
+
import { M as Meta, C as ControllerMeta } from './meta-xvg6V7pH.mjs';
|
|
2
2
|
import { Construct } from 'phecda-core';
|
|
3
3
|
|
|
4
4
|
declare function HMR(cb: (oldModels: Construct[], newModels: Construct[]) => any): void;
|
|
@@ -7,8 +7,6 @@ declare function RELAUNCH(): void;
|
|
|
7
7
|
|
|
8
8
|
declare function resolveDep(ret: any, key: string): any;
|
|
9
9
|
|
|
10
|
-
declare function genClientQueue(key?: string): string;
|
|
11
|
-
|
|
12
10
|
declare function shallowClone(obj: any): any;
|
|
13
11
|
declare function mergeObject(...args: any[]): any;
|
|
14
12
|
|
|
@@ -24,4 +22,4 @@ declare function detectAopDep(meta: Meta[], { guards, addons }?: {
|
|
|
24
22
|
} | undefined;
|
|
25
23
|
declare function joinUrl(base: string, ...paths: string[]): string;
|
|
26
24
|
|
|
27
|
-
export { HMR, RELAUNCH, RELOAD, createControllerMetaMap, detectAopDep,
|
|
25
|
+
export { HMR, RELAUNCH, RELOAD, createControllerMetaMap, detectAopDep, joinUrl, mergeObject, resolveDep, shallowClone };
|
package/dist/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Meta, C as ControllerMeta } from './meta-
|
|
1
|
+
import { M as Meta, C as ControllerMeta } from './meta-xvg6V7pH.js';
|
|
2
2
|
import { Construct } from 'phecda-core';
|
|
3
3
|
|
|
4
4
|
declare function HMR(cb: (oldModels: Construct[], newModels: Construct[]) => any): void;
|
|
@@ -7,8 +7,6 @@ declare function RELAUNCH(): void;
|
|
|
7
7
|
|
|
8
8
|
declare function resolveDep(ret: any, key: string): any;
|
|
9
9
|
|
|
10
|
-
declare function genClientQueue(key?: string): string;
|
|
11
|
-
|
|
12
10
|
declare function shallowClone(obj: any): any;
|
|
13
11
|
declare function mergeObject(...args: any[]): any;
|
|
14
12
|
|
|
@@ -24,4 +22,4 @@ declare function detectAopDep(meta: Meta[], { guards, addons }?: {
|
|
|
24
22
|
} | undefined;
|
|
25
23
|
declare function joinUrl(base: string, ...paths: string[]): string;
|
|
26
24
|
|
|
27
|
-
export { HMR, RELAUNCH, RELOAD, createControllerMetaMap, detectAopDep,
|
|
25
|
+
export { HMR, RELAUNCH, RELOAD, createControllerMetaMap, detectAopDep, joinUrl, mergeObject, resolveDep, shallowClone };
|
package/dist/helper.js
CHANGED
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
var _chunkG7JFKM2Mjs = require('./chunk-G7JFKM2M.js');
|
|
8
|
+
var _chunkIJFIY6QNjs = require('./chunk-IJFIY6QN.js');
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
|
|
@@ -22,5 +21,4 @@ var _chunk4LLLQOMFjs = require('./chunk-4LLLQOMF.js');
|
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
exports.HMR = _chunk4LLLQOMFjs.HMR; exports.RELAUNCH = _chunk4LLLQOMFjs.RELAUNCH; exports.RELOAD = _chunk4LLLQOMFjs.RELOAD; exports.createControllerMetaMap = _chunkG7JFKM2Mjs.createControllerMetaMap; exports.detectAopDep = _chunkG7JFKM2Mjs.detectAopDep; exports.genClientQueue = _chunkG7JFKM2Mjs.genClientQueue; exports.joinUrl = _chunkG7JFKM2Mjs.joinUrl; exports.mergeObject = _chunkG7JFKM2Mjs.mergeObject; exports.resolveDep = _chunkG7JFKM2Mjs.resolveDep; exports.shallowClone = _chunkG7JFKM2Mjs.shallowClone;
|
|
24
|
+
exports.HMR = _chunk4LLLQOMFjs.HMR; exports.RELAUNCH = _chunk4LLLQOMFjs.RELAUNCH; exports.RELOAD = _chunk4LLLQOMFjs.RELOAD; exports.createControllerMetaMap = _chunkIJFIY6QNjs.createControllerMetaMap; exports.detectAopDep = _chunkIJFIY6QNjs.detectAopDep; exports.joinUrl = _chunkIJFIY6QNjs.joinUrl; exports.mergeObject = _chunkIJFIY6QNjs.mergeObject; exports.resolveDep = _chunkIJFIY6QNjs.resolveDep; exports.shallowClone = _chunkIJFIY6QNjs.shallowClone;
|
package/dist/helper.mjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createControllerMetaMap,
|
|
3
3
|
detectAopDep,
|
|
4
|
-
genClientQueue,
|
|
5
4
|
joinUrl,
|
|
6
5
|
mergeObject,
|
|
7
6
|
resolveDep,
|
|
8
7
|
shallowClone
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VX4BZEL7.mjs";
|
|
10
9
|
import {
|
|
11
10
|
HMR,
|
|
12
11
|
RELAUNCH,
|
|
@@ -18,7 +17,6 @@ export {
|
|
|
18
17
|
RELOAD,
|
|
19
18
|
createControllerMetaMap,
|
|
20
19
|
detectAopDep,
|
|
21
|
-
genClientQueue,
|
|
22
20
|
joinUrl,
|
|
23
21
|
mergeObject,
|
|
24
22
|
resolveDep,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
|
|
2
2
|
import { BaseMacro } from 'elysia/dist/types';
|
|
3
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-Ctd6pLNE.mjs';
|
|
4
|
+
import { F as Factory } from '../../core-jUg1HvYT.mjs';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-xvg6V7pH.mjs';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
9
|
interface ElysiaCtx extends HttpCtx {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
|
|
2
2
|
import { BaseMacro } from 'elysia/dist/types';
|
|
3
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-B-1OL-3P.js';
|
|
4
|
+
import { F as Factory } from '../../core-CDzIy2g0.js';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-xvg6V7pH.js';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
9
|
interface ElysiaCtx extends HttpCtx {
|
|
@@ -7,7 +7,7 @@ var _chunkKCPBITYZjs = require('../../chunk-KCPBITYZ.js');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkIJFIY6QNjs = require('../../chunk-IJFIY6QN.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
@@ -19,14 +19,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/elysia");
|
|
|
19
19
|
function bind(app, data, opts = {}) {
|
|
20
20
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
21
21
|
const { moduleMap, meta } = data;
|
|
22
|
-
const metaMap =
|
|
22
|
+
const metaMap = _chunkIJFIY6QNjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
23
23
|
const { controller, http, func, tag } = meta2.data;
|
|
24
24
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
25
25
|
debug(`register method "${func}" in module "${tag}"`);
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
-
|
|
29
|
+
_chunkIJFIY6QNjs.detectAopDep.call(void 0, meta, {
|
|
30
30
|
addons: [
|
|
31
31
|
...globalAddons,
|
|
32
32
|
...parallelAddons
|
|
@@ -35,28 +35,29 @@ function bind(app, data, opts = {}) {
|
|
|
35
35
|
});
|
|
36
36
|
registerRoute();
|
|
37
37
|
function registerRoute() {
|
|
38
|
-
|
|
38
|
+
_chunkIJFIY6QNjs.Context.applyAddons(globalAddons, app, "elysia");
|
|
39
39
|
if (parallelRoute) {
|
|
40
40
|
const parallelRouter = new (0, _elysia.Elysia)();
|
|
41
|
-
|
|
41
|
+
_chunkIJFIY6QNjs.Context.applyAddons(parallelAddons, app, "elysia");
|
|
42
42
|
parallelRouter.post(parallelRoute, async (c) => {
|
|
43
43
|
const { body } = c;
|
|
44
44
|
async function errorHandler(e) {
|
|
45
|
-
const error = await
|
|
45
|
+
const error = await _chunkIJFIY6QNjs.Context.filterRecord.default(e);
|
|
46
46
|
c.set.status = error.status;
|
|
47
47
|
return error;
|
|
48
48
|
}
|
|
49
49
|
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkIJFIY6QNjs.BadRequestException)("data format should be an array"));
|
|
51
51
|
try {
|
|
52
52
|
return Promise.all(body.map((item, i) => {
|
|
53
53
|
return new Promise(async (resolve) => {
|
|
54
|
+
if (!item) return resolve(null);
|
|
54
55
|
const { tag, func } = item;
|
|
55
56
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
56
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
57
|
+
if (!metaMap.has(tag)) return resolve(await _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
57
58
|
const meta2 = metaMap.get(tag)[func];
|
|
58
|
-
if (!meta2) return resolve(await
|
|
59
|
-
const aop =
|
|
59
|
+
if (!meta2) return resolve(await _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
60
|
+
const aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
60
61
|
globalGuards,
|
|
61
62
|
globalFilter,
|
|
62
63
|
globalPipe
|
|
@@ -87,7 +88,7 @@ function bind(app, data, opts = {}) {
|
|
|
87
88
|
throw new Error("elysia can't support getResponse");
|
|
88
89
|
}, "getResponse")
|
|
89
90
|
};
|
|
90
|
-
const context = new (0,
|
|
91
|
+
const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
|
|
91
92
|
context.run(aop, resolve, resolve);
|
|
92
93
|
});
|
|
93
94
|
})).then((ret) => {
|
|
@@ -109,14 +110,14 @@ function bind(app, data, opts = {}) {
|
|
|
109
110
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
110
111
|
let aop;
|
|
111
112
|
if (!dynamic) {
|
|
112
|
-
aop =
|
|
113
|
+
aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
113
114
|
globalFilter,
|
|
114
115
|
globalGuards,
|
|
115
116
|
globalPipe
|
|
116
117
|
});
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
-
subApp[http.type](
|
|
119
|
+
_chunkIJFIY6QNjs.Context.applyAddons(addons, subApp, "elysia");
|
|
120
|
+
subApp[http.type](_chunkIJFIY6QNjs.joinUrl.call(void 0, http.prefix, http.route), async (c) => {
|
|
120
121
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
121
122
|
const contextData = {
|
|
122
123
|
type: "elysia",
|
|
@@ -148,16 +149,16 @@ function bind(app, data, opts = {}) {
|
|
|
148
149
|
}, "getResponse")
|
|
149
150
|
};
|
|
150
151
|
if (dynamic) {
|
|
151
|
-
aop =
|
|
152
|
+
aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
152
153
|
globalFilter,
|
|
153
154
|
globalGuards,
|
|
154
155
|
globalPipe
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
|
-
const context = new (0,
|
|
158
|
+
const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
|
|
158
159
|
if (http.headers) c.set.headers = http.headers;
|
|
159
160
|
if (dynamic) {
|
|
160
|
-
aop =
|
|
161
|
+
aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
161
162
|
globalFilter,
|
|
162
163
|
globalGuards,
|
|
163
164
|
globalPipe
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
createControllerMetaMap,
|
|
8
8
|
detectAopDep,
|
|
9
9
|
joinUrl
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-VX4BZEL7.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
13
|
} from "../../chunk-NQ55PA2X.mjs";
|
|
@@ -51,6 +51,7 @@ function bind(app, data, opts = {}) {
|
|
|
51
51
|
try {
|
|
52
52
|
return Promise.all(body.map((item, i) => {
|
|
53
53
|
return new Promise(async (resolve) => {
|
|
54
|
+
if (!item) return resolve(null);
|
|
54
55
|
const { tag, func } = item;
|
|
55
56
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
56
57
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, RequestHandler } from 'express';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-Ctd6pLNE.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-jUg1HvYT.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-xvg6V7pH.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface ExpressCtx extends HttpCtx {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response, Router, RequestHandler } from 'express';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-B-1OL-3P.js';
|
|
3
|
+
import { F as Factory } from '../../core-CDzIy2g0.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-xvg6V7pH.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface ExpressCtx extends HttpCtx {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkIJFIY6QNjs = require('../../chunk-IJFIY6QN.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -18,14 +18,14 @@ function bind(router, data, opts = {}) {
|
|
|
18
18
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
19
19
|
const { moduleMap, meta } = data;
|
|
20
20
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkIJFIY6QNjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
22
|
const { controller, http, func, tag } = meta2.data;
|
|
23
23
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
24
24
|
debug(`register method "${func}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunkIJFIY6QNjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -38,27 +38,28 @@ function bind(router, data, opts = {}) {
|
|
|
38
38
|
registerRoute();
|
|
39
39
|
});
|
|
40
40
|
function registerRoute() {
|
|
41
|
-
|
|
41
|
+
_chunkIJFIY6QNjs.Context.applyAddons(globalAddons, router, "express");
|
|
42
42
|
if (parallelRoute) {
|
|
43
43
|
const subRouter = _express.Router.call(void 0, );
|
|
44
|
-
|
|
44
|
+
_chunkIJFIY6QNjs.Context.applyAddons(parallelAddons, subRouter, "express");
|
|
45
45
|
subRouter.use(async (req, res, next) => {
|
|
46
46
|
const { body } = req;
|
|
47
47
|
async function errorHandler(e) {
|
|
48
|
-
const error = await
|
|
48
|
+
const error = await _chunkIJFIY6QNjs.Context.filterRecord.default(e);
|
|
49
49
|
return res.status(error.status).json(error);
|
|
50
50
|
}
|
|
51
51
|
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
52
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
52
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkIJFIY6QNjs.BadRequestException)("data format should be an array"));
|
|
53
53
|
try {
|
|
54
54
|
return Promise.all(body.map((item, i) => {
|
|
55
55
|
return new Promise(async (resolve) => {
|
|
56
|
+
if (!item) return resolve(null);
|
|
56
57
|
const { tag, func } = item;
|
|
57
58
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
58
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
59
|
+
if (!metaMap.has(tag)) return resolve(await _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
59
60
|
const meta2 = metaMap.get(tag)[func];
|
|
60
|
-
if (!meta2) return resolve(await
|
|
61
|
-
const aop =
|
|
61
|
+
if (!meta2) return resolve(await _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
62
|
+
const aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
62
63
|
globalFilter,
|
|
63
64
|
globalGuards,
|
|
64
65
|
globalPipe
|
|
@@ -86,7 +87,7 @@ function bind(router, data, opts = {}) {
|
|
|
86
87
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req, "getRequest"),
|
|
87
88
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res, "getResponse")
|
|
88
89
|
};
|
|
89
|
-
const context = new (0,
|
|
90
|
+
const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
|
|
90
91
|
context.run(aop, resolve, resolve);
|
|
91
92
|
});
|
|
92
93
|
})).then((ret) => {
|
|
@@ -105,15 +106,15 @@ function bind(router, data, opts = {}) {
|
|
|
105
106
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
106
107
|
let aop;
|
|
107
108
|
if (!dynamic) {
|
|
108
|
-
aop =
|
|
109
|
+
aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
109
110
|
globalFilter,
|
|
110
111
|
globalGuards,
|
|
111
112
|
globalPipe
|
|
112
113
|
});
|
|
113
114
|
}
|
|
114
115
|
const subRouter = _express.Router.call(void 0, );
|
|
115
|
-
|
|
116
|
-
subRouter[http.type](
|
|
116
|
+
_chunkIJFIY6QNjs.Context.applyAddons(addons, subRouter, "express");
|
|
117
|
+
subRouter[http.type](_chunkIJFIY6QNjs.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
|
|
117
118
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
118
119
|
const contextData = {
|
|
119
120
|
type: "express",
|
|
@@ -141,10 +142,10 @@ function bind(router, data, opts = {}) {
|
|
|
141
142
|
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req, "getRequest"),
|
|
142
143
|
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res, "getResponse")
|
|
143
144
|
};
|
|
144
|
-
const context = new (0,
|
|
145
|
+
const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
|
|
145
146
|
if (http.headers) res.set(http.headers);
|
|
146
147
|
if (dynamic) {
|
|
147
|
-
aop =
|
|
148
|
+
aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
|
|
148
149
|
globalFilter,
|
|
149
150
|
globalGuards,
|
|
150
151
|
globalPipe
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
joinUrl
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-VX4BZEL7.mjs";
|
|
8
8
|
import {
|
|
9
9
|
HMR,
|
|
10
10
|
__name
|
|
@@ -53,6 +53,7 @@ function bind(router, data, opts = {}) {
|
|
|
53
53
|
try {
|
|
54
54
|
return Promise.all(body.map((item, i) => {
|
|
55
55
|
return new Promise(async (resolve) => {
|
|
56
|
+
if (!item) return resolve(null);
|
|
56
57
|
const { tag, func } = item;
|
|
57
58
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
58
59
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-Ctd6pLNE.mjs';
|
|
3
|
+
import { F as Factory } from '../../core-jUg1HvYT.mjs';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-xvg6V7pH.mjs';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface FastifyCtx extends HttpCtx {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
|
|
2
|
-
import { H as HttpCtx, a as HttpOptions } from '../../types-
|
|
3
|
-
import { F as Factory } from '../../core-
|
|
2
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-B-1OL-3P.js';
|
|
3
|
+
import { F as Factory } from '../../core-CDzIy2g0.js';
|
|
4
4
|
import 'node:http';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-xvg6V7pH.js';
|
|
6
6
|
import 'phecda-core';
|
|
7
7
|
|
|
8
8
|
interface FastifyCtx extends HttpCtx {
|