phecda-server 7.0.0-alpha.8 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/assets/schema.json +12 -9
- package/bin/cli.mjs +96 -37
- package/dist/chunk-5SUY5UVC.js +258 -0
- package/dist/chunk-5SUY5UVC.js.map +1 -0
- package/dist/chunk-6JAHCTOT.mjs +334 -0
- package/dist/chunk-6JAHCTOT.mjs.map +1 -0
- package/dist/{chunk-BBNJVYVX.js → chunk-EDAWJVJ4.js} +42 -25
- package/dist/chunk-EDAWJVJ4.js.map +1 -0
- package/dist/{chunk-7EMAZGYO.js → chunk-H7OCHDZT.js} +65 -95
- package/dist/chunk-H7OCHDZT.js.map +1 -0
- package/dist/{chunk-QJIAXSLZ.js → chunk-KRUOHWFR.js} +79 -68
- package/dist/chunk-KRUOHWFR.js.map +1 -0
- package/dist/chunk-KUGU3UGO.js +334 -0
- package/dist/chunk-KUGU3UGO.js.map +1 -0
- package/dist/{chunk-SGMQZRP6.mjs → chunk-LBH4RXQQ.mjs} +12 -42
- package/dist/chunk-LBH4RXQQ.mjs.map +1 -0
- package/dist/{chunk-YKP4ODZA.mjs → chunk-MDPW6WGF.mjs} +32 -6
- package/dist/chunk-MDPW6WGF.mjs.map +1 -0
- package/dist/{chunk-VSGYTGHY.js → chunk-RLFCI3RG.js} +31 -5
- package/dist/chunk-RLFCI3RG.js.map +1 -0
- package/dist/{chunk-7NWDKK7D.mjs → chunk-TTHYUNOT.mjs} +18 -1
- package/dist/chunk-TTHYUNOT.mjs.map +1 -0
- package/dist/chunk-VDOICQ2U.mjs +258 -0
- package/dist/chunk-VDOICQ2U.mjs.map +1 -0
- package/dist/{chunk-B45BN7LY.mjs → chunk-WTJKTICN.mjs} +65 -54
- package/dist/chunk-WTJKTICN.mjs.map +1 -0
- package/dist/{core-BGEsBtTG.d.ts → core-BOo3uGFX.d.ts} +5 -4
- package/dist/{core-BcKywWLd.d.mts → core-CF45G79J.d.mts} +5 -4
- package/dist/core-DbqWh47p.d.mts +50 -0
- package/dist/core-Rq7BhPHE.d.ts +50 -0
- package/dist/helper.d.mts +7 -8
- package/dist/helper.d.ts +7 -8
- package/dist/helper.js +5 -3
- package/dist/helper.js.map +1 -0
- package/dist/helper.mjs +9 -7
- package/dist/helper.mjs.map +1 -0
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +43 -45
- package/dist/http/elysia/index.js.map +1 -0
- package/dist/http/elysia/index.mjs +6 -8
- package/dist/http/elysia/index.mjs.map +1 -0
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +40 -42
- package/dist/http/express/index.js.map +1 -0
- package/dist/http/express/index.mjs +6 -8
- package/dist/http/express/index.mjs.map +1 -0
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +41 -43
- package/dist/http/fastify/index.js.map +1 -0
- package/dist/http/fastify/index.mjs +6 -8
- package/dist/http/fastify/index.mjs.map +1 -0
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +41 -43
- package/dist/http/h3/index.js.map +1 -0
- package/dist/http/h3/index.mjs +5 -7
- package/dist/http/h3/index.mjs.map +1 -0
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +37 -39
- package/dist/http/hono/index.js.map +1 -0
- package/dist/http/hono/index.mjs +5 -7
- package/dist/http/hono/index.mjs.map +1 -0
- package/dist/http/hyper-express/index.d.mts +3 -3
- package/dist/http/hyper-express/index.d.ts +3 -3
- package/dist/http/hyper-express/index.js +38 -40
- package/dist/http/hyper-express/index.js.map +1 -0
- package/dist/http/hyper-express/index.mjs +5 -7
- package/dist/http/hyper-express/index.mjs.map +1 -0
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +40 -42
- package/dist/http/koa/index.js.map +1 -0
- package/dist/http/koa/index.mjs +6 -8
- package/dist/http/koa/index.mjs.map +1 -0
- package/dist/index.d.mts +76 -12
- package/dist/index.d.ts +76 -12
- package/dist/index.js +103 -49
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +68 -14
- package/dist/index.mjs.map +1 -0
- package/dist/{meta-B_HW7cWh.d.ts → meta-BoS1E-Nz.d.mts} +6 -24
- package/dist/{meta-B_HW7cWh.d.mts → meta-BoS1E-Nz.d.ts} +6 -24
- package/dist/rpc/bullmq/index.d.mts +4 -6
- package/dist/rpc/bullmq/index.d.ts +4 -6
- package/dist/rpc/bullmq/index.js +13 -80
- package/dist/rpc/bullmq/index.js.map +1 -0
- package/dist/rpc/bullmq/index.mjs +6 -73
- package/dist/rpc/bullmq/index.mjs.map +1 -0
- package/dist/rpc/electron/index.d.mts +13 -0
- package/dist/rpc/electron/index.d.ts +13 -0
- package/dist/rpc/electron/index.js +73 -0
- package/dist/rpc/electron/index.js.map +1 -0
- package/dist/rpc/electron/index.mjs +73 -0
- package/dist/rpc/electron/index.mjs.map +1 -0
- package/dist/rpc/kafka/index.d.mts +4 -9
- package/dist/rpc/kafka/index.d.ts +4 -9
- package/dist/rpc/kafka/index.js +12 -90
- package/dist/rpc/kafka/index.js.map +1 -0
- package/dist/rpc/kafka/index.mjs +5 -83
- package/dist/rpc/kafka/index.mjs.map +1 -0
- package/dist/rpc/nats/index.d.mts +4 -6
- package/dist/rpc/nats/index.d.ts +4 -6
- package/dist/rpc/nats/index.js +13 -72
- package/dist/rpc/nats/index.js.map +1 -0
- package/dist/rpc/nats/index.mjs +5 -64
- package/dist/rpc/nats/index.mjs.map +1 -0
- package/dist/rpc/rabbitmq/index.d.mts +4 -6
- package/dist/rpc/rabbitmq/index.d.ts +4 -6
- package/dist/rpc/rabbitmq/index.js +14 -79
- package/dist/rpc/rabbitmq/index.js.map +1 -0
- package/dist/rpc/rabbitmq/index.mjs +6 -71
- package/dist/rpc/rabbitmq/index.mjs.map +1 -0
- package/dist/rpc/redis/index.d.mts +4 -9
- package/dist/rpc/redis/index.d.ts +4 -9
- package/dist/rpc/redis/index.js +12 -78
- package/dist/rpc/redis/index.js.map +1 -0
- package/dist/rpc/redis/index.mjs +6 -72
- package/dist/rpc/redis/index.mjs.map +1 -0
- package/dist/rpc/web-ext/index.d.mts +2 -0
- package/dist/rpc/web-ext/index.d.ts +2 -0
- package/dist/rpc/web-ext/index.js +1 -0
- package/dist/rpc/web-ext/index.js.map +1 -0
- package/dist/rpc/web-ext/index.mjs +1 -0
- package/dist/rpc/web-ext/index.mjs.map +1 -0
- package/dist/rpc/ws/index.d.mts +14 -0
- package/dist/rpc/ws/index.d.ts +14 -0
- package/dist/rpc/ws/index.js +74 -0
- package/dist/rpc/ws/index.js.map +1 -0
- package/dist/rpc/ws/index.mjs +74 -0
- package/dist/rpc/ws/index.mjs.map +1 -0
- package/dist/test.d.mts +8 -4
- package/dist/test.d.ts +8 -4
- package/dist/test.js +7 -6
- package/dist/test.js.map +1 -0
- package/dist/test.mjs +3 -2
- package/dist/test.mjs.map +1 -0
- package/dist/types-CInz3bD0.d.ts +14 -0
- package/dist/types-E-rqlg3-.d.mts +14 -0
- package/dist/{types-C2SQ9U9V.d.mts → types-SCJZFCYt.d.mts} +1 -1
- package/dist/{types-PFPIQWVF.d.ts → types-xruyYmyu.d.ts} +1 -1
- package/package.json +24 -8
- package/register/export.mjs +30 -0
- package/register/index.mjs +20 -12
- package/register/loader.mjs +94 -116
- package/register/utils.mjs +36 -6
- package/assets/ps.json +0 -24
- package/assets/tsconfig.json +0 -21
- package/dist/types-CYF0vha6.d.ts +0 -19
- package/dist/types-DEQb_e59.d.mts +0 -19
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ERROR_SYMBOL,
|
|
3
|
+
HMR,
|
|
3
4
|
IS_DEV,
|
|
5
|
+
IS_PURE,
|
|
4
6
|
IS_STRICT,
|
|
5
7
|
LOG_LEVEL,
|
|
6
8
|
__name,
|
|
7
9
|
log
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-MDPW6WGF.mjs";
|
|
9
11
|
|
|
10
12
|
// src/helper.ts
|
|
11
13
|
import pc2 from "picocolors";
|
|
@@ -231,16 +233,13 @@ var Context = class _Context {
|
|
|
231
233
|
static guardRecord = {};
|
|
232
234
|
static addonRecord = {};
|
|
233
235
|
ctx;
|
|
234
|
-
canGetCtx
|
|
236
|
+
// protected canGetCtx = true
|
|
235
237
|
constructor(data) {
|
|
236
238
|
this.data = data;
|
|
237
|
-
this.canGetCtx = true;
|
|
238
239
|
if (IS_DEV)
|
|
239
240
|
data._context = this;
|
|
240
|
-
const that = this;
|
|
241
241
|
this.ctx = new Proxy(data, {
|
|
242
242
|
get(target, p) {
|
|
243
|
-
if (IS_DEV && !that.canGetCtx) throw new FrameworkException("ctx must be obtained within the same request cycle in controller");
|
|
244
243
|
if (!(p in target)) log(`attribute "${p}" does not exist on ctx, which might be due to a missing AOP role (such as a guard).`, "warn", data.tag);
|
|
245
244
|
return target[p];
|
|
246
245
|
},
|
|
@@ -291,13 +290,7 @@ ${pc.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
291
290
|
reflect: paramsType[item.index],
|
|
292
291
|
...item
|
|
293
292
|
}, this.ctx)));
|
|
294
|
-
if (IS_DEV) {
|
|
295
|
-
Promise.resolve().then(() => {
|
|
296
|
-
this.canGetCtx = false;
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
293
|
res = await instance[func](...args);
|
|
300
|
-
this.canGetCtx = true;
|
|
301
294
|
} else {
|
|
302
295
|
let nextPromise;
|
|
303
296
|
async function next() {
|
|
@@ -377,39 +370,12 @@ function addAddon(key, addon, priority = 0) {
|
|
|
377
370
|
}
|
|
378
371
|
__name(addAddon, "addAddon");
|
|
379
372
|
|
|
380
|
-
// src/hmr.ts
|
|
381
|
-
function HMR(cb) {
|
|
382
|
-
if (IS_DEV) globalThis.__PS_HMR__?.push(cb);
|
|
383
|
-
}
|
|
384
|
-
__name(HMR, "HMR");
|
|
385
|
-
|
|
386
373
|
// src/http/helper.ts
|
|
387
374
|
function resolveDep(ret, key) {
|
|
388
375
|
if (key) return ret?.[key];
|
|
389
376
|
return ret;
|
|
390
377
|
}
|
|
391
378
|
__name(resolveDep, "resolveDep");
|
|
392
|
-
function argToReq(params, args, headers) {
|
|
393
|
-
const req = {
|
|
394
|
-
body: {},
|
|
395
|
-
query: {},
|
|
396
|
-
params: {},
|
|
397
|
-
headers
|
|
398
|
-
};
|
|
399
|
-
params.forEach((param) => {
|
|
400
|
-
if (param.key) req[param.type][param.key] = args[param.index];
|
|
401
|
-
else req[param.type] = args[param.index];
|
|
402
|
-
});
|
|
403
|
-
return req;
|
|
404
|
-
}
|
|
405
|
-
__name(argToReq, "argToReq");
|
|
406
|
-
|
|
407
|
-
// src/rpc/helper.ts
|
|
408
|
-
import { hostname } from "os";
|
|
409
|
-
function genClientQueue(key) {
|
|
410
|
-
return `PS-${key ? `${key}-` : ""}${hostname()}-${process.pid}`;
|
|
411
|
-
}
|
|
412
|
-
__name(genClientQueue, "genClientQueue");
|
|
413
379
|
|
|
414
380
|
// src/decorators/helper.ts
|
|
415
381
|
function shallowClone(obj) {
|
|
@@ -444,6 +410,7 @@ function createControllerMetaMap(meta, filter) {
|
|
|
444
410
|
}
|
|
445
411
|
__name(createControllerMetaMap, "createControllerMetaMap");
|
|
446
412
|
function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
413
|
+
if (IS_PURE) return;
|
|
447
414
|
const addonSet = /* @__PURE__ */ new Set();
|
|
448
415
|
const guardSet = /* @__PURE__ */ new Set();
|
|
449
416
|
const pipeSet = /* @__PURE__ */ new Set();
|
|
@@ -462,6 +429,8 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
|
462
429
|
guardSet.add(item);
|
|
463
430
|
});
|
|
464
431
|
meta.forEach(({ data }) => {
|
|
432
|
+
if (!data.controller) return;
|
|
433
|
+
if (typeof data.tag !== "string") warningSet.add(`Tag of controller "${data.name}" should be a string`);
|
|
465
434
|
if (data.controller !== controller) {
|
|
466
435
|
if (data[controller]) warningSet.add(`Should use ${controller} controller to decorate class "${data.name}"`);
|
|
467
436
|
return;
|
|
@@ -486,7 +455,10 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
|
486
455
|
...filterSet
|
|
487
456
|
].filter((i) => !Context.filterRecord[i]);
|
|
488
457
|
function exit() {
|
|
489
|
-
if (IS_STRICT)
|
|
458
|
+
if (IS_STRICT) {
|
|
459
|
+
log("Does not meet strict mode requirements", "error");
|
|
460
|
+
process.exit(1);
|
|
461
|
+
}
|
|
490
462
|
}
|
|
491
463
|
__name(exit, "exit");
|
|
492
464
|
if (missAddons.length) {
|
|
@@ -552,13 +524,11 @@ export {
|
|
|
552
524
|
addFilter,
|
|
553
525
|
addGuard,
|
|
554
526
|
addAddon,
|
|
555
|
-
HMR,
|
|
556
527
|
resolveDep,
|
|
557
|
-
argToReq,
|
|
558
|
-
genClientQueue,
|
|
559
528
|
shallowClone,
|
|
560
529
|
mergeObject,
|
|
561
530
|
createControllerMetaMap,
|
|
562
531
|
detectAopDep,
|
|
563
532
|
joinUrl
|
|
564
533
|
};
|
|
534
|
+
//# sourceMappingURL=chunk-LBH4RXQQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helper.ts","../src/context.ts","../src/pipe.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/exception/timer.ts","../src/exception/worker.ts","../src/filter.ts","../src/http/helper.ts","../src/decorators/helper.ts"],"sourcesContent":["// help you build custom framework or decorator\r\n\r\nimport pc from 'picocolors'\r\nimport { log } from './utils'\r\nimport { Context } from './context'\r\nimport { HMR } from './hmr'\r\nimport { ControllerMeta, Meta } from './meta'\r\nimport { IS_PURE, IS_STRICT } from './common'\r\n\r\nexport * from './hmr'\r\nexport * from './http/helper'\r\nexport * from './decorators/helper'\r\n\r\nexport function createControllerMetaMap(meta: Meta[], filter: (meta: Meta) => boolean | void) {\r\n const metaMap = new Map<string, Record<string, ControllerMeta>>()\r\n\r\n function handleMeta() {\r\n metaMap.clear()\r\n for (const item of meta) {\r\n const { tag, func } = item.data\r\n if (!filter(item))\r\n continue\r\n\r\n if (metaMap.has(tag))\r\n metaMap.get(tag)![func] = item as ControllerMeta\r\n\r\n else\r\n metaMap.set(tag, { [func]: item as ControllerMeta })\r\n }\r\n }\r\n\r\n handleMeta()\r\n HMR(handleMeta)\r\n\r\n return metaMap\r\n}\r\n\r\n// detect whether addon/filter/pipe/guard/intercept is injected\r\nexport function detectAopDep(meta: Meta[], { guards, addons }: {\r\n guards?: string[]\r\n addons?: string[]\r\n\r\n} = {}, controller = 'http') {\r\n if (IS_PURE)\r\n return\r\n\r\n const addonSet = new Set<string>()\r\n const guardSet = new Set<string>()\r\n const pipeSet = new Set<string>()\r\n const filterSet = new Set<string>()\r\n const warningSet = new Set<string>()\r\n function handleMeta() {\r\n addonSet.clear()\r\n guardSet.clear()\r\n pipeSet.clear()\r\n filterSet.clear()\r\n warningSet.clear()\r\n\r\n addons?.forEach((item) => {\r\n addonSet.add(item)\r\n })\r\n guards?.forEach((item) => {\r\n guardSet.add(item)\r\n });\r\n\r\n (meta as ControllerMeta[]).forEach(({ data }) => {\r\n if (!data.controller)\r\n return\r\n\r\n if (typeof data.tag !== 'string')\r\n warningSet.add(`Tag of controller \"${data.name}\" should be a string`)\r\n\r\n // @todo func of meta on controller should be string\r\n\r\n if (data.controller !== controller) {\r\n if (data[controller])\r\n warningSet.add(`Should use ${controller} controller to decorate class \"${data.name}\"`)\r\n\r\n return\r\n }\r\n if (data.filter)\r\n filterSet.add(data.filter)\r\n\r\n data.guards.forEach(i => guardSet.add(i))\r\n data.addons.forEach(i => addonSet.add(i))\r\n data.params.forEach((i) => {\r\n if (i.pipe)\r\n pipeSet.add(i.pipe)\r\n })\r\n })\r\n const missAddons = [...addonSet].filter(i => !Context.addonRecord[i])\r\n const missGuards = [...guardSet].filter(i => !Context.guardRecord[i])\r\n const missPipes = [...pipeSet].filter(i => !Context.pipeRecord[i])\r\n const missFilters = [...filterSet].filter(i => !Context.filterRecord[i])\r\n\r\n function exit() {\r\n if (IS_STRICT) {\r\n log('Does not meet strict mode requirements', 'error')\r\n process.exit(1)\r\n }\r\n }\r\n\r\n if (missAddons.length) {\r\n log(`${pc.white(`Addon [${missAddons.join(',')}]`)} doesn't exist`, 'warn')\r\n exit()\r\n }\r\n if (missGuards.length) {\r\n log(`${pc.magenta(`Guard [${missGuards.join(',')}]`)} doesn't exist`, 'warn')\r\n exit()\r\n }\r\n if (missPipes.length) {\r\n log(`${pc.blue(`Pipe [${missPipes.join(',')}]`)} doesn't exist`, 'warn')\r\n exit()\r\n }\r\n if (missFilters.length) {\r\n log(`${pc.red(`Filter [${missFilters.join(',')}]`)} doesn't exist`, 'warn')\r\n exit()\r\n }\r\n\r\n warningSet.forEach(warn => log(warn, 'warn'))\r\n if (warningSet.size)\r\n exit()\r\n }\r\n\r\n handleMeta()\r\n HMR(handleMeta)\r\n return {\r\n addonSet,\r\n guardSet,\r\n pipeSet,\r\n filterSet,\r\n }\r\n}\r\n\r\nexport function joinUrl(base: string, ...paths: string[]) {\r\n const joinedPath = [base, ...paths].filter(p => p).map(path => path.replace(/(^\\/)/g, '')).join('/')\r\n return `/${joinedPath}`\r\n}\r\n","import Debug from 'debug'\r\nimport pc from 'picocolors'\r\nimport { defaultPipe } from './pipe'\r\nimport { defaultFilter } from './filter'\r\nimport type { BaseCtx, DefaultOptions } from './types'\r\nimport { IS_DEV } from './common'\r\nimport { type Exception } from './exception'\r\nimport { resolveDep } from './helper'\r\nimport { ControllerMeta } from './meta'\r\nimport { log } from './utils'\r\n\r\nconst debug = Debug('phecda-server(Context)')\r\n\r\nexport interface AOP {\r\n guards: GuardType[]\r\n pipe: PipeType[]\r\n filter: FilterType\r\n}\r\n\r\nexport interface PipeArg { arg: any; pipe?: string; key: string; type: string; index: number; reflect: any; define: Record<string, any> }\r\nexport type GuardType<Ctx extends BaseCtx = any> = (ctx: Ctx, next: () => Promise<any>) => any\r\nexport type PipeType<Ctx extends BaseCtx = any> = (arg: PipeArg, ctx: Ctx) => Promise<any>\r\nexport type FilterType<Ctx extends BaseCtx = any, E extends Exception = any> = (err: E | Error, ctx?: Ctx) => Error | any\r\n\r\nexport class Context<Ctx extends BaseCtx> {\r\n method: string\r\n params: string[]\r\n\r\n static filterRecord: Record<PropertyKey, FilterType> = {\r\n default: defaultFilter,\r\n }\r\n\r\n static pipeRecord: Record<PropertyKey, PipeType> = {\r\n default: defaultPipe,\r\n }\r\n\r\n static guardRecord: Record<PropertyKey, {\r\n value: GuardType\r\n priority: number\r\n }> = {}\r\n\r\n static addonRecord: Record<PropertyKey, {\r\n value: (router: any, framework: string) => any\r\n priority: number\r\n\r\n }> = {}\r\n\r\n ctx: Ctx\r\n\r\n // protected canGetCtx = true\r\n\r\n constructor(public data: Ctx) {\r\n if (IS_DEV)\r\n // @ts-expect-error work for debug\r\n data._context = this\r\n\r\n // const that = this\r\n\r\n this.ctx = new Proxy(data, {\r\n get(target, p) {\r\n // if (IS_DEV && !that.canGetCtx)// only detect in dev\r\n // throw new FrameworkException('ctx must be obtained within the same request cycle in controller')\r\n\r\n if (!(p in target))\r\n log(`attribute \"${p as string}\" does not exist on ctx, which might be due to a missing AOP role (such as a guard).`, 'warn', data.tag)\r\n\r\n return target[p as any]\r\n },\r\n set(target: any, p, newValue) {\r\n target[p] = newValue\r\n return true\r\n },\r\n })\r\n }\r\n\r\n static getAop(meta: ControllerMeta, opts: DefaultOptions) {\r\n const { globalGuards = [], globalFilter = 'default', globalPipe = 'default' } = opts\r\n const {\r\n data: {\r\n guards, filter,\r\n params, tag, func,\r\n },\r\n } = meta\r\n\r\n const resolved = {\r\n guards: [...globalGuards, ...guards],\r\n pipe: params.map(item => item.pipe || globalPipe),\r\n filter: filter || globalFilter,\r\n\r\n }\r\n\r\n if (process.env.DEBUG) {\r\n const { guards, pipe, filter } = resolved\r\n debug(`func \"${tag}-${func}\" aop: \\n${pc.magenta(`Guard ${guards.join('->')}[${guards.filter(g => g in this.guardRecord).join('->')}]`)}\\n${pc.blue(`Pipe ${pipe.join('-')}[${pipe.map(p => p in this.pipeRecord ? p : 'default').join('-')}]`)}\\n${pc.red(`Filter ${filter}[${filter || 'default'}]`)}`)\r\n }\r\n return {\r\n guards: this.getGuards(resolved.guards),\r\n pipe: this.getPipe(resolved.pipe),\r\n filter: this.getFilter(resolved.filter),\r\n }\r\n }\r\n\r\n public async run<ResponseData = any, ReturnErr = any>({\r\n guards, filter, pipe,\r\n }: {\r\n guards: GuardType[]\r\n filter: FilterType\r\n pipe: PipeType[]\r\n }, successCb: (data: any) => ResponseData, failCb: (err: any) => ReturnErr) {\r\n const { meta, moduleMap } = this.data\r\n const {\r\n paramsType,\r\n data: {\r\n ctxs,\r\n tag,\r\n params,\r\n func,\r\n },\r\n } = meta\r\n\r\n try {\r\n // let current = 0\r\n let res: any\r\n const nextHandler = (index: number) => {\r\n return async () => {\r\n if (index === guards.length) {\r\n const instance = moduleMap.get(tag)!\r\n if (ctxs) {\r\n ctxs.forEach(ctx => instance[ctx] = this.ctx,\r\n )\r\n }\r\n const args = await Promise.all(\r\n params.map((item, i) =>\r\n pipe[i]({ arg: resolveDep(this.data[item.type], item.key), reflect: paramsType[item.index], ...item }, this.ctx),\r\n ),\r\n )\r\n\r\n // if (IS_DEV) {\r\n // Promise.resolve().then(() => {\r\n // this.canGetCtx = false\r\n // })\r\n // }\r\n res = await instance[func](...args)\r\n // this.canGetCtx = true\r\n }\r\n else {\r\n let nextPromise: Promise<any> | undefined\r\n async function next() {\r\n return nextPromise = nextHandler(index + 1)().then((ret) => {\r\n if (ret !== undefined) {\r\n debug(`The ${index + 1}th guard on \"${tag}-${func}\" rewrite the response value.`)\r\n res = ret\r\n }\r\n\r\n return res\r\n })\r\n }\r\n\r\n const ret = await guards[index](this.ctx, next)\r\n\r\n if (ret !== undefined) {\r\n res = ret\r\n }\r\n else {\r\n if (!nextPromise)\r\n await next()\r\n\r\n else\r\n await nextPromise\r\n }\r\n }\r\n }\r\n }\r\n await nextHandler(0)()\r\n\r\n return successCb(res)\r\n }\r\n catch (e) {\r\n const err = await filter(e, this.ctx)\r\n return failCb(err)\r\n }\r\n }\r\n\r\n static getPipe(pipe: string[]) {\r\n return pipe.map((pipe) => {\r\n return Context.pipeRecord[pipe] || Context.pipeRecord.default\r\n })\r\n }\r\n\r\n static getFilter(filter = 'default') {\r\n return Context.filterRecord[filter] || Context.filterRecord.default\r\n }\r\n\r\n static getGuards(guards: string[]) {\r\n const ret: { value: GuardType; priority: number }[] = []\r\n for (const guard of new Set(guards)) {\r\n if (guard in Context.guardRecord)\r\n ret.push(Context.guardRecord[guard])\r\n }\r\n\r\n return ret.sort((a, b) => b.priority - a.priority).map(item => item.value)\r\n }\r\n\r\n static applyAddons(addons: string[], router: any, framework: string) {\r\n const ret: {\r\n value: (router: any, framework: string) => any\r\n priority: number\r\n }[] = []\r\n for (const a of new Set(addons)) {\r\n if (a in Context.addonRecord)\r\n ret.push(Context.addonRecord[a])\r\n }\r\n\r\n ret.sort((a, b) => b.priority - a.priority).forEach(item => item.value(router, framework))\r\n\r\n // await Context.addonRecord[a](router, framework)\r\n }\r\n}\r\n\r\nexport function addPipe<C extends BaseCtx>(key: PropertyKey, pipe: PipeType<C>) {\r\n if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe)\r\n debug(`overwrite Pipe \"${String(key)}\"`, 'warn')\r\n Context.pipeRecord[key] = pipe\r\n}\r\n\r\nexport function addFilter<C extends BaseCtx>(key: PropertyKey, filter: FilterType<C>) {\r\n if (Context.filterRecord[key] && Context.filterRecord[key] !== filter)\r\n debug(`overwrite Filter \"${String(key)}\"`, 'warn')\r\n Context.filterRecord[key] = filter\r\n}\r\n\r\nexport function addGuard<C extends BaseCtx>(key: PropertyKey, guard: GuardType<C>, priority = 0) {\r\n if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard)\r\n debug(`overwrite Guard \"${String(key)}\"`, 'warn')\r\n\r\n Context.guardRecord[key] = {\r\n value: guard,\r\n priority,\r\n }\r\n}\r\nexport function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority = 0) {\r\n if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon)\r\n debug(`overwrite Addon \"${String(key)}\"`, 'warn')\r\n Context.addonRecord[key] = {\r\n value: addon,\r\n priority,\r\n }\r\n}\r\n","// import { isPhecda, } from 'phecda-core'\r\n// import { ValidateException } from './exception/validate'\r\n\r\nimport type { PipeType } from './context'\r\n\r\nexport const defaultPipe: PipeType = ({ arg }) => {\n // if (['query', 'params'].includes(type) && reflect !== String) {\r\n // if ([Object, Array].includes(reflect)) {\r\n // return JSON.parse(arg)\r\n // }\r\n // if ([Number, Boolean].includes(reflect)) {\r\n // return reflect(arg)\r\n // }\r\n // }\r\n return arg\r\n}\r\n","import { ERROR_SYMBOL } from '../common'\r\n\r\nexport class Exception extends Error {\r\n constructor(public message: string, public status = 0, public description = 'Exception') {\r\n super(message)\r\n }\r\n\r\n get data() {\r\n return { message: this.message, description: this.description, status: this.status, [ERROR_SYMBOL]: true }\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class UndefinedException extends Exception {\r\n constructor(message: string) {\r\n super(message, 500, 'Undefined error')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class ValidateException extends Exception {\r\n constructor(message: string) {\r\n super(message, 400, 'Validate exception')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class ForbiddenException extends Exception {\r\n constructor(message: string) {\r\n super(message, 403, 'Forbidden resource')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class BadRequestException extends Exception {\r\n constructor(message: string) {\r\n super(message, 400, 'Bad Request')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class NotFoundException extends Exception {\r\n constructor(message: string) {\r\n super(message, 404, 'Not Found')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class ConflictException extends Exception {\r\n constructor(message: string) {\r\n super(message, 409, 'Conflict')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class BadGatewayException extends Exception {\r\n constructor(message: string) {\r\n super(message, 502, 'Bad Gatrway')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class InvalidInputException extends Exception {\r\n constructor(message: string) {\r\n super(message, 502, 'Invalid Input')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class UnsupportedMediaTypeException extends Exception {\r\n constructor(message: string) {\r\n super(message, 415, 'Unsupported Media Type')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class PayloadLargeException extends Exception {\r\n constructor(message: string) {\r\n super(message, 413, 'Payload Too Large')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class TimeoutException extends Exception {\r\n constructor(message: string) {\r\n super(message, 408, 'Request Timeout',\r\n )\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class UnauthorizedException extends Exception {\r\n constructor(message: string) {\r\n super(message, 401, 'Unauthorized')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class ServiceUnavailableException extends Exception {\r\n constructor(message: string) {\r\n super(message, 503, 'Service Unavailable')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class FrameworkException extends Exception {\r\n constructor(message: string) {\r\n super(`[phecda-server] ${message}`, 500, 'Framework Error')\r\n }\r\n}\r\n","import { Exception } from './base'\r\nexport class TimerException extends Exception {\r\n constructor(message: string) {\r\n super(message, 0, 'Timer Error')\r\n }\r\n}\r\n","import { Exception } from './base'\r\nexport class WorkerException extends Exception {\r\n constructor(message: string) {\r\n super(message, 0, 'Worker Error')\r\n }\r\n}\r\n","import { LOG_LEVEL } from './common'\r\nimport { Exception, UndefinedException } from './exception'\r\nimport { log } from './utils'\r\nimport type { FilterType } from './context'\r\n\r\nexport const defaultFilter: FilterType = (e) => {\r\n if (!(e instanceof Exception)) {\r\n log(e.message, 'error')\r\n if (LOG_LEVEL <= 0)\r\n console.error(e.stack)\r\n\r\n e = new UndefinedException(e.message || e)\r\n }\r\n else {\r\n log(`[${e.constructor.name}] ${e.message}`, 'error')\r\n if (LOG_LEVEL <= 0)\r\n console.error(e.stack)\r\n }\r\n\r\n return e.data\r\n}\r\n","export function resolveDep(ret: any, key: string) {\r\n if (key)\r\n return ret?.[key]\r\n return ret\r\n}\r\n\r\n// export function argToReq(params: ControllerMetaData['params'], args: any[], headers: Record<string, any>) {\r\n// const req = {\r\n// body: {},\r\n// query: {},\r\n// params: {},\r\n// headers,\r\n// } as any\r\n\r\n// params.forEach((param) => {\r\n// if (param.key)\r\n// req[param.type][param.key] = args[param.index]\r\n\r\n// else\r\n// req[param.type] = args[param.index]\r\n// })\r\n\r\n// return req\r\n// }\r\n","export function shallowClone(obj: any) {\r\n return { ...obj }\r\n}\r\nexport function mergeObject(...args: any[]) {\r\n return Object.assign({}, ...args)\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAEA,OAAOA,SAAQ;;;ACFf,OAAOC,WAAW;AAClB,OAAOC,QAAQ;;;ACIR,IAAMC,cAAwB,wBAAC,EAAEC,IAAG,MAAE;AAS3C,SAAOA;AACT,GAVqC;;;ACH9B,IAAMC,YAAN,cAAwBC,MAAAA;EAF/B,OAE+BA;;;;;;EAC7BC,YAAmBC,SAAwBC,SAAS,GAAUC,cAAc,aAAa;AACvF,UAAMF,OAAAA,GAAAA,KADWA,UA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P,UAAIC,WAAW;AACbC,YAAI,0CAA0C,OAAA;AAC9CC,gBAAQH,KAAK,CAAA;MACf;IACF;AALSA;AAOT,QAAIT,WAAWa,QAAQ;AACrBF,UAAI,GAAGG,IAAGC,MAAM,UAAUf,WAAWgB,KAAK,GAAA,CAAA,GAAO,CAAA,kBAAmB,MAAA;AACpEP,WAAAA;IACF;AACA,QAAIN,WAAWU,QAAQ;AACrBF,UAAI,GAAGG,IAAGG,QAAQ,UAAUd,WAAWa,KAAK,GAAA,CAAA,GAAO,CAAA,kBAAmB,MAAA;AACtEP,WAAAA;IACF;AACA,QAAIJ,UAAUQ,QAAQ;AACpBF,UAAI,GAAGG,IAAGI,KAAK,SAASb,UAAUW,KAAK,GAAA,CAAA,GAAO,CAAA,kBAAmB,MAAA;AACjEP,WAAAA;IACF;AACA,QAAIF,YAAYM,QAAQ;AACtBF,UAAI,GAAGG,IAAGK,IAAI,WAAWZ,YAAYS,KAAK,GAAA,CAAA,GAAO,CAAA,kBAAmB,MAAA;AACpEP,WAAAA;IACF;AAEAhB,eAAWC,QAAQ0B,CAAAA,SAAQT,IAAIS,MAAM,MAAA,CAAA;AACrC,QAAI3B,WAAW4B,KACbZ,MAAAA;EACJ;AAvESpC;AAyETA,aAAAA;AACAS,MAAIT,UAAAA;AACJ,SAAO;IACLe;IACAE;IACAC;IACAC;EACF;AACF;AA9FgBT;AAgGT,SAASuC,QAAQC,SAAiBC,OAAe;AACtD,QAAMC,aAAa;IAACF;OAASC;IAAOtD,OAAOwD,CAAAA,MAAKA,CAAAA,EAAGC,IAAIC,CAAAA,SAAQA,KAAKC,QAAQ,UAAU,EAAA,CAAA,EAAKb,KAAK,GAAA;AAChG,SAAO,IAAIS,UAAAA;AACb;AAHgBH;","names":["pc","Debug","pc","defaultPipe","arg","Exception","Error","constructor","message","status","description","data","ERROR_SYMBOL","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","TimerException","Exception","constructor","message","WorkerException","Exception","constructor","message","defaultFilter","e","Exception","log","message","LOG_LEVEL","console","error","stack","UndefinedException","constructor","name","data","debug","Debug","Context","method","params","filterRecord","default","defaultFilter","pipeRecord","defaultPipe","guardRecord","addonRecord","ctx","constructor","data","IS_DEV","_context","Proxy","get","target","p","log","tag","set","newValue","getAop","meta","opts","globalGuards","globalFilter","globalPipe","guards","filter","func","resolved","pipe","map","item","process","env","DEBUG","pc","magenta","join","g","blue","red","getGuards","getPipe","getFilter","run","successCb","failCb","moduleMap","paramsType","ctxs","res","nextHandler","index","length","instance","forEach","args","Promise","all","i","arg","resolveDep","type","key","reflect","nextPromise","next","then","ret","undefined","e","err","guard","Set","push","sort","a","b","priority","value","applyAddons","addons","router","framework","addPipe","String","addFilter","addGuard","addAddon","addon","resolveDep","ret","key","shallowClone","obj","mergeObject","args","Object","assign","createControllerMetaMap","meta","filter","metaMap","Map","handleMeta","clear","item","tag","func","data","has","get","set","HMR","detectAopDep","guards","addons","controller","IS_PURE","addonSet","Set","guardSet","pipeSet","filterSet","warningSet","forEach","add","name","i","params","pipe","missAddons","Context","addonRecord","missGuards","guardRecord","missPipes","pipeRecord","missFilters","filterRecord","exit","IS_STRICT","log","process","length","pc","white","join","magenta","blue","red","warn","size","joinUrl","base","paths","joinedPath","p","map","path","replace"]}
|
|
@@ -6,11 +6,11 @@ var ERROR_SYMBOL = "__PS_ERROR__";
|
|
|
6
6
|
var IS_DEV = process.env.NODE_ENV === "development";
|
|
7
7
|
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
8
|
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
|
+
var IS_PURE = !!process.env.PS_PURE;
|
|
9
10
|
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
10
|
-
var IS_READY = Symbol("IS_READY");
|
|
11
11
|
var PS_EXIT_CODE = /* @__PURE__ */ function(PS_EXIT_CODE2) {
|
|
12
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] =
|
|
13
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["
|
|
12
|
+
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 4171] = "RELAUNCH";
|
|
13
|
+
PS_EXIT_CODE2[PS_EXIT_CODE2["EXIT"] = 4172] = "EXIT";
|
|
14
14
|
return PS_EXIT_CODE2;
|
|
15
15
|
}({});
|
|
16
16
|
|
|
@@ -82,7 +82,7 @@ ${JSON.stringify(message, (key, value) => typeof value === "bigint" ? value.toSt
|
|
|
82
82
|
log(msg, level, ctx) {
|
|
83
83
|
if (!this.isAllowLog(level)) return;
|
|
84
84
|
msg = this.stringifyMessage(msg, level);
|
|
85
|
-
const pidMsg = this.colorize(`[phecda-server] ${process.pid}`, level);
|
|
85
|
+
const pidMsg = this.colorize(`[${process.env.PS_APP_NAME || "phecda-server"}] ${process.pid}`, level);
|
|
86
86
|
const ctxMsg = ctx ? this.colorize(pc.bold(`[${ctx}] `), level) : "";
|
|
87
87
|
const timeDiff = this.diffTimestamp();
|
|
88
88
|
const levelMsg = this.colorize(level.toUpperCase().padStart(7, " "), level);
|
|
@@ -110,18 +110,44 @@ function runMiddleware(ctx, middleware) {
|
|
|
110
110
|
}
|
|
111
111
|
__name(runMiddleware, "runMiddleware");
|
|
112
112
|
|
|
113
|
+
// src/hmr.ts
|
|
114
|
+
function HMR(cb) {
|
|
115
|
+
if (IS_DEV) {
|
|
116
|
+
if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
|
|
117
|
+
globalThis.__PS_HMR__.push(cb);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
__name(HMR, "HMR");
|
|
121
|
+
async function RELOAD(oldModels, newModels) {
|
|
122
|
+
log("reload module...");
|
|
123
|
+
for (const cb of globalThis.__PS_HMR__) await cb(oldModels, newModels);
|
|
124
|
+
log("reload done");
|
|
125
|
+
}
|
|
126
|
+
__name(RELOAD, "RELOAD");
|
|
127
|
+
function RELAUNCH() {
|
|
128
|
+
if (IS_DEV) {
|
|
129
|
+
log("relaunch...");
|
|
130
|
+
process.exit(PS_EXIT_CODE.RELAUNCH);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
__name(RELAUNCH, "RELAUNCH");
|
|
134
|
+
|
|
113
135
|
export {
|
|
114
136
|
__name,
|
|
115
137
|
ERROR_SYMBOL,
|
|
116
138
|
IS_DEV,
|
|
117
139
|
IS_ONLY_GENERATE,
|
|
118
140
|
IS_STRICT,
|
|
141
|
+
IS_PURE,
|
|
119
142
|
LOG_LEVEL,
|
|
120
|
-
IS_READY,
|
|
121
143
|
PS_EXIT_CODE,
|
|
122
144
|
setLogger,
|
|
123
145
|
getLogger,
|
|
124
146
|
log,
|
|
125
147
|
runMiddleware,
|
|
126
|
-
Mixin
|
|
148
|
+
Mixin,
|
|
149
|
+
HMR,
|
|
150
|
+
RELOAD,
|
|
151
|
+
RELAUNCH
|
|
127
152
|
};
|
|
153
|
+
//# sourceMappingURL=chunk-MDPW6WGF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common.ts","../src/utils.ts","../src/hmr.ts"],"sourcesContent":["export const ERROR_SYMBOL = '__PS_ERROR__'// only use in paralle request\r\n\r\nexport const IS_DEV = process.env.NODE_ENV === 'development'\r\nexport const IS_ONLY_GENERATE = !!process.env.PS_GENERATE// work for ci; only generate code\r\nexport const IS_STRICT = !!process.env.PS_STRICT// throw error if depends on an aop module which is not imported\r\nexport const IS_PURE = !!process.env.PS_PURE// pure mode, will skip detectAopDep\r\n\r\nexport const LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0)// internal logger\r\n\r\nexport enum PS_EXIT_CODE {\r\n RELAUNCH = 4171,\r\n EXIT = 4172,\r\n}\r\n","import pc from 'picocolors'\r\nimport { LOG_LEVEL } from './common'\r\nimport { HttpCtx } from './http/types'\r\n\r\nexport type LogLevel = 'error' | 'info' | 'warn' | 'log' | 'debug'\r\n\r\nexport interface Logger {\r\n log(msg: unknown, level: LogLevel, ctx?: string): void\r\n}\r\n\r\nconst isObject = (fn: any): fn is object =>\r\n fn !== null && typeof fn === 'object'\r\n\r\nconst isPlainObject = (fn: any): fn is object => {\r\n if (!isObject(fn))\r\n return false\r\n\r\n const proto = Object.getPrototypeOf(fn)\r\n if (proto === null)\r\n return true\r\n\r\n const ctor\r\n = Object.prototype.hasOwnProperty.call(proto, 'constructor')\r\n && proto.constructor\r\n return (\r\n typeof ctor === 'function'\r\n && ctor instanceof ctor\r\n && Function.prototype.toString.call(ctor)\r\n === Function.prototype.toString.call(Object)\r\n )\r\n}\r\n\r\nclass InternalLogger {\r\n time: number\r\n color = { debug: 'bgMagenta', error: 'red', info: 'gray', warn: 'yellow', log: 'green' } as const\r\n dateFormatter = new Intl.DateTimeFormat(undefined, {\r\n year: 'numeric',\r\n hour: 'numeric',\r\n minute: 'numeric',\r\n second: 'numeric',\r\n day: '2-digit',\r\n month: '2-digit',\r\n })\r\n\r\n diffTimestamp() {\r\n const now = Date.now()\r\n\r\n if (!this.time)\r\n return ''\r\n const diff = now - this.time\r\n\r\n this.time = now\r\n\r\n return diff ? pc.yellow(` +${diff}`) : ''\r\n }\r\n\r\n colorize(message: string, logLevel: LogLevel) {\r\n return pc[this.color[logLevel]](message)\r\n }\r\n\r\n isAllowLog(level: LogLevel) {\r\n const logLevel = {\r\n debug: -1,\r\n info: 0,\r\n log: 1,\r\n warn: 2,\r\n error: 3,\r\n }[level]\r\n\r\n if (logLevel < LOG_LEVEL)\r\n return false\r\n\r\n return true\r\n }\r\n\r\n stringifyMessage(message: unknown, logLevel: LogLevel): string {\r\n if (typeof message === 'function') {\r\n const messageAsStr = Function.prototype.toString.call(message)\r\n const isClass = messageAsStr.startsWith('class ')\r\n if (isClass) {\r\n // If the message is a class, we will display the class name.\r\n return this.stringifyMessage(message.name, logLevel)\r\n }\r\n // If the message is a non-class function, call it and re-resolve its value.\r\n return this.stringifyMessage(message(), logLevel)\r\n }\r\n\r\n return (isPlainObject(message) || Array.isArray(message))\r\n ? `${this.colorize('Object:', logLevel)}\\n${JSON.stringify(\r\n message,\r\n (key, value) =>\r\n typeof value === 'bigint' ? value.toString() : value,\r\n 2,\r\n )}\\n`\r\n : this.colorize(message as string, logLevel)\r\n }\r\n\r\n log(msg: unknown, level: LogLevel, ctx?: string) {\r\n if (!this.isAllowLog(level))\r\n return\r\n msg = this.stringifyMessage(msg, level)\r\n const pidMsg = this.colorize(`[${process.env.PS_APP_NAME || 'phecda-server'}] ${process.pid}`, level)\r\n const ctxMsg = ctx ? this.colorize(pc.bold(`[${ctx}] `), level) : ''\r\n const timeDiff = this.diffTimestamp()\r\n const levelMsg = this.colorize(level.toUpperCase().padStart(7, ' '), level)\r\n process.stdout.write(`${pidMsg} ${this.dateFormatter.format(Date.now())} ${levelMsg} ${ctxMsg}${msg}${timeDiff}\\n`)\r\n }\r\n}\r\n\r\nlet _logger: Logger = new InternalLogger()\r\n\r\nexport function setLogger(logger: Logger) {\r\n _logger = logger\r\n}\r\nexport function getLogger() {\r\n return _logger\r\n}\r\n\r\nexport function log(msg: unknown, level: LogLevel = 'log', ctx?: any) {\r\n _logger.log(msg, level, ctx)\r\n}\r\n\r\nexport function runMiddleware(ctx: HttpCtx, middleware: (req: any, res: any, next?: any) => any) {\r\n return new Promise((resolve) => {\r\n middleware(ctx.getRequest(), ctx.getResponse(), resolve)\r\n })\r\n}\r\n\r\nexport { Mixin } from 'ts-mixer'\r\n","import { Construct } from 'phecda-core'\r\nimport { IS_DEV, PS_EXIT_CODE } from './common'\r\nimport { log } from './utils'\r\nexport function HMR(cb: (oldModels: Construct[], newModels: Construct[]) => any) {\r\n if (IS_DEV) {\r\n if (!globalThis.__PS_HMR__)\r\n globalThis.__PS_HMR__ = []\r\n globalThis.__PS_HMR__.push(cb)\r\n }\r\n}\r\n\r\nexport async function RELOAD(oldModels: Construct[], newModels: Construct[]) {\r\n log('reload module...')\r\n for (const cb of globalThis.__PS_HMR__) await cb(oldModels, newModels)\r\n\r\n log('reload done')\r\n}\r\n\r\nexport function RELAUNCH() {\r\n if (IS_DEV) {\r\n log('relaunch...')\r\n\r\n process.exit(PS_EXIT_CODE.RELAUNCH)\r\n }\r\n}\r\n"],"mappings":";;;;AAAO,IAAMA,eAAe;AAErB,IAAMC,SAASC,QAAQC,IAAIC,aAAa;AACxC,IAAMC,mBAAmB,CAAC,CAACH,QAAQC,IAAIG;AACvC,IAAMC,YAAY,CAAC,CAACL,QAAQC,IAAIK;AAChC,IAAMC,UAAU,CAAC,CAACP,QAAQC,IAAIO;AAE9B,IAAMC,YAAYC,OAAOV,QAAQC,IAAIU,gBAAgB,CAAA;AAErD,IAAKC,eAAAA,yBAAAA,eAAAA;;;SAAAA;;;;ACTZ,OAAOC,QAAQ;AAgIf,SAASC,aAAa;AAtHtB,IAAMC,WAAW,wBAACC,OAChBA,OAAO,QAAQ,OAAOA,OAAO,UADd;AAGjB,IAAMC,gBAAgB,wBAACD,OAAAA;AACrB,MAAI,CAACD,SAASC,EAAAA,EACZ,QAAO;AAET,QAAME,QAAQC,OAAOC,eAAeJ,EAAAA;AACpC,MAAIE,UAAU,KACZ,QAAO;AAET,QAAMG,OACFF,OAAOG,UAAUC,eAAeC,KAAKN,OAAO,aAAA,KAC3CA,MAAMO;AACX,SACE,OAAOJ,SAAS,cACbA,gBAAgBA,QAChBK,SAASJ,UAAUK,SAASH,KAAKH,IAAAA,MAChCK,SAASJ,UAAUK,SAASH,KAAKL,MAAAA;AAEzC,GAjBsB;AAmBtB,IAAMS,iBAAN,MAAMA,gBAAAA;EAhCN,OAgCMA;;;EACJC;EACAC,Q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eAAsBM,OAAOC,WAAwBC,WAAsB;AACzEC,MAAI,kBAAA;AACJ,aAAWR,MAAME,WAAWC,WAAY,OAAMH,GAAGM,WAAWC,SAAAA;AAE5DC,MAAI,aAAA;AACN;AALsBH;AAOf,SAASI,WAAAA;AACd,MAAIR,QAAQ;AACVO,QAAI,aAAA;AAEJE,YAAQC,KAAKC,aAAaH,QAAQ;EACpC;AACF;AANgBA;","names":["ERROR_SYMBOL","IS_DEV","process","env","NODE_ENV","IS_ONLY_GENERATE","PS_GENERATE","IS_STRICT","PS_STRICT","IS_PURE","PS_PURE","LOG_LEVEL","Number","PS_LOG_LEVEL","PS_EXIT_CODE","pc","Mixin","isObject","fn","isPlainObject","proto","Object","getPrototypeOf","ctor","prototype","hasOwnProperty","call","constructor","Function","toString","InternalLogger","time","color","debug","error","info","warn","log","dateFormatter","Intl","DateTimeFormat","undefined","year","hour","minute","second","day","month","diffTimestamp","now","Date","diff","pc","yellow","colorize","message","logLevel","isAllowLog","level","LOG_LEVEL","stringifyMessage","messageAsStr","isClass","startsWith","name","Array","isArray","JSON","stringify","key","value","msg","ctx","pidMsg","process","env","PS_APP_NAME","pid","ctxMsg","bold","timeDiff","levelMsg","toUpperCase","padStart","stdout","write","format","_logger","setLogger","logger","getLogger","runMiddleware","middleware","Promise","resolve","getRequest","getResponse","HMR","cb","IS_DEV","globalThis","__PS_HMR__","push","RELOAD","oldModels","newModels","log","RELAUNCH","process","exit","PS_EXIT_CODE"]}
|
|
@@ -6,11 +6,11 @@ var ERROR_SYMBOL = "__PS_ERROR__";
|
|
|
6
6
|
var IS_DEV = process.env.NODE_ENV === "development";
|
|
7
7
|
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
8
|
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
|
+
var IS_PURE = !!process.env.PS_PURE;
|
|
9
10
|
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
10
|
-
var IS_READY = Symbol("IS_READY");
|
|
11
11
|
var PS_EXIT_CODE = /* @__PURE__ */ function(PS_EXIT_CODE2) {
|
|
12
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] =
|
|
13
|
-
PS_EXIT_CODE2[PS_EXIT_CODE2["
|
|
12
|
+
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 4171] = "RELAUNCH";
|
|
13
|
+
PS_EXIT_CODE2[PS_EXIT_CODE2["EXIT"] = 4172] = "EXIT";
|
|
14
14
|
return PS_EXIT_CODE2;
|
|
15
15
|
}({});
|
|
16
16
|
|
|
@@ -82,7 +82,7 @@ ${JSON.stringify(message, (key, value) => typeof value === "bigint" ? value.toSt
|
|
|
82
82
|
log(msg, level, ctx) {
|
|
83
83
|
if (!this.isAllowLog(level)) return;
|
|
84
84
|
msg = this.stringifyMessage(msg, level);
|
|
85
|
-
const pidMsg = this.colorize(`[phecda-server] ${process.pid}`, level);
|
|
85
|
+
const pidMsg = this.colorize(`[${process.env.PS_APP_NAME || "phecda-server"}] ${process.pid}`, level);
|
|
86
86
|
const ctxMsg = ctx ? this.colorize(_picocolors2.default.bold(`[${ctx}] `), level) : "";
|
|
87
87
|
const timeDiff = this.diffTimestamp();
|
|
88
88
|
const levelMsg = this.colorize(level.toUpperCase().padStart(7, " "), level);
|
|
@@ -110,6 +110,31 @@ function runMiddleware(ctx, middleware) {
|
|
|
110
110
|
}
|
|
111
111
|
__name(runMiddleware, "runMiddleware");
|
|
112
112
|
|
|
113
|
+
// src/hmr.ts
|
|
114
|
+
function HMR(cb) {
|
|
115
|
+
if (IS_DEV) {
|
|
116
|
+
if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
|
|
117
|
+
globalThis.__PS_HMR__.push(cb);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
__name(HMR, "HMR");
|
|
121
|
+
async function RELOAD(oldModels, newModels) {
|
|
122
|
+
log("reload module...");
|
|
123
|
+
for (const cb of globalThis.__PS_HMR__) await cb(oldModels, newModels);
|
|
124
|
+
log("reload done");
|
|
125
|
+
}
|
|
126
|
+
__name(RELOAD, "RELOAD");
|
|
127
|
+
function RELAUNCH() {
|
|
128
|
+
if (IS_DEV) {
|
|
129
|
+
log("relaunch...");
|
|
130
|
+
process.exit(PS_EXIT_CODE.RELAUNCH);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
__name(RELAUNCH, "RELAUNCH");
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
113
138
|
|
|
114
139
|
|
|
115
140
|
|
|
@@ -124,4 +149,5 @@ __name(runMiddleware, "runMiddleware");
|
|
|
124
149
|
|
|
125
150
|
|
|
126
151
|
|
|
127
|
-
exports.__name = __name; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.IS_DEV = IS_DEV; exports.IS_ONLY_GENERATE = IS_ONLY_GENERATE; exports.IS_STRICT = IS_STRICT; exports.
|
|
152
|
+
exports.__name = __name; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.IS_DEV = IS_DEV; exports.IS_ONLY_GENERATE = IS_ONLY_GENERATE; exports.IS_STRICT = IS_STRICT; exports.IS_PURE = IS_PURE; exports.LOG_LEVEL = LOG_LEVEL; exports.PS_EXIT_CODE = PS_EXIT_CODE; exports.setLogger = setLogger; exports.getLogger = getLogger; exports.log = log; exports.runMiddleware = runMiddleware; exports.Mixin = _tsmixer.Mixin; exports.HMR = HMR; exports.RELOAD = RELOAD; exports.RELAUNCH = RELAUNCH;
|
|
153
|
+
//# sourceMappingURL=chunk-RLFCI3RG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\myproject\\phecda\\packages\\server\\dist\\chunk-RLFCI3RG.js"],"names":[],"mappings":"AAAA,yLAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK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ACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA;AACA,IAAA;AACA,IAAA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA;AACA;AACA;AACA,EAAA;AACA,IAAA;AACA,IAAA;AACA,EAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"D:\\myproject\\phecda\\packages\\server\\dist\\chunk-RLFCI3RG.js","sourcesContent":[null]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__name
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MDPW6WGF.mjs";
|
|
4
4
|
|
|
5
5
|
// src/decorators/param.ts
|
|
6
6
|
import { setMeta } from "phecda-core";
|
|
@@ -46,6 +46,20 @@ function Arg(target, k, index) {
|
|
|
46
46
|
})(target, k, index);
|
|
47
47
|
}
|
|
48
48
|
__name(Arg, "Arg");
|
|
49
|
+
function OneFile(key = "") {
|
|
50
|
+
return BaseParam({
|
|
51
|
+
type: "file",
|
|
52
|
+
key
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
__name(OneFile, "OneFile");
|
|
56
|
+
function ManyFiles(key = "") {
|
|
57
|
+
return BaseParam({
|
|
58
|
+
type: "files",
|
|
59
|
+
key
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
__name(ManyFiles, "ManyFiles");
|
|
49
63
|
|
|
50
64
|
// src/decorators/aop.ts
|
|
51
65
|
import { setMeta as setMeta2 } from "phecda-core";
|
|
@@ -209,6 +223,8 @@ export {
|
|
|
209
223
|
Query,
|
|
210
224
|
Param,
|
|
211
225
|
Arg,
|
|
226
|
+
OneFile,
|
|
227
|
+
ManyFiles,
|
|
212
228
|
Guard,
|
|
213
229
|
Addon,
|
|
214
230
|
Filter,
|
|
@@ -227,3 +243,4 @@ export {
|
|
|
227
243
|
Ctx,
|
|
228
244
|
Define
|
|
229
245
|
};
|
|
246
|
+
//# sourceMappingURL=chunk-TTHYUNOT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/decorators/param.ts","../src/decorators/aop.ts","../src/decorators/http.ts","../src/decorators/rpc.ts","../src/decorators/ctx.ts"],"sourcesContent":["import { setMeta } from 'phecda-core'\r\n\r\nexport function BaseParam(data: Record<string, any>): ParameterDecorator {\r\n return (target: any, property: PropertyKey | undefined, index: number) => {\r\n if (!property)\r\n return\r\n\r\n setMeta(target, property, index, data)\r\n }\r\n}\r\n\r\nexport function Body(key = '') {\r\n return BaseParam({\r\n type: 'body',\r\n key,\r\n })\r\n}\r\n// req.headers\r\nexport function Head(key: string) {\r\n return BaseParam({\r\n type: 'headers', key: key.toLowerCase(),\r\n })\r\n}\r\n\r\nexport function Query(key = '') {\r\n return BaseParam({ type: 'query', key })\r\n}\r\nexport function Param(key: string) {\r\n return BaseParam({\r\n type: 'params', key,\r\n })\r\n}\r\n\r\n// work for micro service\r\nexport function Arg(target: any, k: string, index: number) {\r\n BaseParam({\r\n type: 'args', key: `${index}`,\r\n })(target, k, index)\r\n}\r\n\r\nexport function OneFile(key = '') {\r\n return BaseParam({\r\n type: 'file',\r\n key,\r\n })\r\n}\r\n\r\nexport function ManyFiles(key = '') {\r\n return BaseParam({\r\n type: 'files',\r\n key,\r\n })\r\n}\r\n","import { setMeta } from 'phecda-core'\r\nimport { BaseParam } from './param'\r\nexport function Guard(...guards: string[]) {\r\n return (target: any, property?: PropertyKey) => {\r\n setMeta(target, property, undefined, {\r\n guards,\r\n })\r\n }\r\n}\r\n\r\nexport function Addon(...addons: string[]) {\r\n return (target: any, property?: PropertyKey) => {\r\n setMeta(target, property, undefined, {\r\n addons,\r\n })\r\n }\r\n}\r\n\r\nexport function Filter(filter: string) {\r\n return (target: any, property?: PropertyKey) => {\r\n setMeta(target, property, undefined, {\r\n filter,\r\n })\r\n }\r\n}\r\nexport function Pipe(pipe?: string) {\r\n return (target: any, property?: any, index?: any) => {\r\n if (typeof index === 'number') {\r\n BaseParam({ pipe })(target, property, index)\r\n\r\n return\r\n }\r\n setMeta(target, property, undefined, {\r\n pipe,\r\n })\r\n }\r\n}\r\n","import { setMeta } from 'phecda-core'\r\n\r\nexport function Route(route: string, type: string): MethodDecorator {\r\n return (target: any, property: PropertyKey) => {\r\n setMeta(target, property, undefined, {\r\n http: {\r\n route, type,\r\n },\r\n })\r\n }\r\n}\r\nexport function Header(headers: Record<string, string>): MethodDecorator {\r\n return (target: any, property: PropertyKey) => {\r\n setMeta(target, property, undefined, {\r\n http: {\r\n headers,\r\n },\r\n })\r\n }\r\n}\r\n\r\nexport function Get(route = '') {\r\n return Route(route, 'get')\r\n}\r\n\r\nexport function Post(route = '') {\r\n return Route(route, 'post')\r\n}\r\nexport function Put(route = '') {\r\n return Route(route, 'put')\r\n}\r\n\r\nexport function Search(route = '') {\r\n return Route(route, 'search')\r\n}\r\n\r\nexport function Patch(route = '') {\r\n return Route(route, 'patch')\r\n}\r\nexport function Delete(route = '') {\r\n return Route(route, 'delete')\r\n}\r\n\r\nexport function Controller(prefix = '') {\r\n return (target: any) => {\r\n setMeta(target, undefined, undefined, {\r\n controller: 'http',\r\n http: { prefix },\r\n })\r\n }\r\n}\r\n","import { setMeta } from 'phecda-core'\r\n\r\nexport function Queue(queue = '', isEvent?: boolean) {\r\n return (target: any, property?: PropertyKey) => {\r\n setMeta(target, property, undefined, {\r\n rpc: {\r\n queue, isEvent,\r\n },\r\n })\r\n }\r\n}\r\n\r\nexport function Rpc(): ClassDecorator {\r\n return (target: any) => {\r\n setMeta(target, undefined, undefined, {\r\n controller: 'rpc',\r\n })\r\n }\r\n}\r\n","import { SHARE_KEY, setMeta } from 'phecda-core'\r\n\r\nexport const Ctx: PropertyDecorator = (target: any, property: PropertyKey) => {\r\n setMeta(target, SHARE_KEY, undefined, {\r\n ctxs: [property],\r\n })\r\n}\r\n\r\nexport function Define(key: string, value: any): any {\r\n return (target: any, property?: any, index?: number) => {\r\n if (typeof index === 'number') {\r\n setMeta(target, property, undefined, {\r\n params: [{ define: { [key]: value }, index }],\r\n })\r\n }\r\n else {\r\n setMeta(target, property, undefined, {\r\n define: {\r\n [key]: value,\r\n },\r\n })\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;AAAA,SAASA,eAAe;AAEjB,SAASC,UAAUC,MAAyB;AACjD,SAAO,CAACC,QAAaC,UAAmCC,UAAAA;AACtD,QAAI,CAACD,SACH;AAEFE,YAAQH,QAAQC,UAAUC,OAAOH,IAAAA;EACnC;AACF;AAPgBD;AAST,SAASM,KAAKC,MAAM,IAAE;AAC3B,SAAOP,UAAU;IACfQ,MAAM;IACND;EACF,CAAA;AACF;AALgBD;AAOT,SAASG,KAAKF,KAAW;AAC9B,SAAOP,UAAU;IACfQ,MAAM;IAAWD,KAAKA,IAAIG,YAAW;EACvC,CAAA;AACF;AAJgBD;AAMT,SAASE,MAAMJ,MAAM,IAAE;AAC5B,SAAOP,UAAU;IAAEQ,MAAM;IAASD;EAAI,CAAA;AACxC;AAFgBI;AAGT,SAASC,MAAML,KAAW;AAC/B,SAAOP,UAAU;IACfQ,MAAM;IAAUD;EAClB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ClDC,EAAAA,SAAQF,QAAQG,WAAWC,QAAW;IACpCC,MAAM;MAACJ;;EACT,CAAA;AACF,GAJsC;AAM/B,SAASK,OAAOC,KAAaC,OAAU;AAC5C,SAAO,CAACR,QAAaC,UAAgBQ,UAAAA;AACnC,QAAI,OAAOA,UAAU,UAAU;AAC7BP,MAAAA,SAAQF,QAAQC,UAAUG,QAAW;QACnCM,QAAQ;UAAC;YAAEC,QAAQ;cAAE,CAACJ,GAAAA,GAAMC;YAAM;YAAGC;UAAM;;MAC7C,CAAA;IACF,OACK;AACHP,MAAAA,SAAQF,QAAQC,UAAUG,QAAW;QACnCO,QAAQ;UACN,CAACJ,GAAAA,GAAMC;QACT;MACF,CAAA;IACF;EACF;AACF;AAfgBF;","names":["setMeta","BaseParam","data","target","property","index","setMeta","Body","key","type","Head","toLowerCase","Query","Param","Arg","k","OneFile","ManyFiles","setMeta","Guard","guards","target","property","setMeta","undefined","Addon","addons","Filter","filter","Pipe","pipe","index","BaseParam","setMeta","Route","route","type","target","property","setMeta","undefined","http","Header","headers","Get","Post","Put","Search","Patch","Delete","Controller","prefix","controller","setMeta","Queue","queue","isEvent","target","property","setMeta","undefined","rpc","Rpc","controller","SHARE_KEY","setMeta","Ctx","target","property","setMeta","SHARE_KEY","undefined","ctxs","Define","key","value","index","params","define"]}
|