phecda-server 7.0.0-alpha.0 → 7.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/assets/ps.json +24 -24
  2. package/bin/cli.mjs +5 -0
  3. package/dist/{chunk-BGXSMOLX.js → chunk-7YQ57BQS.js} +1 -1
  4. package/dist/{chunk-SW5IKE5H.js → chunk-GSPBHZBH.js} +47 -16
  5. package/dist/{chunk-P75VKZJY.mjs → chunk-V7EI76QQ.mjs} +48 -17
  6. package/dist/{chunk-5622RBNB.mjs → chunk-XYVMNY2X.mjs} +1 -1
  7. package/dist/helper.js +2 -2
  8. package/dist/helper.mjs +1 -1
  9. package/dist/http/elysia/index.js +17 -17
  10. package/dist/http/elysia/index.mjs +1 -1
  11. package/dist/http/express/index.js +17 -17
  12. package/dist/http/express/index.mjs +1 -1
  13. package/dist/http/fastify/index.js +16 -16
  14. package/dist/http/fastify/index.mjs +1 -1
  15. package/dist/http/h3/index.js +16 -16
  16. package/dist/http/h3/index.mjs +1 -1
  17. package/dist/http/hono/index.js +15 -15
  18. package/dist/http/hono/index.mjs +1 -1
  19. package/dist/http/hyper-express/index.js +15 -15
  20. package/dist/http/hyper-express/index.mjs +1 -1
  21. package/dist/http/koa/index.js +17 -17
  22. package/dist/http/koa/index.mjs +1 -1
  23. package/dist/index.d.mts +3 -3
  24. package/dist/index.d.ts +3 -3
  25. package/dist/index.js +20 -20
  26. package/dist/index.mjs +2 -2
  27. package/dist/rpc/bullmq/index.js +8 -8
  28. package/dist/rpc/bullmq/index.mjs +1 -1
  29. package/dist/rpc/kafka/index.js +7 -7
  30. package/dist/rpc/kafka/index.mjs +1 -1
  31. package/dist/rpc/nats/index.js +7 -7
  32. package/dist/rpc/nats/index.mjs +1 -1
  33. package/dist/rpc/rabbitmq/index.js +8 -8
  34. package/dist/rpc/rabbitmq/index.mjs +1 -1
  35. package/dist/rpc/redis/index.js +8 -8
  36. package/dist/rpc/redis/index.mjs +1 -1
  37. package/dist/test.js +2 -2
  38. package/dist/test.mjs +1 -1
  39. package/package.json +1 -1
  40. package/register/loader.mjs +366 -367
package/assets/ps.json CHANGED
@@ -1,24 +1,24 @@
1
- {
2
- "$schema": "https://unpkg.com/phecda-server/assets/schema.json",
3
- "resolve": [
4
- {
5
- "source": "controller",
6
- "importer": "http",
7
- "path": ".ps/http.js"
8
- },
9
- {
10
- "source": "rpc",
11
- "importer": "client",
12
- "path": ".ps/rpc.js"
13
- }
14
- ],
15
- "unimport": {
16
- "dirs": ["."],
17
- "dirsScanOptions": {
18
- "filePatterns": ["*.{service,controller,module,rpc,edge,guard,interceptor,extension,pipe,filter,plugin}.ts"]
19
- }
20
- },
21
- "virtualFile": {},
22
- "moduleFile": []
23
-
24
- }
1
+ {
2
+ "$schema": "https://unpkg.com/phecda-server/assets/schema.json",
3
+ "resolve": [
4
+ {
5
+ "source": "controller",
6
+ "importer": "http",
7
+ "path": ".ps/http.js"
8
+ },
9
+ {
10
+ "source": "rpc",
11
+ "importer": "client",
12
+ "path": ".ps/rpc.js"
13
+ }
14
+ ],
15
+ "unimport": {
16
+ "dirs": ["."],
17
+ "dirsScanOptions": {
18
+ "filePatterns": ["*.{service,controller,module,rpc,edge,guard,extension,pipe,filter,addon}.ts"]
19
+ }
20
+ },
21
+ "virtualFile": {},
22
+ "moduleFile": []
23
+
24
+ }
package/bin/cli.mjs CHANGED
@@ -46,6 +46,11 @@ function startChild(file, args) {
46
46
  log('only generate code')
47
47
  process.exit(0)
48
48
  }
