phecda-server 4.0.0-alpha.6 → 4.0.0-alpha.7
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/dist/{core-c289deb2.d.ts → core-72b1280e.d.ts} +1 -2
- package/dist/index.d.ts +5 -6
- package/dist/index.js +63 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -57
- package/dist/index.mjs.map +1 -1
- package/dist/rpc/rabbitmq/index.d.ts +12 -5
- package/dist/rpc/rabbitmq/index.js +14 -4
- package/dist/rpc/rabbitmq/index.js.map +1 -1
- package/dist/rpc/rabbitmq/index.mjs +14 -4
- package/dist/rpc/rabbitmq/index.mjs.map +1 -1
- package/dist/rpc/redis/index.d.ts +13 -5
- package/dist/rpc/redis/index.js +16 -5
- package/dist/rpc/redis/index.js.map +1 -1
- package/dist/rpc/redis/index.mjs +16 -5
- package/dist/rpc/redis/index.mjs.map +1 -1
- package/dist/test.d.ts +3 -3
- package/dist/test.js +3 -5
- package/dist/test.js.map +1 -1
- package/dist/test.mjs +3 -5
- package/dist/test.mjs.map +1 -1
- package/dist/{types-2c710fc7.d.ts → types-ff44d472.d.ts} +3 -2
- package/package.json +1 -1
- package/register/index.mjs +2 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P, b as Emitter, d as Meta, C as Construct } from './types-
|
|
1
|
+
import { P, b as Emitter, d as Meta, C as Construct } from './types-ff44d472.js';
|
|
2
2
|
|
|
3
3
|
declare class Histroy {
|
|
4
4
|
guard: string[];
|
|
@@ -36,7 +36,6 @@ declare abstract class BaseContext<Data = any> {
|
|
|
36
36
|
|
|
37
37
|
declare const emitter: Emitter;
|
|
38
38
|
declare function Factory(Modules: (new (...args: any) => any)[], opts?: {
|
|
39
|
-
dev?: boolean;
|
|
40
39
|
http?: string;
|
|
41
40
|
rpc?: string;
|
|
42
41
|
}): Promise<{
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RequestHandler, Router } from 'express';
|
|
2
|
-
import { E as Exception, P, S as ServerCtx, a as ServerErr } from './types-
|
|
3
|
-
export {
|
|
4
|
-
import { B as BaseContext, F as Factory } from './core-
|
|
5
|
-
export { e as emitter } from './core-
|
|
2
|
+
import { E as Exception, P, S as ServerCtx, a as ServerErr } from './types-ff44d472.js';
|
|
3
|
+
export { B as BaseError, C as Construct, b as Emitter, M as MergeType, d as Meta, R as RequestType, c as ServerBase, T as ToInstance } from './types-ff44d472.js';
|
|
4
|
+
import { B as BaseContext, F as Factory } from './core-72b1280e.js';
|
|
5
|
+
export { e as emitter } from './core-72b1280e.js';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
7
|
|
|
8
8
|
declare class UndefinedException extends Exception {
|
|
@@ -86,7 +86,6 @@ declare function addGuard(key: string, handler: P.Guard<ServerCtx>): void;
|
|
|
86
86
|
declare function addInterceptor(key: string, handler: P.Interceptor<ServerCtx>): void;
|
|
87
87
|
|
|
88
88
|
interface Options {
|
|
89
|
-
dev?: boolean;
|
|
90
89
|
route?: string;
|
|
91
90
|
globalGuards?: string[];
|
|
92
91
|
globalInterceptors?: string[];
|
|
@@ -110,7 +109,7 @@ declare function Put(route: string): any;
|
|
|
110
109
|
declare function Patch(route: string): any;
|
|
111
110
|
declare function Delete(route: string): any;
|
|
112
111
|
declare function Controller(route: string): any;
|
|
113
|
-
declare function Rpc(...rpc: string[]): (target: any, key: PropertyKey) => void;
|
|
112
|
+
declare function Rpc(...rpc: ('mq' | 'redis' | string)[]): (target: any, key: PropertyKey) => void;
|
|
114
113
|
|
|
115
114
|
declare function Guard(...guards: string[]): any;
|
|
116
115
|
declare function Middle(...middlewares: string[]): any;
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,6 @@ __export(src_exports, {
|
|
|
37
37
|
Arg: () => Arg,
|
|
38
38
|
BadGatewayException: () => BadGatewayException,
|
|
39
39
|
BadRequestException: () => BadRequestException,
|
|
40
|
-
Base: () => Base,
|
|
41
40
|
BaseContext: () => BaseContext,
|
|
42
41
|
BaseParam: () => BaseParam,
|
|
43
42
|
Body: () => Body,
|
|
@@ -72,6 +71,7 @@ __export(src_exports, {
|
|
|
72
71
|
Route: () => Route,
|
|
73
72
|
Rpc: () => Rpc,
|
|
74
73
|
SERIES_SYMBOL: () => SERIES_SYMBOL,
|
|
74
|
+
ServerBase: () => ServerBase,
|
|
75
75
|
ServerFilter: () => ServerFilter,
|
|
76
76
|
ServerGuard: () => ServerGuard,
|
|
77
77
|
ServerInterceptor: () => ServerInterceptor,
|
|
@@ -305,6 +305,8 @@ var BaseContext = class {
|
|
|
305
305
|
this.tag = tag;
|
|
306
306
|
this.data = data;
|
|
307
307
|
this.history = new Histroy();
|
|
308
|
+
if (process.env.NODE_ENV === "development")
|
|
309
|
+
data._context = this;
|
|
308
310
|
}
|
|
309
311
|
usePipe(args) {
|
|
310
312
|
return this.singletonConf.pipe(args, this.tag, this.data);
|
|
@@ -404,10 +406,10 @@ function addInterceptor(key, handler) {
|
|
|
404
406
|
__name(addInterceptor, "addInterceptor");
|
|
405
407
|
|
|
406
408
|
// src/types.ts
|
|
407
|
-
var
|
|
409
|
+
var ServerBase = class {
|
|
408
410
|
context;
|
|
409
411
|
};
|
|
410
|
-
__name(
|
|
412
|
+
__name(ServerBase, "ServerBase");
|
|
411
413
|
|
|
412
414
|
// src/utils.ts
|
|
413
415
|
var import_picocolors = __toESM(require("picocolors"));
|
|
@@ -437,7 +439,7 @@ var APP_SYMBOL = "__PS__";
|
|
|
437
439
|
|
|
438
440
|
// src/server/express.ts
|
|
439
441
|
function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
440
|
-
const {
|
|
442
|
+
const { globalGuards, globalInterceptors, route, middlewares: proMiddle, parallel = true, series = true } = {
|
|
441
443
|
route: "/__PHECDA_SERVER__",
|
|
442
444
|
globalGuards: [],
|
|
443
445
|
globalInterceptors: [],
|
|
@@ -485,6 +487,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
485
487
|
for (const item of data) {
|
|
486
488
|
const { tag } = item;
|
|
487
489
|
const contextData = {
|
|
490
|
+
type: "express",
|
|
488
491
|
request: req,
|
|
489
492
|
meta: metaMap.get(tag),
|
|
490
493
|
response: res,
|
|
@@ -546,6 +549,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
546
549
|
return new Promise(async (resolve) => {
|
|
547
550
|
const { tag } = item;
|
|
548
551
|
const contextData = {
|
|
552
|
+
type: "express",
|
|
549
553
|
request: req,
|
|
550
554
|
meta: metaMap.get(tag),
|
|
551
555
|
response: res,
|
|
@@ -596,64 +600,65 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
|
|
|
596
600
|
});
|
|
597
601
|
for (const i of meta) {
|
|
598
602
|
const { method, http, header, tag } = i.data;
|
|
603
|
+
if (!http?.type)
|
|
604
|
+
continue;
|
|
599
605
|
const methodTag = `${tag}-${method}`;
|
|
600
606
|
const { reflect, handlers, data: { interceptors, guards, params, middlewares } } = metaMap.get(methodTag);
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}
|
|
607
|
+
app[http.type](http.route, (req, _res, next) => {
|
|
608
|
+
req[MODULE_SYMBOL] = moduleMap;
|
|
609
|
+
req[META_SYMBOL] = meta;
|
|
610
|
+
next();
|
|
611
|
+
}, ...Context.useMiddleware(middlewares), async (req, res) => {
|
|
612
|
+
const instance = moduleMap.get(tag);
|
|
613
|
+
const contextData = {
|
|
614
|
+
type: "express",
|
|
615
|
+
request: req,
|
|
616
|
+
meta: i,
|
|
617
|
+
response: res,
|
|
618
|
+
moduleMap
|
|
619
|
+
};
|
|
620
|
+
const context = new Context(methodTag, contextData);
|
|
621
|
+
try {
|
|
622
|
+
for (const name in header)
|
|
623
|
+
res.set(name, header[name]);
|
|
624
|
+
await context.useGuard([
|
|
625
|
+
...globalGuards,
|
|
626
|
+
...guards
|
|
627
|
+
]);
|
|
628
|
+
if (await context.useInterceptor([
|
|
629
|
+
...globalInterceptors,
|
|
630
|
+
...interceptors
|
|
631
|
+
]))
|
|
632
|
+
return;
|
|
633
|
+
const args = await context.usePipe(params.map(({ type, key, option, index }) => {
|
|
634
|
+
return {
|
|
635
|
+
arg: resolveDep(req[type], key),
|
|
636
|
+
option,
|
|
637
|
+
key,
|
|
638
|
+
type,
|
|
639
|
+
index,
|
|
640
|
+
reflect: reflect[index]
|
|
641
|
+
};
|
|
642
|
+
}));
|
|
643
|
+
instance.context = contextData;
|
|
644
|
+
const funcData = await instance[method](...args);
|
|
645
|
+
const ret = await context.usePostInterceptor(funcData);
|
|
646
|
+
if (isObject(ret))
|
|
647
|
+
res.json(ret);
|
|
648
|
+
else
|
|
649
|
+
res.send(String(ret));
|
|
650
|
+
} catch (e) {
|
|
651
|
+
handlers.forEach((handler) => handler.error?.(e));
|
|
652
|
+
const err = await context.useFilter(e);
|
|
653
|
+
res.status(err.status).json(err);
|
|
654
|
+
}
|
|
655
|
+
});
|
|
651
656
|
}
|
|
652
657
|
}
|
|
653
658
|
__name(createRoute, "createRoute");
|
|
654
659
|
handleMeta();
|
|
655
660
|
createRoute();
|
|
656
|
-
if (
|
|
661
|
+
if (process.env.NODE_ENV === "development") {
|
|
657
662
|
const rawMetaHmr = globalThis.__PS_WRITEMETA__;
|
|
658
663
|
globalThis.__PS_WRITEMETA__ = () => {
|
|
659
664
|
app.stack = [];
|
|
@@ -780,7 +785,7 @@ async function Factory(Modules, opts = {}) {
|
|
|
780
785
|
const constructorMap = /* @__PURE__ */ new Map();
|
|
781
786
|
const constructorSet = /* @__PURE__ */ new WeakSet();
|
|
782
787
|
const moduleGraph = /* @__PURE__ */ new Map();
|
|
783
|
-
const {
|
|
788
|
+
const { http, rpc } = opts;
|
|
784
789
|
(0, import_phecda_core2.injectProperty)("watcher", ({ eventName, instance, key, options }) => {
|
|
785
790
|
const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
|
|
786
791
|
if (options?.once)
|
|
@@ -869,7 +874,7 @@ async function Factory(Modules, opts = {}) {
|
|
|
869
874
|
}
|
|
870
875
|
__name(writeMeta, "writeMeta");
|
|
871
876
|
writeMeta();
|
|
872
|
-
if (
|
|
877
|
+
if (process.env.NODE_ENV === "development") {
|
|
873
878
|
globalThis.__PS_HMR__ = async (file) => {
|
|
874
879
|
debug(`reload file ${file}`);
|
|
875
880
|
const module2 = await import(file);
|
|
@@ -1177,7 +1182,6 @@ __name(ServerFilter, "ServerFilter");
|
|
|
1177
1182
|
Arg,
|
|
1178
1183
|
BadGatewayException,
|
|
1179
1184
|
BadRequestException,
|
|
1180
|
-
Base,
|
|
1181
1185
|
BaseContext,
|
|
1182
1186
|
BaseParam,
|
|
1183
1187
|
Body,
|
|
@@ -1212,6 +1216,7 @@ __name(ServerFilter, "ServerFilter");
|
|
|
1212
1216
|
Route,
|
|
1213
1217
|
Rpc,
|
|
1214
1218
|
SERIES_SYMBOL,
|
|
1219
|
+
ServerBase,
|
|
1215
1220
|
ServerFilter,
|
|
1216
1221
|
ServerGuard,
|
|
1217
1222
|
ServerInterceptor,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/exception/base.ts","../src/exception/undefine.ts","../src/exception/validate.ts","../src/exception/forbidden.ts","../src/exception/bad-request.ts","../src/exception/not-found.ts","../src/exception/conflict.ts","../src/exception/bad-gateway.ts","../src/exception/invalid-input.ts","../src/exception/media-type.ts","../src/exception/payload-large.ts","../src/exception/timeout.ts","../src/exception/unauthorized.ts","../src/exception/unavailable-service.ts","../src/exception/framework.ts","../src/pipe.ts","../src/filter.ts","../src/history.ts","../src/context/base.ts","../src/context/server.ts","../src/types.ts","../src/utils.ts","../src/helper.ts","../src/common.ts","../src/server/express.ts","../src/core.ts","../src/meta.ts","../src/compiler/rpc.ts","../src/compiler/http.ts","../src/decorators/index.ts","../src/decorators/param.ts","../src/decorators/route.ts","../src/decorators/aop.ts","../src/modules/dev.ts","../src/modules/guard.ts","../src/modules/interceptor.ts","../src/modules/pipe.ts","../src/modules/filter.ts"],"sourcesContent":["export * from './context'\nexport * from './types'\nexport * from './server/express'\nexport * from './core'\nexport * from './decorators'\nexport * from './exception'\nexport * from './pipe'\nexport * from './meta'\nexport * from 'phecda-core'\nexport * from './helper'\nexport * from './common'\nexport * from './modules'\nexport * from './compiler'\n","export class Exception extends Error {\n constructor(public message: string, public status: number, public description = 'Http exception') {\n super(message)\n }\n\n get data() {\n return { message: this.message, description: this.description, status: this.status, error: true }\n }\n}\n","import { Exception } from './base'\n\nexport class UndefinedException extends Exception {\n constructor(message: string) {\n super(message, 500, 'Undefined error')\n }\n}\n","import { Exception } from './base'\n\nexport class ValidateException extends Exception {\n constructor(message: string) {\n super(message, 400, 'Validate exception')\n }\n}\n","import { Exception } from './base'\n\nexport class ForbiddenException extends Exception {\n constructor(message: string) {\n super(message, 403, 'Forbidden resource')\n }\n}\n","import { Exception } from './base'\n\nexport class BadRequestException extends Exception {\n constructor(message: string) {\n super(message, 400, 'Bad Request')\n }\n}\n","import { Exception } from './base'\n\nexport class NotFoundException extends Exception {\n constructor(message: string) {\n super(message, 404, 'Not Found')\n }\n}\n","import { Exception } from './base'\n\nexport class ConflictException extends Exception {\n constructor(message: string) {\n super(message, 409, 'Conflict')\n }\n}\n","import { Exception } from './base'\n\nexport class BadGatewayException extends Exception {\n constructor(message: string) {\n super(message, 502, 'Bad Gatrway')\n }\n}\n","import { Exception } from './base'\n\nexport class InvalidInputException extends Exception {\n constructor(message: string) {\n super(message, 502, 'Invalid Input')\n }\n}\n","import { Exception } from './base'\n\nexport class UnsupportedMediaTypeException extends Exception {\n constructor(message: string) {\n super(message, 415, 'Unsupported Media Type')\n }\n}\n","import { Exception } from './base'\n\nexport class PayloadLargeException extends Exception {\n constructor(message: string) {\n super(message, 413, 'Payload Too Large')\n }\n}\n","import { Exception } from './base'\n\nexport class TimeoutException extends Exception {\n constructor(message: string) {\n super(message, 408, 'Request Timeout',\n )\n }\n}\n","import { Exception } from './base'\n\nexport class UnauthorizedException extends Exception {\n constructor(message: string) {\n super(message, 401, 'Unauthorized')\n }\n}\n","import { Exception } from './base'\n\nexport class ServiceUnavailableException extends Exception {\n constructor(message: string) {\n super(message, 503, 'Service Unavailable')\n }\n}\n","import { Exception } from './base'\n\nexport class FrameworkException extends Exception {\n constructor(message: string) {\n super(`[phecda-server] ${message}`, 500, 'Framework Error')\n }\n}\n","import { isPhecda, plainToClass } from 'phecda-core'\nimport { ValidateException } from './exception/validate'\n\nimport type { P } from './types'\n\nexport const defaultPipe: P.Pipe = async (args: any[]) => {\n for (const i in args) {\n const { option, arg, reflect } = args[i]\n if (option === false)\n continue\n if (!reflect) {\n if (option && arg)\n args[i].arg = option(arg)\n\n continue\n }\n\n if (isPhecda(reflect)) {\n const ret = await plainToClass(reflect, arg, { transform: true })\n if (ret.err.length > 0)\n throw new ValidateException(ret.err[0])\n args[i].arg = ret.data\n }\n else {\n if ([Number, Boolean].includes(reflect)) {\n args[i].arg = reflect(arg)\n\n if (reflect === Number && Object.is(args[i].arg, NaN))\n throw new ValidateException(`parameter ${Number(i) + 1} should be a number`)\n }\n }\n }\n return args.map(item => item.arg)\n}\n","import { Exception, UndefinedException } from './exception'\nimport type { P } from './types'\n\nexport const defaultFilter: P.Filter = (e: any) => {\n if (!(e instanceof Exception)) {\n console.error(e.stack)\n e = new UndefinedException(e.message || e)\n }\n else {\n console.error(e.message)\n }\n\n return e.data\n}\n","export class Histroy {\n guard: string[] = []\n interceptor: string[] = []\n record(name: string, type: 'guard' | 'interceptor') {\n if (!this[type].includes(name)) {\n this[type].push(name)\n return true\n }\n return false\n }\n}\n","import { ForbiddenException, FrameworkException } from '../exception'\nimport { Histroy } from '../history'\nimport type { P } from '../types'\n\nexport abstract class BaseContext<Data = any> {\n method: string\n params: string[]\n history = new Histroy()\n abstract singletonConf: {\n filter: P.Filter\n pipe: P.Pipe\n }\n\n abstract guardsRecord: Record<string, P.Guard>\n abstract interceptorsRecord: Record<string, P.Interceptor>\n postInterceptors: Function[]\n\n constructor(public tag: string, public data: Data) {\n }\n\n usePipe(args: { arg: any; option?: any; type: string; key: string; index: number; reflect: any }[]) {\n return this.singletonConf.pipe(args, this.tag, this.data)\n }\n\n useFilter(arg: any) {\n return this.singletonConf.filter(arg, this.tag, this.data)\n }\n\n async useGuard(guards: string[]) {\n for (const guard of guards) {\n if (this.history.record(guard, 'guard')) {\n if (!(guard in this.guardsRecord)) {\n if (process.env.PS_STRICT)\n throw new FrameworkException(`can't find guard named '${guard}'`)\n continue\n }\n if (!await this.guardsRecord[guard](this.tag, this.data))\n throw new ForbiddenException(`Guard exception--${guard}`)\n }\n }\n }\n\n async usePostInterceptor(ret: any) {\n for (const cb of this.postInterceptors)\n ret = await cb(ret) || ret\n\n return ret\n }\n\n async useInterceptor(interceptors: string[]) {\n const ret = []\n for (const interceptor of interceptors) {\n if (this.history.record(interceptor, 'interceptor')) {\n if (!(interceptor in this.interceptorsRecord)) {\n if (process.env.PS_STRICT)\n throw new FrameworkException(`can't find interceptor named '${interceptor}'`)\n\n continue\n }\n const postInterceptor = await this.interceptorsRecord[interceptor](this.tag, this.data)\n if (postInterceptor !== undefined) {\n if (typeof postInterceptor === 'function')\n ret.push(postInterceptor)\n\n else\n return true\n }\n }\n }\n this.postInterceptors = ret\n }\n}\n","import type { RequestHandler } from 'express'\nimport { FrameworkException } from '../exception'\nimport { defaultPipe } from '../pipe'\nimport { defaultFilter } from '../filter'\nimport type { P, ServerCtx, ServerErr } from '../types'\n\nimport { BaseContext } from './base'\n\nexport const guardsRecord = {} as Record<string, P.Guard<ServerCtx>>\n\nexport const interceptorsRecord = {} as Record<string, P.Interceptor<ServerCtx>>\n\nexport const middlewareRecord = {} as Record<string, (...params: any) => any>\n\nexport const singletonConf = {\n pipe: defaultPipe,\n filter: defaultFilter,\n}\nexport class Context extends BaseContext<ServerCtx> {\n singletonConf = singletonConf\n // static metaRecord: Record<string, Meta> = {}\n // static metaDataRecord: Record<string, ReturnType<typeof parseMeta>> = {}\n\n static middlewareRecord = middlewareRecord\n guardsRecord = guardsRecord\n interceptorsRecord = interceptorsRecord\n\n postInterceptors: Function[]\n\n static useMiddleware(middlewares: string[]) {\n const ret = []\n for (const m of middlewares) {\n if (!(m in Context.middlewareRecord)) {\n if (process.env.PS_STRICT)\n throw new FrameworkException(`can't find middleware named '${m}'`)\n\n continue\n }\n ret.push(Context.middlewareRecord[m])\n }\n return ret\n }\n}\n\nexport function addMiddleware(key: string, handler: RequestHandler) {\n middlewareRecord[key] = handler\n}\n\nexport function setPipe(pipe: P.Pipe<ServerCtx>) {\n singletonConf.pipe = pipe\n}\n\nexport function setFilter(filter: P.Filter<ServerCtx, ServerErr>) {\n singletonConf.filter = filter\n}\n\nexport function addGuard(key: string, handler: P.Guard<ServerCtx>) {\n guardsRecord[key] = handler\n}\n\nexport function addInterceptor(key: string, handler: P.Interceptor<ServerCtx>) {\n interceptorsRecord[key] = handler\n}\n","import type { Request, Response } from 'express'\nimport type { Events } from 'phecda-core'\nimport type { Meta } from './meta'\nimport type { Exception } from './exception'\nexport type Construct<T = any> = new (...args: any[]) => T\n\nexport interface Emitter {\n on<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n once<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n off<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n removeAllListeners<N extends keyof Events>(eventName: N): void\n emit<N extends keyof Events>(eventName: N, param: Events[N]): void\n}\n\nexport type ToInstance<T = any> = {\n [K in keyof T]: T[K] extends (new (...args: any) => any) ? InstanceType<T[K]> : void\n}\n\nexport type RequestType = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head'\n\nexport type MergeType = <R extends Promise<any>[]> (...args: R) => { [K in keyof R]: Awaited<R[K]> }\n\n// export interface ServerMergeCtx {\n// request: Request\n// response: Response\n// meta: Record<string, Meta>\n// moduleMap: Record<string, any>\n// isMerge: true\n// tags?: string[]\n// }\n\nexport interface ServerCtx {\n request: Request\n response: Response\n meta: Meta\n moduleMap: Record<string, any>\n}\n\nexport interface ServerErr { message: string; description: string; status: number; error: boolean }\n\nexport interface BaseError {\n error: true\n status: number\n}\n\nexport class Base {\n context: ServerCtx\n}\n\nexport namespace P {\n export interface Error extends BaseError { message: string; description: string }\n\n export type ResOrErr<R> = { [K in keyof R]: Awaited<R[K]> | Error }\n\n export type Res<T> = T\n export type Guard<C = any> = ((tag: string, ctx: C) => Promise<boolean> | boolean)\n\n export type Interceptor<C = any> = (tag: string, ctx: C) =>(any | ((ret: any) => any))\n\n export type Pipe<C = any> = (args: { arg: any; option?: any; key: string; type: string; index: number; reflect: any }[], tag: string, ctx: C) => Promise<any[]>\n export type Filter<C = any, R = any, E extends Exception = any > = (err: E | Error, tag?: string, ctx?: C) => R | Promise<R>\n\n export interface Handler {\n error?: (arg: any) => void\n }\n export interface Meta {\n http?: {\n type: RequestType\n route: string\n }\n rpc?: string[]\n define?: any\n header: Record<string, string>\n params: { type: string; index: number; key: string; option?: any }[]\n guards: string[]\n interceptors: string[]\n middlewares: string[]\n method: string\n name: string\n tag: string\n }\n\n}\n","import pc from 'picocolors'\nimport type { Meta } from './meta'\nexport const isUndefined = (obj: any): obj is undefined =>\n typeof obj === 'undefined'\nexport const isNil = (obj: any): obj is null | undefined =>\n isUndefined(obj) || obj === null\n\nexport const isObject = (fn: any): fn is object =>\n !isNil(fn) && typeof fn === 'object'\n\nexport function warn(msg: string, color = 'yellow') {\n // @ts-expect-error pc\n console.warn(`${pc.magenta('[phecda-server]')} ${pc[color](msg)}`)\n}\n","export function resolveDep(ret: any, key: string) {\n if (key)\n return ret?.[key]\n return ret\n}\n","export const SERIES_SYMBOL = '__PS_SERIES__'\nexport const MERGE_SYMBOL = '__PS_MERGE__'\nexport const UNMOUNT_SYMBOL = '__PS_UNMOUNT__'\nexport const MODULE_SYMBOL = '__PS_MODULE__'\nexport const META_SYMBOL = '__PS_META__'\nexport const APP_SYMBOL = '__PS__'\n","import type { Express, Router } from 'express'\nimport { Context, singletonConf } from '../context'\nimport { isObject } from '../utils'\nimport { resolveDep } from '../helper'\nimport { APP_SYMBOL, MERGE_SYMBOL, META_SYMBOL, MODULE_SYMBOL, SERIES_SYMBOL } from '../common'\nimport type { Factory } from '../core'\nimport { BadRequestException, FrameworkException } from '../exception'\nimport type { Meta } from '../meta'\n\nexport interface Options {\n\n dev?: boolean\n /**\n * 专用路由的值,默认为/__PHECDA_SERVER__,处理phecda-client发出的合并请求\n */\n route?: string\n /**\n * 全局守卫\n */\n globalGuards?: string[]\n /**\n * 全局拦截器\n */\n globalInterceptors?: string[]\n /**\n * 专用路由的中间件(work for merge request),全局中间件请在bindApp以外设置\n */\n middlewares?: string[]\n\n /**\n * allow parallel request,default is true\n */\n parallel?: boolean\n\n /**\n * allow series request,default is true\n */\n series?: boolean\n}\n\nexport function bindApp(app: Router, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, options: Options = {}) {\n const { dev = process.env.NODE_ENV !== 'production', globalGuards, globalInterceptors, route, middlewares: proMiddle, parallel = true, series = true } = { route: '/__PHECDA_SERVER__', globalGuards: [], globalInterceptors: [], middlewares: [], ...options } as Required<Options>\n (app as any)[APP_SYMBOL] = { moduleMap, meta }\n\n const metaMap = new Map<string, Meta>()\n function handleMeta() {\n metaMap.clear()\n for (const item of meta) {\n const { tag, method, http } = item.data\n if (!http?.type)\n continue\n const methodTag = `${tag}-${method}`\n metaMap.set(methodTag, item)\n }\n }\n\n async function createRoute() {\n (app as Express).post(route, (req, _res, next) => {\n (req as any)[MERGE_SYMBOL] = true;\n (req as any)[MODULE_SYMBOL] = moduleMap;\n (req as any)[META_SYMBOL] = meta\n\n next()\n }, ...Context.useMiddleware(proMiddle), async (req, res) => {\n const { body: { category, data } } = req\n\n async function errorHandler(e: any) {\n const error = await singletonConf.filter(e)\n return res.status(error.status).json(error)\n }\n\n if (!Array.isArray(data))\n return errorHandler(new BadRequestException('data format should be an array'))\n\n if (category !== 'series' && category !== 'parallel')\n return errorHandler(new BadRequestException('category should be \\'parallel\\' or \\'series\\''))\n\n const ret = [] as any[]\n try {\n if (category === 'series') {\n if (!series)\n return errorHandler(new FrameworkException('series request is not allowed'))\n\n for (const item of data) {\n const { tag } = item\n const contextData = {\n request: req,\n meta: metaMap.get(tag)!,\n response: res,\n moduleMap,\n\n }\n const context = new Context(tag, contextData)\n try {\n const [name, method] = tag.split('-')\n const {\n reflect,\n data: {\n params,\n guards,\n interceptors,\n },\n } = contextData.meta\n const instance = moduleMap.get(name)\n if (!params)\n throw new BadRequestException(`\"${tag}\" doesn't exist`)\n\n await context.useGuard([...globalGuards, ...guards])\n if (await context.useInterceptor([...globalInterceptors, ...interceptors])\n ) return\n const args = await context.usePipe(params.map(({ type, key, option, index }) => {\n const arg = resolveDep(item[type], key)\n if (typeof arg === 'string' && arg.startsWith(SERIES_SYMBOL)) {\n const [, argIndex, argKey] = arg.split('@')\n return { arg: resolveDep(ret[Number(argIndex)], argKey || key), option, index, type, key, reflect: reflect[index] }\n }\n\n return { arg, option, index, type, key, reflect: reflect[index] }\n })) as any\n instance.context = contextData\n const funcData = await moduleMap.get(name)[method](...args)\n\n ret.push(await context.usePostInterceptor(funcData))\n }\n catch (e: any) {\n const m = metaMap.get(tag)!\n m.handlers.forEach(handler => handler.error?.(e))\n ret.push(await context.useFilter(e))\n }\n }\n\n return res.json(ret)\n }\n if (category === 'parallel') {\n if (!parallel)\n return errorHandler(new FrameworkException('parallel request is not allowed'))\n\n return Promise.all(data.map((item: any) => {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve) => {\n const { tag } = item\n const contextData = {\n request: req,\n meta: metaMap.get(tag)!,\n response: res,\n moduleMap,\n }\n const context = new Context(tag, contextData)\n const [name, method] = tag.split('-')\n const {\n reflect,\n\n handlers,\n\n data: {\n params,\n guards, interceptors,\n },\n } = metaMap.get(tag)!\n\n const instance = moduleMap.get(name)\n\n try {\n if (!params)\n throw new BadRequestException(`\"${tag}\" doesn't exist`)\n await context.useGuard([...globalGuards, ...guards])\n if (await context.useInterceptor([...globalInterceptors, ...interceptors])\n ) return\n const args = await context.usePipe(params.map(({ type, key, option, index }) => {\n const arg = resolveDep(item[type], key)\n return { arg, type, key, option, index, reflect: reflect[index] }\n })) as any\n instance.context = contextData\n const funcData = await moduleMap.get(name)[method](...args)\n resolve(await context.usePostInterceptor(funcData))\n }\n catch (e: any) {\n handlers.forEach(handler => handler.error?.(e))\n resolve(await context.useFilter(e))\n }\n })\n })).then((ret) => {\n res.json(ret)\n })\n }\n }\n catch (e) {\n return errorHandler(e)\n }\n })\n for (const i of meta) {\n const { method, http, header, tag } = i.data\n const methodTag = `${tag}-${method}`\n const {\n reflect,\n handlers,\n data: {\n interceptors,\n guards,\n\n params,\n middlewares,\n },\n } = metaMap.get(methodTag)!\n\n if (http?.type) {\n (app as Express)[http.type](http.route, (req, _res, next) => {\n (req as any)[MODULE_SYMBOL] = moduleMap;\n (req as any)[META_SYMBOL] = meta\n next()\n }, ...Context.useMiddleware(middlewares), async (req, res) => {\n const instance = moduleMap.get(tag)!\n const contextData = {\n request: req,\n meta: i,\n response: res,\n moduleMap,\n }\n const context = new Context(methodTag, contextData)\n\n try {\n for (const name in header)\n res.set(name, header[name])\n await context.useGuard([...globalGuards, ...guards])\n if (await context.useInterceptor([...globalInterceptors, ...interceptors]))\n return\n\n const args = await context.usePipe(params.map(({ type, key, option, index }) => {\n return { arg: resolveDep((req as any)[type], key), option, key, type, index, reflect: reflect[index] }\n }))\n\n instance.context = contextData\n const funcData = await instance[method](...args)\n const ret = await context.usePostInterceptor(funcData)\n\n if (isObject(ret))\n res.json(ret)\n else\n res.send(String(ret))\n }\n catch (e: any) {\n handlers.forEach(handler => handler.error?.(e))\n const err = await context.useFilter(e)\n res.status(err.status).json(err)\n }\n })\n }\n }\n }\n\n handleMeta()\n createRoute()\n if (dev) {\n // @ts-expect-error globalThis\n const rawMetaHmr = globalThis.__PS_WRITEMETA__\n // @ts-expect-error globalThis\n\n globalThis.__PS_WRITEMETA__ = () => {\n app.stack = []// app.stack.slice(0, 1)\n handleMeta()\n\n createRoute()\n rawMetaHmr?.()\n }\n }\n}\n","import 'reflect-metadata'\nimport fs from 'fs'\nimport EventEmitter from 'node:events'\nimport type { Phecda } from 'phecda-core'\nimport { getExposeKey, getHandler, getState, injectProperty, isPhecda, registerAsync } from 'phecda-core'\nimport Debug from 'debug'\nimport type { Construct, Emitter, P } from './types'\nimport { Meta } from './meta'\nimport { warn } from './utils'\nimport { UNMOUNT_SYMBOL } from './common'\nimport { generateHTTPCode, generateRPCCode } from './compiler'\n\nconst debug = Debug('phecda-server')\n// TODO: support both emitter types and origin emitter type in future\nexport const emitter: Emitter = new EventEmitter() as any\n\nexport async function Factory(Modules: (new (...args: any) => any)[], opts: {\n dev?: boolean\n // HTTP generate code path\n http?: string\n // rpc generate code path\n rpc?: string\n} = {}) {\n const moduleMap = new Map<string, InstanceType<Construct>>()\n const meta: Meta[] = []\n const constructorMap = new Map()\n\n // only work for warn\n const constructorSet = new WeakSet()\n const moduleGraph = new Map<string, Set<string>>()\n const { dev = process.env.NODE_ENV !== 'production', http, rpc } = opts\n injectProperty('watcher', ({ eventName, instance, key, options }: { eventName: string; instance: any; key: string; options?: { once: boolean } }) => {\n const fn = typeof instance[key] === 'function' ? instance[key].bind(instance) : (v: any) => instance[key] = v\n\n if (options?.once)\n (emitter as any).once(eventName, fn)\n\n else\n (emitter as any).on(eventName, fn)\n })\n\n async function update(Module: Construct) {\n const tag = Module.prototype?.__TAG__ || Module.name\n if (!moduleMap.has(tag))\n return\n debug(`update module \"${tag}\"`)\n\n const instance = moduleMap.get(tag)\n\n if (instance?.[UNMOUNT_SYMBOL]) {\n for (const cb of instance[UNMOUNT_SYMBOL])\n await cb()\n }\n moduleMap.delete(tag)\n constructorMap.delete(tag)\n for (let i = meta.length - 1; i >= 0; i--) {\n if (meta[i].data.tag === tag)\n meta.splice(i, 1)\n }\n\n const { instance: newModule } = await buildNestModule(Module)\n if (moduleGraph.has(tag)) {\n [...moduleGraph.get(tag)!].forEach((tag) => {\n const module = moduleMap.get(tag)\n for (const key in module) {\n if (module[key] === instance)\n module[key] = newModule\n }\n })\n }\n\n moduleMap.set(tag, newModule)\n }\n async function buildNestModule(Module: Construct) {\n const paramtypes = getParamtypes(Module) as Construct[]\n let instance: InstanceType<Construct>\n const tag = Module.prototype?.__TAG__ || Module.name\n if (moduleMap.has(tag)) {\n instance = moduleMap.get(tag)\n if (!instance)\n throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${tag}--[module] ${Module}`)\n\n if (constructorMap.get(tag) !== Module && !constructorSet.has(Module)) {\n constructorSet.add(Module)// a module will only warn once\n warn(`Synonym module: Module taged \"${tag}\" has been loaded before, so phecda-server won't load Module \"${Module.name}\"`)\n }\n return { instance, tag }\n }\n moduleMap.set(tag, undefined)\n if (paramtypes) {\n const paramtypesInstances = [] as any[]\n for (const i in paramtypes) {\n const { instance: sub, tag: subTag } = await buildNestModule(paramtypes[i])\n paramtypesInstances[i] = sub\n if (!moduleGraph.has(subTag))\n moduleGraph.set(subTag, new Set())\n moduleGraph.get(subTag)!.add(tag)\n }\n instance = new Module(...paramtypesInstances)\n }\n else {\n instance = new Module()\n }\n meta.push(...getMetaFromInstance(instance, tag, Module.name))\n await registerAsync(instance)\n moduleMap.set(tag, instance)\n constructorMap.set(tag, Module)\n return { instance, tag }\n }\n\n for (const Module of Modules)\n await buildNestModule(Module)\n\n function writeMeta() {\n debug('write metadata')\n\n http && fs.promises.writeFile(http, generateHTTPCode(meta.map(item => item.data)))\n rpc && fs.promises.writeFile(rpc, generateRPCCode(meta.map(item => item.data)))\n }\n\n writeMeta()\n if (dev) {\n // @ts-expect-error globalThis\n globalThis.__PS_HMR__ = async (file: string) => {\n debug(`reload file ${file}`)\n const module = await import(file)\n for (const i in module) {\n if (isPhecda(module[i]))\n await update(module[i])\n }\n }\n // @ts-expect-error globalThis\n globalThis.__PS_WRITEMETA__ = writeMeta\n }\n\n return {\n moduleMap,\n meta,\n constructorMap,\n update,\n }\n}\n\nfunction getMetaFromInstance(instance: Phecda, tag: string, name: string) {\n const vars = getExposeKey(instance).filter(item => item !== '__CLASS')\n const baseState = (getState(instance, '__CLASS') || {}) as P.Meta\n initState(baseState)\n\n return vars.map((i) => {\n const meta = {} as P.Meta\n const state = (getState(instance, i) || {}) as P.Meta\n initState(state)\n if (state.http) {\n meta.http = {\n route: (baseState.http?.route || '') + (state.http.route),\n type: state.http.type,\n }\n }\n if (state.rpc)\n meta.rpc = state.rpc\n\n meta.name = name\n meta.tag = tag\n meta.method = i as string\n const params = [] as any[]\n for (const i of state.params || []) {\n params.unshift(i)\n if (i.index === 0)\n break\n }\n\n meta.params = params\n meta.define = { ...baseState.define, ...state.define }\n meta.header = { ...baseState.header, ...state.header }\n meta.middlewares = [...new Set([...baseState.middlewares, ...state.middlewares])]\n meta.guards = [...new Set([...baseState.guards, ...state.guards])]\n meta.interceptors = [...new Set([...baseState.interceptors, ...state.interceptors])]\n\n return new Meta(meta as unknown as P.Meta, getHandler(instance, i), getParamtypes(instance, i as string) || [])\n })\n}\n\nfunction getParamtypes(Module: any, key?: string | symbol) {\n return Reflect.getMetadata('design:paramtypes', Module, key!)\n}\n\nfunction initState(state: any) {\n if (!state.define)\n state.define = {}\n if (!state.header)\n state.header = {}\n if (!state.middlewares)\n state.middlewares = []\n if (!state.guards)\n state.guards = []\n if (!state.interceptors)\n state.interceptors = []\n}\n","import type { P } from './types'\n\nexport class Meta {\n constructor(public data: P.Meta, public handlers: P.Handler[], public reflect: any[]) {\n\n }\n}\n","import type { P } from '../types'\n\nclass Compiler {\n classMap: Record<string, { [key: string]: string }> = {}\n constructor() { }\n\n getContent() {\n let content = ''\n\n for (const name in this.classMap) {\n content += `\n export class ${name}{\n ${Object.values(this.classMap[name]).reduce((p, c) => p + c)}\n }`\n }\n return content\n }\n\n // createRequest() {\n // let content = 'import {useC} from \\'phecda-server\\'\\n'\n // for (const name in this.classMap)\n // content += `export const {${Object.keys(this.classMap[name]).join(',')}}=useC(${name})\\n`\n // return content\n // }\n\n addMethod(args: P.Meta) {\n const {\n rpc, name, method, tag,\n } = args\n if (!rpc)\n return\n if (!this.classMap[name])\n this.classMap[name] = {}\n this.classMap[name][method] = `\n ${method}(){\n return {tag:'${tag}-${method}',rpc:[${rpc.reduce((p, c) => {\n return `${p}\"${c}\",`\n }, '')}]}\n\n }\n `\n }\n}\n\nexport function generateRPCCode(meta: P.Meta[]) {\n const compiler = new Compiler()\n\n for (const i of meta)\n compiler.addMethod(i)\n return compiler.getContent()\n}\n","import type { P } from '../types'\n\nclass Compiler {\n classMap: Record<string, { [key: string]: string }> = {}\n constructor() { }\n\n getContent() {\n let content = ''\n\n for (const name in this.classMap) {\n content += `\n export class ${name}{\n ${Object.values(this.classMap[name]).reduce((p, c) => p + c)}\n }`\n }\n return content\n }\n\n // createRequest() {\n // let content = 'import {useC} from \\'phecda-server\\'\\n'\n // for (const name in this.classMap)\n // content += `export const {${Object.keys(this.classMap[name]).join(',')}}=useC(${name})\\n`\n // return content\n // }\n\n addMethod(args: P.Meta) {\n const {\n http, name, method, params, tag,\n } = args\n if (!http)\n return\n const url = http.route.replace(/\\/\\:([^\\/]*)/g, (_, js) => `/{{${js}}}`)\n if (!this.classMap[name])\n this.classMap[name] = {}\n this.classMap[name][method] = `\n ${method}(${genParams(params)}){\nconst ret={tag:\"${tag}-${method}\",body:{},headers:{},query:{},params:{},method:\"${http.type}\",url:\"${url}\"}\n${params.reduce((p, c, i) => `${p}if(arg${i}!==undefined&&arg${i}!==null){ret.${c.type}${c.key ? `['${c.key}']` : ''}=arg${i}\\n${c.type === 'params' ? `ret.url=ret.url.replace('{{${c.key}}}',arg${i})}` : '}'}\\n`, '')}\nreturn ret\n }\n `\n }\n}\n\nfunction genParams(decorators: any[]) {\n return decorators.map((_, i) => {\n return `${`arg${i}`}`\n }).join(',')\n}\n\nexport function generateHTTPCode(meta: P.Meta[]) {\n const compiler = new Compiler()\n\n for (const i of meta)\n compiler.addMethod(i)\n return compiler.getContent()\n}\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function Header(name: string, value: string) {\n return (target: any, k: PropertyKey) => {\n setModelVar(target, k)\n const state = target._namespace.__STATE_NAMESPACE__.get(k) || {}\n if (!state.header)\n state.header = {}\n\n state.header[name] = value\n setState(target, k, state)\n }\n}\n\nexport function Define(key: string, value: any) {\n return (target: any, k?: PropertyKey) => {\n if (!k) {\n k = '__CLASS'\n target = target.prototype\n }\n\n setModelVar(target, k)\n const state = target._namespace.__STATE_NAMESPACE__.get(k) || {}\n if (!state.define)\n state.define = {}\n\n state.define[key] = value\n setState(target, k, state)\n }\n}\n\nexport * from './param'\nexport * from './route'\nexport * from './aop'\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function BaseParam(type: string, key: string, option?: any): any {\n return (target: any, k: PropertyKey, index: number) => {\n setModelVar(target, k)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(k) || {}\n if (!state.params)\n state.params = []\n\n state.params.push({ type, key, index, option })\n setState(target, k, state)\n }\n}\n\nexport function Body(key = '', pipeOpts?: any) {\n return BaseParam('body', key, pipeOpts)\n}\n// req.headers\nexport function Head(key: string, pipeOpts?: any) {\n return BaseParam('headers', key.toLowerCase(), pipeOpts)\n}\n\nexport function Query(key = '', pipeOpts?: any) {\n return BaseParam('query', key, pipeOpts)\n}\nexport function Param(key: string, pipeOpts?: any) {\n return BaseParam('params', key, pipeOpts)\n}\n\n// work for micro service\nexport function Arg(pipeOpts?: any) {\n return BaseParam('params', '', pipeOpts)\n}\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function Route(route: string, type?: string): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n state.http = {\n route,\n type,\n }\n setState(target, key, state)\n }\n}\n\nexport function Get(route: string) {\n return Route(route, 'get')\n}\n\nexport function Post(route: string) {\n return Route(route, 'post')\n}\nexport function Put(route: string) {\n return Route(route, 'put')\n}\n\nexport function Patch(route: string) {\n return Route(route, 'patch')\n}\nexport function Delete(route: string) {\n return Route(route, 'delete')\n}\n\nexport function Controller(route: string) {\n return Route(route)\n}\n\nexport function Rpc(...rpc: string[]) {\n return (target: any, key: PropertyKey) => {\n setModelVar(target, key)\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n state.rpc = rpc\n\n setState(target, key, state)\n }\n}\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function Guard(...guards: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n if (!state.guards)\n state.guards = []\n state.guards.push(...guards)\n setState(target, key, state)\n }\n}\n\nexport function Middle(...middlewares: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n if (!state.middlewares)\n state.middlewares = []\n state.middlewares.push(...middlewares)\n setState(target, key, state)\n }\n}\n\nexport function Interceptor(...interceptors: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n if (!state.interceptors)\n state.interceptors = []\n state.interceptors.push(...interceptors)\n setState(target, key, state)\n }\n}\n","import { UNMOUNT_SYMBOL } from '../common'\n\nexport class Dev {\n [UNMOUNT_SYMBOL]: (() => void)[] = []\n onUnmount(cb: () => void) {\n this[UNMOUNT_SYMBOL].push(cb)\n }\n}\n","import { addGuard } from '../context'\nimport type { ServerCtx } from '../types'\n\nexport abstract class ServerGuard {\n abstract use(tag: string, ctx: ServerCtx): Promise<boolean> | boolean\n\n constructor(tag: string) {\n addGuard(tag, this.use.bind(this))\n }\n}\n","import { addInterceptor } from '../context'\nimport type { ServerCtx } from '../types'\n\nexport abstract class ServerInterceptor {\n abstract use(tag: string, ctx: ServerCtx): ((arg: any) => any) | void\n\n constructor(tag: string) {\n addInterceptor(tag, this.use.bind(this))\n }\n}\n","import { setPipe } from '../context'\nimport type { ServerCtx } from '../types'\n\nexport abstract class ServerPipe {\n constructor() {\n setPipe(this.use.bind(this))\n }\n\n abstract use(args: { arg: any; option?: any; key: string; type: string; index: number; reflect: any }[], tag: string, ctx: ServerCtx): Promise<any[]>\n}\n","import { setFilter } from '../context'\nimport type { Exception } from '../exception'\nimport type { ServerCtx, ServerErr } from '../types'\n\nexport abstract class ServerFilter {\n constructor() {\n setFilter(this.use.bind(this))\n }\n\n abstract use< E extends Exception >(error: Error | E, tag?: string, ctx?: ServerCtx): ServerErr | Promise<ServerErr>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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MS,SAAS,CAAC;AAElBT,UAAMS,OAAOF,OAAOX;AACpBS,sCAASR,QAAQC,GAAGE,KAAAA;EACtB;AACF;AAfgBM;;;A9BNhB,wBAAc,wBARd;;;AkCEO,IAAMI,MAAN,MAAMA;EACX,CAACC,kBAAkC,CAAA;EACnCC,UAAUC,IAAgB;AACxB,SAAKF,gBAAgBG,KAAKD,EAAAA;EAC5B;AACF;AALaH;;;ACCN,IAAeK,cAAf,MAAeA;EAGpBC,YAAYC,KAAa;AACvBC,aAASD,KAAK,KAAKE,IAAIC,KAAK,IAAI,CAAA;EAClC;AACF;AANsBL;;;ACAf,IAAeM,oBAAf,MAAeA;EAGpBC,YAAYC,KAAa;AACvBC,mBAAeD,KAAK,KAAKE,IAAIC,KAAK,IAAI,CAAA;EACxC;AACF;AANsBL;;;ACAf,IAAeM,aAAf,MAAeA;EACpBC,cAAc;AACZC,YAAQ,KAAKC,IAAIC,KAAK,IAAI,CAAA;EAC5B;AAGF;AANsBJ;;;ACCf,IAAeK,eAAf,MAAeA;EACpBC,cAAc;AACZC,cAAU,KAAKC,IAAIC,KAAK,IAAI,CAAA;EAC9B;AAGF;AANsBJ;","names":["Exception","Error","message","status","description","constructor","data","error","UndefinedException","Exception","constructor","message","ValidateException","Exception","constructor","message","ForbiddenException","Exception","constructor","message","BadRequestException","Exception","constructor","message","NotFoundException","Exception","constructor","message","ConflictException","Exception","constructor","message","BadGatewayException","Exception","constructor","message","InvalidInputException","Exception","constructor","message","UnsupportedMediaTypeException","Exception","constructor","message","PayloadLargeException","Exception","constructor","message","TimeoutException","Exception","constructor","message","UnauthorizedException","Exception","constructor","message","ServiceUnavailableException","Exception","constructor","message","FrameworkException","Exception","constructor","message","defaultPipe","args","i","option","arg","reflect","isPhecda","ret","plainToClass","transform","err","length","ValidateException","data","Number","Boolean","includes","Object","is","NaN","map","item","defaultFilter","e","Exception","console","error","stack","UndefinedException","message","data","Histroy","guard","interceptor","record","name","type","includes","push","BaseContext","tag","data","method","params","history","postInterceptors","constructor","Histroy","usePipe","args","singletonConf","pipe","useFilter","arg","filter","useGuard","guards","guard","record","guardsRecord","process","env","PS_STRICT","FrameworkException","ForbiddenException","usePostInterceptor","ret","cb","useInterceptor","interceptors","interceptor","interceptorsRecord","postInterceptor","undefined","push","guardsRecord","interceptorsRecord","middlewareRecord","singletonConf","pipe","defaultPipe","filter","defaultFilter","Context","BaseContext","postInterceptors","useMiddleware","middlewares","ret","m","process","env","PS_STRICT","FrameworkException","push","addMiddleware","key","handler","setPipe","setFilter","addGuard","addInterceptor","Base","context","isUndefined","obj","isNil","isObject","fn","warn","msg","color","console","pc","magenta","resolveDep","ret","key","SERIES_SYMBOL","MERGE_SYMBOL","UNMOUNT_SYMBOL","MODULE_SYMBOL","META_SYMBOL","APP_SYMBOL","bindApp","app","moduleMap","meta","options","dev","process","env","NODE_ENV","globalGuards","globalInterceptors","route","middlewares","proMiddle","parallel","series","APP_SYMBOL","metaMap","Map","handleMeta","clear","item","tag","method","http","data","type","methodTag","set","createRoute","post","req","_res","next","MERGE_SYMBOL","MODULE_SYMBOL","META_SYMBOL","Context","useMiddleware","res","body","category","errorHandler","e","error","singletonConf","filter","status","json","Array","isArray","BadRequestException","ret","FrameworkException","contextData","request","get","response","context","name","split","reflect","params","guards","interceptors","instance","useGuard","useInterceptor","args","usePipe","map","key","option","index","arg","resolveDep","startsWith","SERIES_SYMBOL","argIndex","argKey","Number","funcData","push","usePostInterceptor","m","handlers","forEach","handler","useFilter","Promise","all","resolve","then","i","header","isObject","send","String","err","rawMetaHmr","globalThis","__PS_WRITEMETA__","stack","import_phecda_core","Meta","data","handlers","reflect","constructor","Compiler","classMap","constructor","getContent","content","name","Object","values","reduce","p","c","addMethod","args","rpc","method","tag","generateRPCCode","meta","compiler","i","Compiler","classMap","constructor","getContent","content","name","Object","values","reduce","p","c","addMethod","args","http","method","params","tag","url","route","replace","_","js","genParams","type","i","key","decorators","map","join","generateHTTPCode","meta","compiler","debug","Debug","emitter","EventEmitter","Factory","Modules","opts","moduleMap","Map","meta","constructorMap","constructorSet","WeakSet","moduleGraph","dev","process","env","NODE_ENV","http","rpc","injectProperty","eventName","instance","key","options","fn","bind","v","once","on","update","Module","tag","prototype","__TAG__","name","has","get","UNMOUNT_SYMBOL","cb","delete","i","length","data","splice","newModule","buildNestModule","forEach","module","set","paramtypes","getParamtypes","Error","add","warn","undefined","paramtypesInstances","sub","subTag","Set","push","getMetaFromInstance","registerAsync","writeMeta","fs","promises","writeFile","generateHTTPCode","map","item","generateRPCCode","globalThis","__PS_HMR__","file","isPhecda","__PS_WRITEMETA__","vars","getExposeKey","filter","baseState","getState","initState","state","route","type","method","params","unshift","index","define","header","middlewares","guards","interceptors","Meta","getHandler","Reflect","getMetadata","import_phecda_core","import_phecda_core","BaseParam","type","key","option","target","k","index","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","params","push","setState","Body","pipeOpts","Head","toLowerCase","Query","Param","Arg","import_phecda_core","Route","route","type","target","key","prototype","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","http","setState","Get","Post","Put","Patch","Delete","Controller","Rpc","rpc","import_phecda_core","Guard","guards","target","key","prototype","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","push","setState","Middle","middlewares","Interceptor","interceptors","Header","name","value","target","k","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","header","setState","Define","key","prototype","define","Dev","UNMOUNT_SYMBOL","onUnmount","cb","push","ServerGuard","constructor","tag","addGuard","use","bind","ServerInterceptor","constructor","tag","addInterceptor","use","bind","ServerPipe","constructor","setPipe","use","bind","ServerFilter","constructor","setFilter","use","bind"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/exception/base.ts","../src/exception/undefine.ts","../src/exception/validate.ts","../src/exception/forbidden.ts","../src/exception/bad-request.ts","../src/exception/not-found.ts","../src/exception/conflict.ts","../src/exception/bad-gateway.ts","../src/exception/invalid-input.ts","../src/exception/media-type.ts","../src/exception/payload-large.ts","../src/exception/timeout.ts","../src/exception/unauthorized.ts","../src/exception/unavailable-service.ts","../src/exception/framework.ts","../src/pipe.ts","../src/filter.ts","../src/history.ts","../src/context/base.ts","../src/context/server.ts","../src/types.ts","../src/utils.ts","../src/helper.ts","../src/common.ts","../src/server/express.ts","../src/core.ts","../src/meta.ts","../src/compiler/rpc.ts","../src/compiler/http.ts","../src/decorators/index.ts","../src/decorators/param.ts","../src/decorators/route.ts","../src/decorators/aop.ts","../src/modules/dev.ts","../src/modules/guard.ts","../src/modules/interceptor.ts","../src/modules/pipe.ts","../src/modules/filter.ts"],"sourcesContent":["export * from './context'\nexport * from './types'\nexport * from './server/express'\nexport * from './core'\nexport * from './decorators'\nexport * from './exception'\nexport * from './pipe'\nexport * from './meta'\nexport * from 'phecda-core'\nexport * from './helper'\nexport * from './common'\nexport * from './modules'\nexport * from './compiler'\n","export class Exception extends Error {\n constructor(public message: string, public status: number, public description = 'Http exception') {\n super(message)\n }\n\n get data() {\n return { message: this.message, description: this.description, status: this.status, error: true }\n }\n}\n","import { Exception } from './base'\n\nexport class UndefinedException extends Exception {\n constructor(message: string) {\n super(message, 500, 'Undefined error')\n }\n}\n","import { Exception } from './base'\n\nexport class ValidateException extends Exception {\n constructor(message: string) {\n super(message, 400, 'Validate exception')\n }\n}\n","import { Exception } from './base'\n\nexport class ForbiddenException extends Exception {\n constructor(message: string) {\n super(message, 403, 'Forbidden resource')\n }\n}\n","import { Exception } from './base'\n\nexport class BadRequestException extends Exception {\n constructor(message: string) {\n super(message, 400, 'Bad Request')\n }\n}\n","import { Exception } from './base'\n\nexport class NotFoundException extends Exception {\n constructor(message: string) {\n super(message, 404, 'Not Found')\n }\n}\n","import { Exception } from './base'\n\nexport class ConflictException extends Exception {\n constructor(message: string) {\n super(message, 409, 'Conflict')\n }\n}\n","import { Exception } from './base'\n\nexport class BadGatewayException extends Exception {\n constructor(message: string) {\n super(message, 502, 'Bad Gatrway')\n }\n}\n","import { Exception } from './base'\n\nexport class InvalidInputException extends Exception {\n constructor(message: string) {\n super(message, 502, 'Invalid Input')\n }\n}\n","import { Exception } from './base'\n\nexport class UnsupportedMediaTypeException extends Exception {\n constructor(message: string) {\n super(message, 415, 'Unsupported Media Type')\n }\n}\n","import { Exception } from './base'\n\nexport class PayloadLargeException extends Exception {\n constructor(message: string) {\n super(message, 413, 'Payload Too Large')\n }\n}\n","import { Exception } from './base'\n\nexport class TimeoutException extends Exception {\n constructor(message: string) {\n super(message, 408, 'Request Timeout',\n )\n }\n}\n","import { Exception } from './base'\n\nexport class UnauthorizedException extends Exception {\n constructor(message: string) {\n super(message, 401, 'Unauthorized')\n }\n}\n","import { Exception } from './base'\n\nexport class ServiceUnavailableException extends Exception {\n constructor(message: string) {\n super(message, 503, 'Service Unavailable')\n }\n}\n","import { Exception } from './base'\n\nexport class FrameworkException extends Exception {\n constructor(message: string) {\n super(`[phecda-server] ${message}`, 500, 'Framework Error')\n }\n}\n","import { isPhecda, plainToClass } from 'phecda-core'\nimport { ValidateException } from './exception/validate'\n\nimport type { P } from './types'\n\nexport const defaultPipe: P.Pipe = async (args: any[]) => {\n for (const i in args) {\n const { option, arg, reflect } = args[i]\n if (option === false)\n continue\n if (!reflect) {\n if (option && arg)\n args[i].arg = option(arg)\n\n continue\n }\n\n if (isPhecda(reflect)) {\n const ret = await plainToClass(reflect, arg, { transform: true })\n if (ret.err.length > 0)\n throw new ValidateException(ret.err[0])\n args[i].arg = ret.data\n }\n else {\n if ([Number, Boolean].includes(reflect)) {\n args[i].arg = reflect(arg)\n\n if (reflect === Number && Object.is(args[i].arg, NaN))\n throw new ValidateException(`parameter ${Number(i) + 1} should be a number`)\n }\n }\n }\n return args.map(item => item.arg)\n}\n","import { Exception, UndefinedException } from './exception'\nimport type { P } from './types'\n\nexport const defaultFilter: P.Filter = (e: any) => {\n if (!(e instanceof Exception)) {\n console.error(e.stack)\n e = new UndefinedException(e.message || e)\n }\n else {\n console.error(e.message)\n }\n\n return e.data\n}\n","export class Histroy {\n guard: string[] = []\n interceptor: string[] = []\n record(name: string, type: 'guard' | 'interceptor') {\n if (!this[type].includes(name)) {\n this[type].push(name)\n return true\n }\n return false\n }\n}\n","import { ForbiddenException, FrameworkException } from '../exception'\nimport { Histroy } from '../history'\nimport type { P } from '../types'\n\nexport abstract class BaseContext<Data = any> {\n method: string\n params: string[]\n history = new Histroy()\n abstract singletonConf: {\n filter: P.Filter\n pipe: P.Pipe\n }\n\n abstract guardsRecord: Record<string, P.Guard>\n abstract interceptorsRecord: Record<string, P.Interceptor>\n postInterceptors: Function[]\n\n constructor(public tag: string, public data: Data) {\n if (process.env.NODE_ENV === 'development')\n // @ts-expect-error work for debug\n data._context = this\n }\n\n usePipe(args: { arg: any; option?: any; type: string; key: string; index: number; reflect: any }[]) {\n return this.singletonConf.pipe(args, this.tag, this.data)\n }\n\n useFilter(arg: any) {\n return this.singletonConf.filter(arg, this.tag, this.data)\n }\n\n async useGuard(guards: string[]) {\n for (const guard of guards) {\n if (this.history.record(guard, 'guard')) {\n if (!(guard in this.guardsRecord)) {\n if (process.env.PS_STRICT)\n throw new FrameworkException(`can't find guard named '${guard}'`)\n continue\n }\n if (!await this.guardsRecord[guard](this.tag, this.data))\n throw new ForbiddenException(`Guard exception--${guard}`)\n }\n }\n }\n\n async usePostInterceptor(ret: any) {\n for (const cb of this.postInterceptors)\n ret = await cb(ret) || ret\n\n return ret\n }\n\n async useInterceptor(interceptors: string[]) {\n const ret = []\n for (const interceptor of interceptors) {\n if (this.history.record(interceptor, 'interceptor')) {\n if (!(interceptor in this.interceptorsRecord)) {\n if (process.env.PS_STRICT)\n throw new FrameworkException(`can't find interceptor named '${interceptor}'`)\n\n continue\n }\n const postInterceptor = await this.interceptorsRecord[interceptor](this.tag, this.data)\n if (postInterceptor !== undefined) {\n if (typeof postInterceptor === 'function')\n ret.push(postInterceptor)\n\n else\n return true\n }\n }\n }\n this.postInterceptors = ret\n }\n}\n","import type { RequestHandler } from 'express'\nimport { FrameworkException } from '../exception'\nimport { defaultPipe } from '../pipe'\nimport { defaultFilter } from '../filter'\nimport type { P, ServerCtx, ServerErr } from '../types'\n\nimport { BaseContext } from './base'\n\nexport const guardsRecord = {} as Record<string, P.Guard<ServerCtx>>\n\nexport const interceptorsRecord = {} as Record<string, P.Interceptor<ServerCtx>>\n\nexport const middlewareRecord = {} as Record<string, (...params: any) => any>\n\nexport const singletonConf = {\n pipe: defaultPipe,\n filter: defaultFilter,\n}\nexport class Context extends BaseContext<ServerCtx> {\n singletonConf = singletonConf\n // static metaRecord: Record<string, Meta> = {}\n // static metaDataRecord: Record<string, ReturnType<typeof parseMeta>> = {}\n\n static middlewareRecord = middlewareRecord\n guardsRecord = guardsRecord\n interceptorsRecord = interceptorsRecord\n\n postInterceptors: Function[]\n\n static useMiddleware(middlewares: string[]) {\n const ret = []\n for (const m of middlewares) {\n if (!(m in Context.middlewareRecord)) {\n if (process.env.PS_STRICT)\n throw new FrameworkException(`can't find middleware named '${m}'`)\n\n continue\n }\n ret.push(Context.middlewareRecord[m])\n }\n return ret\n }\n}\n\nexport function addMiddleware(key: string, handler: RequestHandler) {\n middlewareRecord[key] = handler\n}\n\nexport function setPipe(pipe: P.Pipe<ServerCtx>) {\n singletonConf.pipe = pipe\n}\n\nexport function setFilter(filter: P.Filter<ServerCtx, ServerErr>) {\n singletonConf.filter = filter\n}\n\nexport function addGuard(key: string, handler: P.Guard<ServerCtx>) {\n guardsRecord[key] = handler\n}\n\nexport function addInterceptor(key: string, handler: P.Interceptor<ServerCtx>) {\n interceptorsRecord[key] = handler\n}\n","import type { Request, Response } from 'express'\nimport type { Events } from 'phecda-core'\nimport type { Meta } from './meta'\nimport type { Exception } from './exception'\nexport type Construct<T = any> = new (...args: any[]) => T\n\nexport interface Emitter {\n on<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n once<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n off<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n removeAllListeners<N extends keyof Events>(eventName: N): void\n emit<N extends keyof Events>(eventName: N, param: Events[N]): void\n}\n\nexport type ToInstance<T = any> = {\n [K in keyof T]: T[K] extends (new (...args: any) => any) ? InstanceType<T[K]> : void\n}\n\nexport type RequestType = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head'\n\nexport type MergeType = <R extends Promise<any>[]> (...args: R) => { [K in keyof R]: Awaited<R[K]> }\n\n// export interface ServerMergeCtx {\n// request: Request\n// response: Response\n// meta: Record<string, Meta>\n// moduleMap: Record<string, any>\n// isMerge: true\n// tags?: string[]\n// }\n\nexport interface ServerCtx {\n type: string\n request: Request\n response: Response\n meta: Meta\n moduleMap: Record<string, any>\n}\n\nexport interface ServerErr { message: string; description: string; status: number; error: boolean }\n\nexport interface BaseError {\n error: true\n status: number\n}\n\nexport class ServerBase {\n context: ServerCtx\n}\n\nexport namespace P {\n export interface Error extends BaseError { message: string; description: string }\n\n export type ResOrErr<R> = { [K in keyof R]: Awaited<R[K]> | Error }\n\n export type Res<T> = T\n export type Guard<C = any> = ((tag: string, ctx: C) => Promise<boolean> | boolean)\n\n export type Interceptor<C = any> = (tag: string, ctx: C) =>(any | ((ret: any) => any))\n\n export type Pipe<C = any> = (args: { arg: any; option?: any; key: string; type: string; index: number; reflect: any }[], tag: string, ctx: C) => Promise<any[]>\n export type Filter<C = any, R = any, E extends Exception = any > = (err: E | Error, tag?: string, ctx?: C) => R | Promise<R>\n\n export interface Handler {\n error?: (arg: any) => void\n }\n export interface Meta {\n http?: {\n type: RequestType\n route: string\n }\n rpc?: string[]\n define?: any\n header: Record<string, string>\n params: { type: string; index: number; key: string; option?: any }[]\n guards: string[]\n interceptors: string[]\n middlewares: string[]\n method: string\n name: string\n tag: string\n }\n\n}\n","import pc from 'picocolors'\nimport type { Meta } from './meta'\nexport const isUndefined = (obj: any): obj is undefined =>\n typeof obj === 'undefined'\nexport const isNil = (obj: any): obj is null | undefined =>\n isUndefined(obj) || obj === null\n\nexport const isObject = (fn: any): fn is object =>\n !isNil(fn) && typeof fn === 'object'\n\nexport function warn(msg: string, color = 'yellow') {\n // @ts-expect-error pc\n console.warn(`${pc.magenta('[phecda-server]')} ${pc[color](msg)}`)\n}\n","export function resolveDep(ret: any, key: string) {\n if (key)\n return ret?.[key]\n return ret\n}\n","export const SERIES_SYMBOL = '__PS_SERIES__'\nexport const MERGE_SYMBOL = '__PS_MERGE__'\nexport const UNMOUNT_SYMBOL = '__PS_UNMOUNT__'\nexport const MODULE_SYMBOL = '__PS_MODULE__'\nexport const META_SYMBOL = '__PS_META__'\nexport const APP_SYMBOL = '__PS__'\n","import type { Express, Router } from 'express'\nimport { Context, singletonConf } from '../context'\nimport { isObject } from '../utils'\nimport { resolveDep } from '../helper'\nimport { APP_SYMBOL, MERGE_SYMBOL, META_SYMBOL, MODULE_SYMBOL, SERIES_SYMBOL } from '../common'\nimport type { Factory } from '../core'\nimport { BadRequestException, FrameworkException } from '../exception'\nimport type { Meta } from '../meta'\n\nexport interface Options {\n\n /**\n * 专用路由的值,默认为/__PHECDA_SERVER__,处理phecda-client发出的合并请求\n */\n route?: string\n /**\n * 全局守卫\n */\n globalGuards?: string[]\n /**\n * 全局拦截器\n */\n globalInterceptors?: string[]\n /**\n * 专用路由的中间件(work for merge request),全局中间件请在bindApp以外设置\n */\n middlewares?: string[]\n\n /**\n * allow parallel request,default is true\n */\n parallel?: boolean\n\n /**\n * allow series request,default is true\n */\n series?: boolean\n}\n\nexport function bindApp(app: Router, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, options: Options = {}) {\n const { globalGuards, globalInterceptors, route, middlewares: proMiddle, parallel = true, series = true } = { route: '/__PHECDA_SERVER__', globalGuards: [], globalInterceptors: [], middlewares: [], ...options } as Required<Options>\n (app as any)[APP_SYMBOL] = { moduleMap, meta }\n\n const metaMap = new Map<string, Meta>()\n function handleMeta() {\n metaMap.clear()\n for (const item of meta) {\n const { tag, method, http } = item.data\n if (!http?.type)\n continue\n const methodTag = `${tag}-${method}`\n metaMap.set(methodTag, item)\n }\n }\n\n async function createRoute() {\n (app as Express).post(route, (req, _res, next) => {\n (req as any)[MERGE_SYMBOL] = true;\n (req as any)[MODULE_SYMBOL] = moduleMap;\n (req as any)[META_SYMBOL] = meta\n\n next()\n }, ...Context.useMiddleware(proMiddle), async (req, res) => {\n const { body: { category, data } } = req\n\n async function errorHandler(e: any) {\n const error = await singletonConf.filter(e)\n return res.status(error.status).json(error)\n }\n\n if (!Array.isArray(data))\n return errorHandler(new BadRequestException('data format should be an array'))\n\n if (category !== 'series' && category !== 'parallel')\n return errorHandler(new BadRequestException('category should be \\'parallel\\' or \\'series\\''))\n\n const ret = [] as any[]\n try {\n if (category === 'series') {\n if (!series)\n return errorHandler(new FrameworkException('series request is not allowed'))\n\n for (const item of data) {\n const { tag } = item\n const contextData = {\n type: 'express',\n request: req,\n meta: metaMap.get(tag)!,\n response: res,\n moduleMap,\n\n }\n const context = new Context(tag, contextData)\n try {\n const [name, method] = tag.split('-')\n const {\n reflect,\n data: {\n params,\n guards,\n interceptors,\n },\n } = contextData.meta\n const instance = moduleMap.get(name)\n if (!params)\n throw new BadRequestException(`\"${tag}\" doesn't exist`)\n\n await context.useGuard([...globalGuards, ...guards])\n if (await context.useInterceptor([...globalInterceptors, ...interceptors])\n ) return\n const args = await context.usePipe(params.map(({ type, key, option, index }) => {\n const arg = resolveDep(item[type], key)\n if (typeof arg === 'string' && arg.startsWith(SERIES_SYMBOL)) {\n const [, argIndex, argKey] = arg.split('@')\n return { arg: resolveDep(ret[Number(argIndex)], argKey || key), option, index, type, key, reflect: reflect[index] }\n }\n\n return { arg, option, index, type, key, reflect: reflect[index] }\n })) as any\n instance.context = contextData\n const funcData = await moduleMap.get(name)[method](...args)\n\n ret.push(await context.usePostInterceptor(funcData))\n }\n catch (e: any) {\n const m = metaMap.get(tag)!\n m.handlers.forEach(handler => handler.error?.(e))\n ret.push(await context.useFilter(e))\n }\n }\n\n return res.json(ret)\n }\n if (category === 'parallel') {\n if (!parallel)\n return errorHandler(new FrameworkException('parallel request is not allowed'))\n\n return Promise.all(data.map((item: any) => {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve) => {\n const { tag } = item\n const contextData = {\n type: 'express',\n\n request: req,\n meta: metaMap.get(tag)!,\n response: res,\n moduleMap,\n }\n const context = new Context(tag, contextData)\n const [name, method] = tag.split('-')\n const {\n reflect,\n\n handlers,\n\n data: {\n params,\n guards, interceptors,\n },\n } = metaMap.get(tag)!\n\n const instance = moduleMap.get(name)\n\n try {\n if (!params)\n throw new BadRequestException(`\"${tag}\" doesn't exist`)\n await context.useGuard([...globalGuards, ...guards])\n if (await context.useInterceptor([...globalInterceptors, ...interceptors])\n ) return\n const args = await context.usePipe(params.map(({ type, key, option, index }) => {\n const arg = resolveDep(item[type], key)\n return { arg, type, key, option, index, reflect: reflect[index] }\n })) as any\n instance.context = contextData\n const funcData = await moduleMap.get(name)[method](...args)\n resolve(await context.usePostInterceptor(funcData))\n }\n catch (e: any) {\n handlers.forEach(handler => handler.error?.(e))\n resolve(await context.useFilter(e))\n }\n })\n })).then((ret) => {\n res.json(ret)\n })\n }\n }\n catch (e) {\n return errorHandler(e)\n }\n })\n for (const i of meta) {\n const { method, http, header, tag } = i.data\n\n if (!http?.type)\n continue\n\n const methodTag = `${tag}-${method}`\n\n const {\n reflect,\n handlers,\n data: {\n interceptors,\n guards,\n params,\n middlewares,\n },\n } = metaMap.get(methodTag)!;\n\n (app as Express)[http.type](http.route, (req, _res, next) => {\n (req as any)[MODULE_SYMBOL] = moduleMap;\n (req as any)[META_SYMBOL] = meta\n next()\n }, ...Context.useMiddleware(middlewares), async (req, res) => {\n const instance = moduleMap.get(tag)!\n const contextData = {\n type: 'express',\n request: req,\n meta: i,\n response: res,\n moduleMap,\n }\n const context = new Context(methodTag, contextData)\n\n try {\n for (const name in header)\n res.set(name, header[name])\n await context.useGuard([...globalGuards, ...guards])\n if (await context.useInterceptor([...globalInterceptors, ...interceptors]))\n return\n\n const args = await context.usePipe(params.map(({ type, key, option, index }) => {\n return { arg: resolveDep((req as any)[type], key), option, key, type, index, reflect: reflect[index] }\n }))\n\n instance.context = contextData\n const funcData = await instance[method](...args)\n const ret = await context.usePostInterceptor(funcData)\n\n if (isObject(ret))\n res.json(ret)\n else\n res.send(String(ret))\n }\n catch (e: any) {\n handlers.forEach(handler => handler.error?.(e))\n const err = await context.useFilter(e)\n res.status(err.status).json(err)\n }\n })\n }\n }\n\n handleMeta()\n createRoute()\n if (process.env.NODE_ENV === 'development') {\n // @ts-expect-error globalThis\n const rawMetaHmr = globalThis.__PS_WRITEMETA__\n // @ts-expect-error globalThis\n\n globalThis.__PS_WRITEMETA__ = () => {\n app.stack = []// app.stack.slice(0, 1)\n handleMeta()\n\n createRoute()\n rawMetaHmr?.()\n }\n }\n}\n","import 'reflect-metadata'\nimport fs from 'fs'\nimport EventEmitter from 'node:events'\nimport type { Phecda } from 'phecda-core'\nimport { getExposeKey, getHandler, getState, injectProperty, isPhecda, registerAsync } from 'phecda-core'\nimport Debug from 'debug'\nimport type { Construct, Emitter, P } from './types'\nimport { Meta } from './meta'\nimport { warn } from './utils'\nimport { UNMOUNT_SYMBOL } from './common'\nimport { generateHTTPCode, generateRPCCode } from './compiler'\n\nconst debug = Debug('phecda-server')\n// TODO: support both emitter types and origin emitter type in future\nexport const emitter: Emitter = new EventEmitter() as any\n\nexport async function Factory(Modules: (new (...args: any) => any)[], opts: {\n\n // HTTP generate code path\n http?: string\n // rpc generate code path\n rpc?: string\n} = {}) {\n const moduleMap = new Map<string, InstanceType<Construct>>()\n const meta: Meta[] = []\n const constructorMap = new Map()\n\n // only work for warn\n const constructorSet = new WeakSet()\n const moduleGraph = new Map<string, Set<string>>()\n const { http, rpc } = opts\n injectProperty('watcher', ({ eventName, instance, key, options }: { eventName: string; instance: any; key: string; options?: { once: boolean } }) => {\n const fn = typeof instance[key] === 'function' ? instance[key].bind(instance) : (v: any) => instance[key] = v\n\n if (options?.once)\n (emitter as any).once(eventName, fn)\n\n else\n (emitter as any).on(eventName, fn)\n })\n\n async function update(Module: Construct) {\n const tag = Module.prototype?.__TAG__ || Module.name\n if (!moduleMap.has(tag))\n return\n debug(`update module \"${tag}\"`)\n\n const instance = moduleMap.get(tag)\n\n if (instance?.[UNMOUNT_SYMBOL]) {\n for (const cb of instance[UNMOUNT_SYMBOL])\n await cb()\n }\n moduleMap.delete(tag)\n constructorMap.delete(tag)\n for (let i = meta.length - 1; i >= 0; i--) {\n if (meta[i].data.tag === tag)\n meta.splice(i, 1)\n }\n\n const { instance: newModule } = await buildNestModule(Module)\n if (moduleGraph.has(tag)) {\n [...moduleGraph.get(tag)!].forEach((tag) => {\n const module = moduleMap.get(tag)\n for (const key in module) {\n if (module[key] === instance)\n module[key] = newModule\n }\n })\n }\n\n moduleMap.set(tag, newModule)\n }\n async function buildNestModule(Module: Construct) {\n const paramtypes = getParamtypes(Module) as Construct[]\n let instance: InstanceType<Construct>\n const tag = Module.prototype?.__TAG__ || Module.name\n if (moduleMap.has(tag)) {\n instance = moduleMap.get(tag)\n if (!instance)\n throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${tag}--[module] ${Module}`)\n\n if (constructorMap.get(tag) !== Module && !constructorSet.has(Module)) {\n constructorSet.add(Module)// a module will only warn once\n warn(`Synonym module: Module taged \"${tag}\" has been loaded before, so phecda-server won't load Module \"${Module.name}\"`)\n }\n return { instance, tag }\n }\n moduleMap.set(tag, undefined)\n if (paramtypes) {\n const paramtypesInstances = [] as any[]\n for (const i in paramtypes) {\n const { instance: sub, tag: subTag } = await buildNestModule(paramtypes[i])\n paramtypesInstances[i] = sub\n if (!moduleGraph.has(subTag))\n moduleGraph.set(subTag, new Set())\n moduleGraph.get(subTag)!.add(tag)\n }\n instance = new Module(...paramtypesInstances)\n }\n else {\n instance = new Module()\n }\n meta.push(...getMetaFromInstance(instance, tag, Module.name))\n await registerAsync(instance)\n moduleMap.set(tag, instance)\n constructorMap.set(tag, Module)\n return { instance, tag }\n }\n\n for (const Module of Modules)\n await buildNestModule(Module)\n\n function writeMeta() {\n debug('write metadata')\n\n http && fs.promises.writeFile(http, generateHTTPCode(meta.map(item => item.data)))\n rpc && fs.promises.writeFile(rpc, generateRPCCode(meta.map(item => item.data)))\n }\n\n writeMeta()\n if (process.env.NODE_ENV === 'development') {\n // @ts-expect-error globalThis\n globalThis.__PS_HMR__ = async (file: string) => {\n debug(`reload file ${file}`)\n const module = await import(file)\n for (const i in module) {\n if (isPhecda(module[i]))\n await update(module[i])\n }\n }\n // @ts-expect-error globalThis\n globalThis.__PS_WRITEMETA__ = writeMeta\n }\n\n return {\n moduleMap,\n meta,\n constructorMap,\n update,\n }\n}\n\nfunction getMetaFromInstance(instance: Phecda, tag: string, name: string) {\n const vars = getExposeKey(instance).filter(item => item !== '__CLASS')\n const baseState = (getState(instance, '__CLASS') || {}) as P.Meta\n initState(baseState)\n\n return vars.map((i) => {\n const meta = {} as P.Meta\n const state = (getState(instance, i) || {}) as P.Meta\n initState(state)\n if (state.http) {\n meta.http = {\n route: (baseState.http?.route || '') + (state.http.route),\n type: state.http.type,\n }\n }\n if (state.rpc)\n meta.rpc = state.rpc\n\n meta.name = name\n meta.tag = tag\n meta.method = i as string\n const params = [] as any[]\n for (const i of state.params || []) {\n params.unshift(i)\n if (i.index === 0)\n break\n }\n\n meta.params = params\n meta.define = { ...baseState.define, ...state.define }\n meta.header = { ...baseState.header, ...state.header }\n meta.middlewares = [...new Set([...baseState.middlewares, ...state.middlewares])]\n meta.guards = [...new Set([...baseState.guards, ...state.guards])]\n meta.interceptors = [...new Set([...baseState.interceptors, ...state.interceptors])]\n\n return new Meta(meta as unknown as P.Meta, getHandler(instance, i), getParamtypes(instance, i as string) || [])\n })\n}\n\nfunction getParamtypes(Module: any, key?: string | symbol) {\n return Reflect.getMetadata('design:paramtypes', Module, key!)\n}\n\nfunction initState(state: any) {\n if (!state.define)\n state.define = {}\n if (!state.header)\n state.header = {}\n if (!state.middlewares)\n state.middlewares = []\n if (!state.guards)\n state.guards = []\n if (!state.interceptors)\n state.interceptors = []\n}\n","import type { P } from './types'\n\nexport class Meta {\n constructor(public data: P.Meta, public handlers: P.Handler[], public reflect: any[]) {\n\n }\n}\n","import type { P } from '../types'\n\nclass Compiler {\n classMap: Record<string, { [key: string]: string }> = {}\n constructor() { }\n\n getContent() {\n let content = ''\n\n for (const name in this.classMap) {\n content += `\n export class ${name}{\n ${Object.values(this.classMap[name]).reduce((p, c) => p + c)}\n }`\n }\n return content\n }\n\n // createRequest() {\n // let content = 'import {useC} from \\'phecda-server\\'\\n'\n // for (const name in this.classMap)\n // content += `export const {${Object.keys(this.classMap[name]).join(',')}}=useC(${name})\\n`\n // return content\n // }\n\n addMethod(args: P.Meta) {\n const {\n rpc, name, method, tag,\n } = args\n if (!rpc)\n return\n if (!this.classMap[name])\n this.classMap[name] = {}\n this.classMap[name][method] = `\n ${method}(){\n return {tag:'${tag}-${method}',rpc:[${rpc.reduce((p, c) => {\n return `${p}\"${c}\",`\n }, '')}]}\n\n }\n `\n }\n}\n\nexport function generateRPCCode(meta: P.Meta[]) {\n const compiler = new Compiler()\n\n for (const i of meta)\n compiler.addMethod(i)\n return compiler.getContent()\n}\n","import type { P } from '../types'\n\nclass Compiler {\n classMap: Record<string, { [key: string]: string }> = {}\n constructor() { }\n\n getContent() {\n let content = ''\n\n for (const name in this.classMap) {\n content += `\n export class ${name}{\n ${Object.values(this.classMap[name]).reduce((p, c) => p + c)}\n }`\n }\n return content\n }\n\n // createRequest() {\n // let content = 'import {useC} from \\'phecda-server\\'\\n'\n // for (const name in this.classMap)\n // content += `export const {${Object.keys(this.classMap[name]).join(',')}}=useC(${name})\\n`\n // return content\n // }\n\n addMethod(args: P.Meta) {\n const {\n http, name, method, params, tag,\n } = args\n if (!http)\n return\n const url = http.route.replace(/\\/\\:([^\\/]*)/g, (_, js) => `/{{${js}}}`)\n if (!this.classMap[name])\n this.classMap[name] = {}\n this.classMap[name][method] = `\n ${method}(${genParams(params)}){\nconst ret={tag:\"${tag}-${method}\",body:{},headers:{},query:{},params:{},method:\"${http.type}\",url:\"${url}\"}\n${params.reduce((p, c, i) => `${p}if(arg${i}!==undefined&&arg${i}!==null){ret.${c.type}${c.key ? `['${c.key}']` : ''}=arg${i}\\n${c.type === 'params' ? `ret.url=ret.url.replace('{{${c.key}}}',arg${i})}` : '}'}\\n`, '')}\nreturn ret\n }\n `\n }\n}\n\nfunction genParams(decorators: any[]) {\n return decorators.map((_, i) => {\n return `${`arg${i}`}`\n }).join(',')\n}\n\nexport function generateHTTPCode(meta: P.Meta[]) {\n const compiler = new Compiler()\n\n for (const i of meta)\n compiler.addMethod(i)\n return compiler.getContent()\n}\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function Header(name: string, value: string) {\n return (target: any, k: PropertyKey) => {\n setModelVar(target, k)\n const state = target._namespace.__STATE_NAMESPACE__.get(k) || {}\n if (!state.header)\n state.header = {}\n\n state.header[name] = value\n setState(target, k, state)\n }\n}\n\nexport function Define(key: string, value: any) {\n return (target: any, k?: PropertyKey) => {\n if (!k) {\n k = '__CLASS'\n target = target.prototype\n }\n\n setModelVar(target, k)\n const state = target._namespace.__STATE_NAMESPACE__.get(k) || {}\n if (!state.define)\n state.define = {}\n\n state.define[key] = value\n setState(target, k, state)\n }\n}\n\nexport * from './param'\nexport * from './route'\nexport * from './aop'\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function BaseParam(type: string, key: string, option?: any): any {\n return (target: any, k: PropertyKey, index: number) => {\n setModelVar(target, k)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(k) || {}\n if (!state.params)\n state.params = []\n\n state.params.push({ type, key, index, option })\n setState(target, k, state)\n }\n}\n\nexport function Body(key = '', pipeOpts?: any) {\n return BaseParam('body', key, pipeOpts)\n}\n// req.headers\nexport function Head(key: string, pipeOpts?: any) {\n return BaseParam('headers', key.toLowerCase(), pipeOpts)\n}\n\nexport function Query(key = '', pipeOpts?: any) {\n return BaseParam('query', key, pipeOpts)\n}\nexport function Param(key: string, pipeOpts?: any) {\n return BaseParam('params', key, pipeOpts)\n}\n\n// work for micro service\nexport function Arg(pipeOpts?: any) {\n return BaseParam('params', '', pipeOpts)\n}\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function Route(route: string, type?: string): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n state.http = {\n route,\n type,\n }\n setState(target, key, state)\n }\n}\n\nexport function Get(route: string) {\n return Route(route, 'get')\n}\n\nexport function Post(route: string) {\n return Route(route, 'post')\n}\nexport function Put(route: string) {\n return Route(route, 'put')\n}\n\nexport function Patch(route: string) {\n return Route(route, 'patch')\n}\nexport function Delete(route: string) {\n return Route(route, 'delete')\n}\n\nexport function Controller(route: string) {\n return Route(route)\n}\n\nexport function Rpc(...rpc: ('mq'|'redis'|string)[]) {\n return (target: any, key: PropertyKey) => {\n setModelVar(target, key)\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n state.rpc = rpc\n\n setState(target, key, state)\n }\n}\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function Guard(...guards: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n if (!state.guards)\n state.guards = []\n state.guards.push(...guards)\n setState(target, key, state)\n }\n}\n\nexport function Middle(...middlewares: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n if (!state.middlewares)\n state.middlewares = []\n state.middlewares.push(...middlewares)\n setState(target, key, state)\n }\n}\n\nexport function Interceptor(...interceptors: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n if (!state.interceptors)\n state.interceptors = []\n state.interceptors.push(...interceptors)\n setState(target, key, state)\n }\n}\n","import { UNMOUNT_SYMBOL } from '../common'\n\nexport class Dev {\n [UNMOUNT_SYMBOL]: (() => void)[] = []\n onUnmount(cb: () => void) {\n this[UNMOUNT_SYMBOL].push(cb)\n }\n}\n","import { addGuard } from '../context'\nimport type { ServerCtx } from '../types'\n\nexport abstract class ServerGuard {\n abstract use(tag: string, ctx: ServerCtx): Promise<boolean> | boolean\n\n constructor(tag: string) {\n addGuard(tag, this.use.bind(this))\n }\n}\n","import { addInterceptor } from '../context'\nimport type { ServerCtx } from '../types'\n\nexport abstract class ServerInterceptor {\n abstract use(tag: string, ctx: ServerCtx): ((arg: any) => any) | void\n\n constructor(tag: string) {\n addInterceptor(tag, this.use.bind(this))\n }\n}\n","import { setPipe } from '../context'\nimport type { ServerCtx } from '../types'\n\nexport abstract class ServerPipe {\n constructor() {\n setPipe(this.use.bind(this))\n }\n\n abstract use(args: { arg: any; option?: any; key: string; type: string; index: number; reflect: any }[], tag: string, ctx: ServerCtx): Promise<any[]>\n}\n","import { setFilter } from '../context'\nimport type { Exception } from '../exception'\nimport type { ServerCtx, ServerErr } from '../types'\n\nexport abstract class ServerFilter {\n constructor() {\n setFilter(this.use.bind(this))\n }\n\n abstract use< E extends Exception >(error: Error | E, tag?: string, ctx?: ServerCtx): ServerErr | Promise<ServerErr>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAO,IAAMA,YAAN,cAAwBC,MAAAA;EACVC;EAAwBC;EAAuBC;EAAlEC,YAAmBH,SAAwBC,QAAuBC,cAAc,kBAAkB;AAChG,UAAMF,OAAAA;mBADWA;kBAAwBC;uBAAuBC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AMI,MAAN,MAAMA;EACX,CAACC,kBAAkC,CAAA;EACnCC,UAAUC,IAAgB;AACxB,SAAKF,gBAAgBG,KAAKD,EAAAA;EAC5B;AACF;AALaH;;;ACCN,IAAeK,cAAf,MAAeA;EAGpBC,YAAYC,KAAa;AACvBC,aAASD,KAAK,KAAKE,IAAIC,KAAK,IAAI,CAAA;EAClC;AACF;AANsBL;;;ACAf,IAAeM,oBAAf,MAAeA;EAGpBC,YAAYC,KAAa;AACvBC,mBAAeD,KAAK,KAAKE,IAAIC,KAAK,IAAI,CAAA;EACxC;AACF;AANsBL;;;ACAf,IAAeM,aAAf,MAAeA;EACpBC,cAAc;AACZC,YAAQ,KAAKC,IAAIC,KAAK,IAAI,CAAA;EAC5B;AAGF;AANsBJ;;;ACCf,IAAeK,eAAf,MAAeA;EACpBC,cAAc;AACZC,cAAU,KAAKC,IAAIC,KAAK,IAAI,CAAA;EAC9B;AAGF;AANsBJ;","names":["Exception","Error","message","status","description","constructor","data","error","UndefinedException","Exception","constructor","message","ValidateException","Exception","constructor","message","ForbiddenException","Exception","constructor","message","BadRequestException","Exception","constructor","message","NotFoundException","Exception","constructor","message","ConflictException","Exception","constructor","message","BadGatewayException","Exception","constructor","message","InvalidInputException","Exception","constructor","message","UnsupportedMediaTypeException","Exception","constructor","message","PayloadLargeException","Exception","constructor","message","TimeoutException","Exception","constructor","message","UnauthorizedException","Exception","constructor","message","ServiceUnavailableException","Exception","constructor","message","FrameworkException","Exception","constructor","message","defaultPipe","args","i","option","arg","reflect","isPhecda","ret","plainToClass","transform","err","length","ValidateException","data","Number","Boolean","includes","Object","is","NaN","map","item","defaultFilter","e","Exception","console","error","stack","UndefinedException","message","data","Histroy","guard","interceptor","record","name","type","includes","push","BaseContext","tag","data","method","params","history","postInterceptors","constructor","Histroy","process","env","NODE_ENV","_context","usePipe","args","singletonConf","pipe","useFilter","arg","filter","useGuard","guards","guard","record","guardsRecord","PS_STRICT","FrameworkException","ForbiddenException","usePostInterceptor","ret","cb","useInterceptor","interceptors","interceptor","interceptorsRecord","postInterceptor","undefined","push","guardsRecord","interceptorsRecord","middlewareRecord","singletonConf","pipe","defaultPipe","filter","defaultFilter","Context","BaseContext","postInterceptors","useMiddleware","middlewares","ret","m","process","env","PS_STRICT","FrameworkException","push","addMiddleware","key","handler","setPipe","setFilter","addGuard","addInterceptor","ServerBase","context","isUndefined","obj","isNil","isObject","fn","warn","msg","color","console","pc","magenta","resolveDep","ret","key","SERIES_SYMBOL","MERGE_SYMBOL","UNMOUNT_SYMBOL","MODULE_SYMBOL","META_SYMBOL","APP_SYMBOL","bindApp","app","moduleMap","meta","options","globalGuards","globalInterceptors","route","middlewares","proMiddle","parallel","series","APP_SYMBOL","metaMap","Map","handleMeta","clear","item","tag","method","http","data","type","methodTag","set","createRoute","post","req","_res","next","MERGE_SYMBOL","MODULE_SYMBOL","META_SYMBOL","Context","useMiddleware","res","body","category","errorHandler","e","error","singletonConf","filter","status","json","Array","isArray","BadRequestException","ret","FrameworkException","contextData","request","get","response","context","name","split","reflect","params","guards","interceptors","instance","useGuard","useInterceptor","args","usePipe","map","key","option","index","arg","resolveDep","startsWith","SERIES_SYMBOL","argIndex","argKey","Number","funcData","push","usePostInterceptor","m","handlers","forEach","handler","useFilter","Promise","all","resolve","then","i","header","isObject","send","String","err","process","env","NODE_ENV","rawMetaHmr","globalThis","__PS_WRITEMETA__","stack","import_phecda_core","Meta","data","handlers","reflect","constructor","Compiler","classMap","constructor","getContent","content","name","Object","values","reduce","p","c","addMethod","args","rpc","method","tag","generateRPCCode","meta","compiler","i","Compiler","classMap","constructor","getContent","content","name","Object","values","reduce","p","c","addMethod","args","http","method","params","tag","url","route","replace","_","js","genParams","type","i","key","decorators","map","join","generateHTTPCode","meta","compiler","debug","Debug","emitter","EventEmitter","Factory","Modules","opts","moduleMap","Map","meta","constructorMap","constructorSet","WeakSet","moduleGraph","http","rpc","injectProperty","eventName","instance","key","options","fn","bind","v","once","on","update","Module","tag","prototype","__TAG__","name","has","get","UNMOUNT_SYMBOL","cb","delete","i","length","data","splice","newModule","buildNestModule","forEach","module","set","paramtypes","getParamtypes","Error","add","warn","undefined","paramtypesInstances","sub","subTag","Set","push","getMetaFromInstance","registerAsync","writeMeta","fs","promises","writeFile","generateHTTPCode","map","item","generateRPCCode","process","env","NODE_ENV","globalThis","__PS_HMR__","file","isPhecda","__PS_WRITEMETA__","vars","getExposeKey","filter","baseState","getState","initState","state","route","type","method","params","unshift","index","define","header","middlewares","guards","interceptors","Meta","getHandler","Reflect","getMetadata","import_phecda_core","import_phecda_core","BaseParam","type","key","option","target","k","index","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","params","push","setState","Body","pipeOpts","Head","toLowerCase","Query","Param","Arg","import_phecda_core","Route","route","type","target","key","prototype","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","http","setState","Get","Post","Put","Patch","Delete","Controller","Rpc","rpc","import_phecda_core","Guard","guards","target","key","prototype","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","push","setState","Middle","middlewares","Interceptor","interceptors","Header","name","value","target","k","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","header","setState","Define","key","prototype","define","Dev","UNMOUNT_SYMBOL","onUnmount","cb","push","ServerGuard","constructor","tag","addGuard","use","bind","ServerInterceptor","constructor","tag","addInterceptor","use","bind","ServerPipe","constructor","setPipe","use","bind","ServerFilter","constructor","setFilter","use","bind"]}
|