49
+
50
+ if (code === 5) {
51
+ log('Does not comply with strict mode', 'error')
52
+ process.exit(0)
53
+ }
49
54
  if (code >= 2) {
50
55
  // for relaunch
51
56
  log('relaunch...')
@@ -23,7 +23,7 @@ require('reflect-metadata');
23
23
  var _events = require('events'); var _events2 = _interopRequireDefault(_events);
24
24
  var _phecdacore = require('phecda-core');
25
25
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
26
- var debug = _debug2.default.call(void 0, "phecda-server(createPhecda)");
26
+ var debug = _debug2.default.call(void 0, "phecda-server(Factory)");
27
27
  var emitter = new (0, _events2.default)();
28
28
  function defaultServerInject() {
29
29
  if (!_phecdacore.getInject.call(void 0, "watcher")) {
@@ -4,6 +4,7 @@
4
4
 
5
5
 
6
6
 
7
+
7
8
  var _chunkJ5CFUN4Vjs = require('./chunk-J5CFUN4V.js');
8
9
 
9
10
  // src/helper.ts
@@ -12,6 +13,7 @@ var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefau
12
13
  // src/context.ts
13
14
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
14
15
 
16
+
15
17
  // src/pipe.ts
16
18
  var defaultPipe = /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, ({ arg }) => {
17
19
  return arg;
@@ -235,14 +237,26 @@ var Context = (_class = class _Context {
235
237
  }
236
238
  static getAop(meta, opts) {
237
239
  const { globalGuards = [], globalFilter = "default", globalPipe = "default" } = opts;
238
- const { data: { guards, filter, params } } = meta;
239
- return {
240
- guards: this.getGuards([
240
+ const { data: { guards, filter, params, tag, func } } = meta;
241
+ const resolved = {
242
+ guards: [
241
243
  ...globalGuards,
242
244
  ...guards
243
- ]),
244
- pipe: this.getPipe(params.map((item) => item.pipe || globalPipe)),
245
- filter: this.getFilter(filter || globalFilter)
245
+ ],
246
+ pipe: params.map((item) => item.pipe || globalPipe),
247
+ filter: filter || globalFilter
248
+ };
249
+ if (process.env.DEBUG) {
250
+ const { guards: guards2, pipe, filter: filter2 } = resolved;
251
+ debug(`func "${tag}-${func}" aop:
252
+ ${_picocolors2.default.magenta(`Guard ${guards2.join("->")}[${guards2.filter((g) => g in this.guardRecord).join("->")}]`)}
253
+ ${_picocolors2.default.blue(`Pipe ${pipe.join("-")}[${pipe.map((p) => p in this.pipeRecord ? p : "default").join("-")}]`)}
254
+ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
255
+ }
256
+ return {
257
+ guards: this.getGuards(resolved.guards),
258
+ pipe: this.getPipe(resolved.pipe),
259
+ filter: this.getFilter(resolved.filter)
246
260
  };
247
261
  }
248
262
  async run({ guards, filter, pipe }, successCb, failCb) {
@@ -268,7 +282,7 @@ var Context = (_class = class _Context {
268
282
  async function next() {
269
283
  return nextPromise = nextHandler(index + 1)().then((ret2) => {
270
284
  if (ret2 !== void 0) {
271
- debug(`The ${index + 1}th guard rewrite the response value.`);
285
+ debug(`The ${index + 1}th guard on "${tag}-${func}" rewrite the response value.`);
272
286
  res = ret2;
273
287
  }
274
288
  return res;
@@ -316,17 +330,17 @@ var Context = (_class = class _Context {
316
330
  }
317
331
  }, _class.__initStatic(), _class.__initStatic2(), _class.__initStatic3(), _class.__initStatic4(), _class);
318
332
  function addPipe(key, pipe) {
319
- if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) _chunkJ5CFUN4Vjs.log.call(void 0, `overwrite Pipe "${String(key)}"`, "warn");
333
+ if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) debug(`overwrite Pipe "${String(key)}"`, "warn");
320
334
  Context.pipeRecord[key] = pipe;
321
335
  }
322
336
  _chunkJ5CFUN4Vjs.__name.call(void 0, addPipe, "addPipe");
323
337
  function addFilter(key, filter) {
324
- if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) _chunkJ5CFUN4Vjs.log.call(void 0, `overwrite Filter "${String(key)}"`, "warn");
338
+ if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) debug(`overwrite Filter "${String(key)}"`, "warn");
325
339
  Context.filterRecord[key] = filter;
326
340
  }
327
341
  _chunkJ5CFUN4Vjs.__name.call(void 0, addFilter, "addFilter");
328
342
  function addGuard(key, guard, priority = 0) {
329
- if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) _chunkJ5CFUN4Vjs.log.call(void 0, `overwrite Guard "${String(key)}"`, "warn");
343
+ if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) debug(`overwrite Guard "${String(key)}"`, "warn");
330
344
  Context.guardRecord[key] = {
331
345
  value: guard,
332
346
  priority
@@ -334,7 +348,7 @@ function addGuard(key, guard, priority = 0) {
334
348
  }
335
349
  _chunkJ5CFUN4Vjs.__name.call(void 0, addGuard, "addGuard");
336
350
  function addAddon(key, addon, priority = 0) {
337
- if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) _chunkJ5CFUN4Vjs.log.call(void 0, `overwrite Addon "${String(key)}"`, "warn");
351
+ if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) debug(`overwrite Addon "${String(key)}"`, "warn");
338
352
  Context.addonRecord[key] = {
339
353
  value: addon,
340
354
  priority
@@ -428,7 +442,7 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
428
442
  })]);
429
443
  meta.forEach(({ data }) => {
430
444
  if (data.controller !== controller) {
431
- if (data[controller]) warningSet.add(`Module "${data.tag === data.name ? data.name : `${data.name}(${data.tag})`}" should use ${controller} controller to decorate class or remove ${controller} decorator on method "${data.func}"`);
445
+ if (data[controller]) warningSet.add(`Should use ${controller} controller to decorate class "${data.name}" or method "${data.func}"`);
432
446
  return;
433
447
  }
434
448
  if (data.filter) filterSet.add(data.filter);
@@ -450,11 +464,28 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
450
464
  const missFilters = [
451
465
  ...filterSet
452
466
  ].filter((i) => !Context.filterRecord[i]);
453
- if (missAddons.length) _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
454
- if (missGuards.length) _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
455
- if (missPipes.length) _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
456
- if (missFilters.length) _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
467
+ function exit() {
468
+ if (_chunkJ5CFUN4Vjs.IS_STRICT) process.exit(5);
469
+ }
470
+ _chunkJ5CFUN4Vjs.__name.call(void 0, exit, "exit");
471
+ if (missAddons.length) {
472
+ _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
473
+ exit();
474
+ }
475
+ if (missGuards.length) {
476
+ _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
477
+ exit();
478
+ }
479
+ if (missPipes.length) {
480
+ _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
481
+ exit();
482
+ }
483
+ if (missFilters.length) {
484
+ _chunkJ5CFUN4Vjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
485
+ exit();
486
+ }
457
487
  warningSet.forEach((warn) => _chunkJ5CFUN4Vjs.log.call(void 0, warn, "warn"));
488
+ if (warningSet.size) exit();
458
489
  }
459
490
  _chunkJ5CFUN4Vjs.__name.call(void 0, handleMeta, "handleMeta");
460
491
  handleMeta();
@@ -1,16 +1,18 @@
1
1
  import {
2
2
  ERROR_SYMBOL,
3
3
  IS_HMR,
4
+ IS_STRICT,
4
5
  LOG_LEVEL,
5
6
  __name,
6
7
  log
7
8
  } from "./chunk-WHJ5FALK.mjs";
8
9
 
9
10
  // src/helper.ts
10
- import pc from "picocolors";
11
+ import pc2 from "picocolors";
11
12
 
12
13
  // src/context.ts
13
14
  import Debug from "debug";
15
+ import pc from "picocolors";
14
16
 
15
17
  // src/pipe.ts
16
18
  var defaultPipe = /* @__PURE__ */ __name(({ arg }) => {
@@ -235,14 +237,26 @@ var Context = class _Context {
235
237
  }
236
238
  static getAop(meta, opts) {
237
239
  const { globalGuards = [], globalFilter = "default", globalPipe = "default" } = opts;
238
- const { data: { guards, filter, params } } = meta;
239
- return {
240
- guards: this.getGuards([
240
+ const { data: { guards, filter, params, tag, func } } = meta;
241
+ const resolved = {
242
+ guards: [
241
243
  ...globalGuards,
242
244
  ...guards
243
- ]),
244
- pipe: this.getPipe(params.map((item) => item.pipe || globalPipe)),
245
- filter: this.getFilter(filter || globalFilter)
245
+ ],
246
+ pipe: params.map((item) => item.pipe || globalPipe),
247
+ filter: filter || globalFilter
248
+ };
249
+ if (process.env.DEBUG) {
250
+ const { guards: guards2, pipe, filter: filter2 } = resolved;
251
+ debug(`func "${tag}-${func}" aop:
252
+ ${pc.magenta(`Guard ${guards2.join("->")}[${guards2.filter((g) => g in this.guardRecord).join("->")}]`)}
253
+ ${pc.blue(`Pipe ${pipe.join("-")}[${pipe.map((p) => p in this.pipeRecord ? p : "default").join("-")}]`)}
254
+ ${pc.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
255
+ }
256
+ return {
257
+ guards: this.getGuards(resolved.guards),
258
+ pipe: this.getPipe(resolved.pipe),
259
+ filter: this.getFilter(resolved.filter)
246
260
  };
247
261
  }
248
262
  async run({ guards, filter, pipe }, successCb, failCb) {
@@ -268,7 +282,7 @@ var Context = class _Context {
268
282
  async function next() {
269
283
  return nextPromise = nextHandler(index + 1)().then((ret2) => {
270
284
  if (ret2 !== void 0) {
271
- debug(`The ${index + 1}th guard rewrite the response value.`);
285
+ debug(`The ${index + 1}th guard on "${tag}-${func}" rewrite the response value.`);
272
286
  res = ret2;
273
287
  }
274
288
  return res;
@@ -316,17 +330,17 @@ var Context = class _Context {
316
330
  }
317
331
  };
318
332
  function addPipe(key, pipe) {
319
- if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) log(`overwrite Pipe "${String(key)}"`, "warn");
333
+ if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) debug(`overwrite Pipe "${String(key)}"`, "warn");
320
334
  Context.pipeRecord[key] = pipe;
321
335
  }
322
336
  __name(addPipe, "addPipe");
323
337
  function addFilter(key, filter) {
324
- if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) log(`overwrite Filter "${String(key)}"`, "warn");
338
+ if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) debug(`overwrite Filter "${String(key)}"`, "warn");
325
339
  Context.filterRecord[key] = filter;
326
340
  }
327
341
  __name(addFilter, "addFilter");
328
342
  function addGuard(key, guard, priority = 0) {
329
- if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) log(`overwrite Guard "${String(key)}"`, "warn");
343
+ if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) debug(`overwrite Guard "${String(key)}"`, "warn");
330
344
  Context.guardRecord[key] = {
331
345
  value: guard,
332
346
  priority
@@ -334,7 +348,7 @@ function addGuard(key, guard, priority = 0) {
334
348
  }
335
349
  __name(addGuard, "addGuard");
336
350
  function addAddon(key, addon, priority = 0) {
337
- if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) log(`overwrite Addon "${String(key)}"`, "warn");
351
+ if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) debug(`overwrite Addon "${String(key)}"`, "warn");
338
352
  Context.addonRecord[key] = {
339
353
  value: addon,
340
354
  priority
@@ -428,7 +442,7 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
428
442
  });
429
443
  meta.forEach(({ data }) => {
430
444
  if (data.controller !== controller) {
431
- if (data[controller]) warningSet.add(`Module "${data.tag === data.name ? data.name : `${data.name}(${data.tag})`}" should use ${controller} controller to decorate class or remove ${controller} decorator on method "${data.func}"`);
445
+ if (data[controller]) warningSet.add(`Should use ${controller} controller to decorate class "${data.name}" or method "${data.func}"`);
432
446
  return;
433
447
  }
434
448
  if (data.filter) filterSet.add(data.filter);
@@ -450,11 +464,28 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
450
464
  const missFilters = [
451
465
  ...filterSet
452
466
  ].filter((i) => !Context.filterRecord[i]);
453
- if (missAddons.length) log(`${pc.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
454
- if (missGuards.length) log(`${pc.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
455
- if (missPipes.length) log(`${pc.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
456
- if (missFilters.length) log(`${pc.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
467
+ function exit() {
468
+ if (IS_STRICT) process.exit(5);
469
+ }
470
+ __name(exit, "exit");
471
+ if (missAddons.length) {
472
+ log(`${pc2.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
473
+ exit();
474
+ }
475
+ if (missGuards.length) {
476
+ log(`${pc2.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
477
+ exit();
478
+ }
479
+ if (missPipes.length) {
480
+ log(`${pc2.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
481
+ exit();
482
+ }
483
+ if (missFilters.length) {
484
+ log(`${pc2.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
485
+ exit();
486
+ }
457
487
  warningSet.forEach((warn) => log(warn, "warn"));
488
+ if (warningSet.size) exit();
458
489
  }
459
490
  __name(handleMeta, "handleMeta");
460
491
  handleMeta();
@@ -23,7 +23,7 @@ import "reflect-metadata";
23
23
  import EventEmitter from "node:events";
24
24
  import { getInject, getMergedMeta, getMetaKey, getMetaParams, getTag, invokeInit, invokeUnmount, isPhecda, setInject } from "phecda-core";
25
25
  import Debug from "debug";
26
- var debug = Debug("phecda-server(createPhecda)");
26
+ var debug = Debug("phecda-server(Factory)");
27
27
  var emitter = new EventEmitter();
28
28
  function defaultServerInject() {
29
29
  if (!getInject("watcher")) {
package/dist/helper.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkSW5IKE5Hjs = require('./chunk-SW5IKE5H.js');
10
+ var _chunkGSPBHZBHjs = require('./chunk-GSPBHZBH.js');
11
11
  require('./chunk-J5CFUN4V.js');
12
12
 
13
13
 
@@ -18,4 +18,4 @@ require('./chunk-J5CFUN4V.js');
18
18
 
19
19
 
20
20
 
21
- exports.HMR = _chunkSW5IKE5Hjs.HMR; exports.argToReq = _chunkSW5IKE5Hjs.argToReq; exports.createControllerMetaMap = _chunkSW5IKE5Hjs.createControllerMetaMap; exports.detectAopDep = _chunkSW5IKE5Hjs.detectAopDep; exports.genClientQueue = _chunkSW5IKE5Hjs.genClientQueue; exports.mergeObject = _chunkSW5IKE5Hjs.mergeObject; exports.resolveDep = _chunkSW5IKE5Hjs.resolveDep; exports.shallowClone = _chunkSW5IKE5Hjs.shallowClone;
21
+ exports.HMR = _chunkGSPBHZBHjs.HMR; exports.argToReq = _chunkGSPBHZBHjs.argToReq; exports.createControllerMetaMap = _chunkGSPBHZBHjs.createControllerMetaMap; exports.detectAopDep = _chunkGSPBHZBHjs.detectAopDep; exports.genClientQueue = _chunkGSPBHZBHjs.genClientQueue; exports.mergeObject = _chunkGSPBHZBHjs.mergeObject; exports.resolveDep = _chunkGSPBHZBHjs.resolveDep; exports.shallowClone = _chunkGSPBHZBHjs.shallowClone;
package/dist/helper.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  mergeObject,
8
8
  resolveDep,
9
9
  shallowClone
10
- } from "./chunk-P75VKZJY.mjs";
10
+ } from "./chunk-V7EI76QQ.mjs";
11
11
  import "./chunk-WHJ5FALK.mjs";
12
12
  export {
13
13
  HMR,
@@ -7,7 +7,7 @@ var _chunkMBCHNDAYjs = require('../../chunk-MBCHNDAY.js');
7
7
 
8
8
 
9
9
 
10
- var _chunkSW5IKE5Hjs = require('../../chunk-SW5IKE5H.js');
10
+ var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
11
11
 
12
12
 
13
13
  var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
@@ -19,14 +19,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/elysia");
19
19
  function bind(app, data, opts = {}) {
20
20
  const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
21
21
  const { moduleMap, meta } = data;
22
- const metaMap = _chunkSW5IKE5Hjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
+ const metaMap = _chunkGSPBHZBHjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
23
23
  const { controller, http, func, tag } = meta2.data;
24
24
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
25
25
  debug(`register method "${func}" in module "${tag}"`);
26
26
  return true;
27
27
  }
28
28
  });
29
- _chunkSW5IKE5Hjs.detectAopDep.call(void 0, meta, {
29
+ _chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
30
30
  addons: [
31
31
  ...globalAddons,
32
32
  ...parallelAddons
@@ -35,29 +35,29 @@ function bind(app, data, opts = {}) {
35
35
  });
36
36
  registerRoute();
37
37
  function registerRoute() {
38
- _chunkSW5IKE5Hjs.Context.applyAddons(globalAddons, app, "elysia");
38
+ _chunkGSPBHZBHjs.Context.applyAddons(globalAddons, app, "elysia");
39
39
  if (parallelRoute) {
40
40
  const parallelRouter = new (0, _elysia.Elysia)();
41
- _chunkSW5IKE5Hjs.Context.applyAddons(parallelAddons, app, "elysia");
41
+ _chunkGSPBHZBHjs.Context.applyAddons(parallelAddons, app, "elysia");
42
42
  parallelRouter.post(parallelRoute, async (c) => {
43
43
  const { body } = c;
44
44
  async function errorHandler(e) {
45
- const error = await _chunkSW5IKE5Hjs.Context.filterRecord.default(e);
45
+ const error = await _chunkGSPBHZBHjs.Context.filterRecord.default(e);
46
46
  c.set.status = error.status;
47
47
  return error;
48
48
  }
49
49
  _chunkJ5CFUN4Vjs.__name.call(void 0, errorHandler, "errorHandler");
50
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkSW5IKE5Hjs.BadRequestException)("data format should be an array"));
50
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkGSPBHZBHjs.BadRequestException)("data format should be an array"));
51
51
  try {
52
52
  return Promise.all(body.map((item, i) => {
53
53
  return new Promise(async (resolve) => {
54
54
  const { tag, func } = item;
55
55
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
56
- if (!metaMap.has(tag)) return resolve(await _chunkSW5IKE5Hjs.Context.filterRecord.default(new (0, _chunkSW5IKE5Hjs.BadRequestException)(`module "${tag}" doesn't exist`)));
56
+ if (!metaMap.has(tag)) return resolve(await _chunkGSPBHZBHjs.Context.filterRecord.default(new (0, _chunkGSPBHZBHjs.BadRequestException)(`module "${tag}" doesn't exist`)));
57
57
  const meta2 = metaMap.get(tag)[func];
58
- if (!meta2) return resolve(await _chunkSW5IKE5Hjs.Context.filterRecord.default(new (0, _chunkSW5IKE5Hjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
58
+ if (!meta2) return resolve(await _chunkGSPBHZBHjs.Context.filterRecord.default(new (0, _chunkGSPBHZBHjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
59
59
  const { data: { params } } = meta2;
60
- const aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
60
+ const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
61
61
  globalGuards,
62
62
  globalFilter,
63
63
  globalPipe
@@ -72,7 +72,7 @@ function bind(app, data, opts = {}) {
72
72
  tag,
73
73
  func,
74
74
  app,
75
- ..._chunkSW5IKE5Hjs.argToReq.call(void 0, params, item.args, c.headers),
75
+ ..._chunkGSPBHZBHjs.argToReq.call(void 0, params, item.args, c.headers),
76
76
  getCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
77
77
  setCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
78
78
  ...opts2,
@@ -89,7 +89,7 @@ function bind(app, data, opts = {}) {
89
89
  throw new Error("elysia can't support getResponse");
90
90
  }, "getResponse")
91
91
  };
92
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
92
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
93
93
  context.run(aop, resolve, resolve);
94
94
  });
95
95
  })).then((ret) => {
@@ -111,13 +111,13 @@ function bind(app, data, opts = {}) {
111
111
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
112
112
  let aop;
113
113
  if (!dynamic) {
114
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
114
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
115
115
  globalFilter,
116
116
  globalGuards,
117
117
  globalPipe
118
118
  });
119
119
  }
120
- _chunkSW5IKE5Hjs.Context.applyAddons(addons, subApp, "elysia");
120
+ _chunkGSPBHZBHjs.Context.applyAddons(addons, subApp, "elysia");
121
121
  subApp[http.type](http.prefix + http.route, async (c) => {
122
122
  debug(`invoke method "${func}" in module "${tag}"`);
123
123
  const contextData = {
@@ -149,16 +149,16 @@ function bind(app, data, opts = {}) {
149
149
  }, "getResponse")
150
150
  };
151
151
  if (dynamic) {
152
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
152
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
153
153
  globalFilter,
154
154
  globalGuards,
155
155
  globalPipe
156
156
  });
157
157
  }
158
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
158
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
159
159
  if (http.headers) c.set.headers = http.headers;
160
160
  if (dynamic) {
161
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
161
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
162
162
  globalFilter,
163
163
  globalGuards,
164
164
  globalPipe
@@ -7,7 +7,7 @@ import {
7
7
  argToReq,
8
8
  createControllerMetaMap,
9
9
  detectAopDep
10
- } from "../../chunk-P75VKZJY.mjs";
10
+ } from "../../chunk-V7EI76QQ.mjs";
11
11
  import {
12
12
  __name
13
13
  } from "../../chunk-WHJ5FALK.mjs";
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkSW5IKE5Hjs = require('../../chunk-SW5IKE5H.js');
8
+ var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
9
9
 
10
10
 
11
11
  var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
@@ -18,14 +18,14 @@ function bind(router, data, opts = {}) {
18
18
  const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
19
19
  const { moduleMap, meta } = data;
20
20
  const originStack = router.stack.slice(0, router.stack.length);
21
- const metaMap = _chunkSW5IKE5Hjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
+ const metaMap = _chunkGSPBHZBHjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
22
  const { controller, http, func, tag } = meta2.data;
23
23
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
24
24
  debug(`register method "${func}" in module "${tag}"`);
25
25
  return true;
26
26
  }
27
27
  });
28
- _chunkSW5IKE5Hjs.detectAopDep.call(void 0, meta, {
28
+ _chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
29
29
  addons: [
30
30
  ...globalAddons,
31
31
  ...parallelAddons
@@ -33,33 +33,33 @@ function bind(router, data, opts = {}) {
33
33
  guards: globalGuards
34
34
  });
35
35
  registerRoute();
36
- _chunkSW5IKE5Hjs.HMR.call(void 0, async () => {
36
+ _chunkGSPBHZBHjs.HMR.call(void 0, async () => {
37
37
  router.stack = originStack;
38
38
  registerRoute();
39
39
  });
40
40
  function registerRoute() {
41
- _chunkSW5IKE5Hjs.Context.applyAddons(globalAddons, router, "express");
41
+ _chunkGSPBHZBHjs.Context.applyAddons(globalAddons, router, "express");
42
42
  if (parallelRoute) {
43
43
  const subRouter = _express.Router.call(void 0, );
44
- _chunkSW5IKE5Hjs.Context.applyAddons(parallelAddons, subRouter, "express");
44
+ _chunkGSPBHZBHjs.Context.applyAddons(parallelAddons, subRouter, "express");
45
45
  subRouter.use(async (req, res, next) => {
46
46
  const { body } = req;
47
47
  async function errorHandler(e) {
48
- const error = await _chunkSW5IKE5Hjs.Context.filterRecord.default(e);
48
+ const error = await _chunkGSPBHZBHjs.Context.filterRecord.default(e);
49
49
  return res.status(error.status).json(error);
50
50
  }
51
51
  _chunkJ5CFUN4Vjs.__name.call(void 0, errorHandler, "errorHandler");
52
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkSW5IKE5Hjs.BadRequestException)("data format should be an array"));
52
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkGSPBHZBHjs.BadRequestException)("data format should be an array"));
53
53
  try {
54
54
  return Promise.all(body.map((item, i) => {
55
55
  return new Promise(async (resolve) => {
56
56
  const { tag, func } = item;
57
57
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
58
- if (!metaMap.has(tag)) return resolve(await _chunkSW5IKE5Hjs.Context.filterRecord.default(new (0, _chunkSW5IKE5Hjs.BadRequestException)(`module "${tag}" doesn't exist`)));
58
+ if (!metaMap.has(tag)) return resolve(await _chunkGSPBHZBHjs.Context.filterRecord.default(new (0, _chunkGSPBHZBHjs.BadRequestException)(`module "${tag}" doesn't exist`)));
59
59
  const meta2 = metaMap.get(tag)[func];
60
- if (!meta2) return resolve(await _chunkSW5IKE5Hjs.Context.filterRecord.default(new (0, _chunkSW5IKE5Hjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
60
+ if (!meta2) return resolve(await _chunkGSPBHZBHjs.Context.filterRecord.default(new (0, _chunkGSPBHZBHjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
61
61
  const { data: { params } } = meta2;
62
- const aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
62
+ const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
63
63
  globalFilter,
64
64
  globalGuards,
65
65
  globalPipe
@@ -76,7 +76,7 @@ function bind(router, data, opts = {}) {
76
76
  func,
77
77
  next,
78
78
  app: router,
79
- ..._chunkSW5IKE5Hjs.argToReq.call(void 0, params, item.args, req.headers),
79
+ ..._chunkGSPBHZBHjs.argToReq.call(void 0, params, item.args, req.headers),
80
80
  getCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
81
81
  setCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, opts2 || {}), "setCookie"),
82
82
  delCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key) => res.cookie(key, "", {
@@ -88,7 +88,7 @@ function bind(router, data, opts = {}) {
88
88
  getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => req, "getRequest"),
89
89
  getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => res, "getResponse")
90
90
  };
91
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
91
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
92
92
  context.run(aop, resolve, resolve);
93
93
  });
94
94
  })).then((ret) => {
@@ -107,14 +107,14 @@ function bind(router, data, opts = {}) {
107
107
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
108
108
  let aop;
109
109
  if (!dynamic) {
110
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
110
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
111
111
  globalFilter,
112
112
  globalGuards,
113
113
  globalPipe
114
114
  });
115
115
  }
116
116
  const subRouter = _express.Router.call(void 0, );
117
- _chunkSW5IKE5Hjs.Context.applyAddons(addons, subRouter, "express");
117
+ _chunkGSPBHZBHjs.Context.applyAddons(addons, subRouter, "express");
118
118
  subRouter[http.type](http.prefix + http.route, async (req, res, next) => {
119
119
  debug(`invoke method "${func}" in module "${tag}"`);
120
120
  const contextData = {
@@ -142,10 +142,10 @@ function bind(router, data, opts = {}) {
142
142
  getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => req, "getRequest"),
143
143
  getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => res, "getResponse")
144
144
  };
145
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
145
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
146
146
  if (http.headers) res.set(http.headers);
147
147
  if (dynamic) {
148
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
148
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
149
149
  globalFilter,
150
150
  globalGuards,
151
151
  globalPipe
@@ -5,7 +5,7 @@ import {
5
5
  argToReq,
6
6
  createControllerMetaMap,
7
7
  detectAopDep
8
- } from "../../chunk-P75VKZJY.mjs";
8
+ } from "../../chunk-V7EI76QQ.mjs";
9
9
  import {
10
10
  __name
11
11
  } from "../../chunk-WHJ5FALK.mjs";