phecda-server 7.0.0-alpha.7 → 7.0.0-alpha.9

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 (80) hide show
  1. package/bin/cli.mjs +10 -1
  2. package/dist/{chunk-M5HGFUCV.js → chunk-5RBTN33A.js} +23 -3
  3. package/dist/{chunk-RGSKKTHD.mjs → chunk-7ZGYJ5OW.mjs} +88 -54
  4. package/dist/{chunk-IRXNF6ZE.mjs → chunk-CVPZWDXU.mjs} +39 -30
  5. package/dist/{chunk-MENRZSGW.js → chunk-FX3LDQII.js} +88 -79
  6. package/dist/{chunk-C5BVKEGW.mjs → chunk-FXTJ3BJ6.mjs} +25 -5
  7. package/dist/{chunk-XSMUJ77A.js → chunk-KJUD2BKE.js} +103 -69
  8. package/dist/{chunk-JPSXNDXP.mjs → chunk-ODVWOXVB.mjs} +1 -1
  9. package/dist/{chunk-VYMSCWXC.js → chunk-V5EYXVJT.js} +24 -24
  10. package/dist/{core-DU7gQKSk.d.mts → core-BDkhrEyf.d.mts} +4 -3
  11. package/dist/{core-CzElxZoF.d.ts → core-D_cz0tKa.d.ts} +4 -3
  12. package/dist/helper.d.mts +7 -5
  13. package/dist/helper.d.ts +7 -5
  14. package/dist/helper.js +8 -3
  15. package/dist/helper.mjs +10 -5
  16. package/dist/http/elysia/index.d.mts +4 -4
  17. package/dist/http/elysia/index.d.ts +4 -4
  18. package/dist/http/elysia/index.js +41 -44
  19. package/dist/http/elysia/index.mjs +7 -10
  20. package/dist/http/express/index.d.mts +4 -4
  21. package/dist/http/express/index.d.ts +4 -4
  22. package/dist/http/express/index.js +38 -41
  23. package/dist/http/express/index.mjs +7 -10
  24. package/dist/http/fastify/index.d.mts +4 -4
  25. package/dist/http/fastify/index.d.ts +4 -4
  26. package/dist/http/fastify/index.js +39 -42
  27. package/dist/http/fastify/index.mjs +7 -10
  28. package/dist/http/h3/index.d.mts +4 -4
  29. package/dist/http/h3/index.d.ts +4 -4
  30. package/dist/http/h3/index.js +39 -42
  31. package/dist/http/h3/index.mjs +7 -10
  32. package/dist/http/hono/index.d.mts +4 -4
  33. package/dist/http/hono/index.d.ts +4 -4
  34. package/dist/http/hono/index.js +35 -39
  35. package/dist/http/hono/index.mjs +3 -7
  36. package/dist/http/hyper-express/index.d.mts +4 -4
  37. package/dist/http/hyper-express/index.d.ts +4 -4
  38. package/dist/http/hyper-express/index.js +36 -39
  39. package/dist/http/hyper-express/index.mjs +6 -9
  40. package/dist/http/koa/index.d.mts +4 -4
  41. package/dist/http/koa/index.d.ts +4 -4
  42. package/dist/http/koa/index.js +38 -41
  43. package/dist/http/koa/index.mjs +7 -10
  44. package/dist/index.d.mts +35 -33
  45. package/dist/index.d.ts +35 -33
  46. package/dist/index.js +42 -43
  47. package/dist/index.mjs +15 -16
  48. package/dist/{meta-BTnLXuCa.d.ts → meta-BX5jhe4Z.d.mts} +3 -4
  49. package/dist/{meta-BTnLXuCa.d.mts → meta-BX5jhe4Z.d.ts} +3 -4
  50. package/dist/rpc/bullmq/index.d.mts +4 -4
  51. package/dist/rpc/bullmq/index.d.ts +4 -4
  52. package/dist/rpc/bullmq/index.js +14 -14
  53. package/dist/rpc/bullmq/index.mjs +3 -3
  54. package/dist/rpc/kafka/index.d.mts +4 -4
  55. package/dist/rpc/kafka/index.d.ts +4 -4
  56. package/dist/rpc/kafka/index.js +14 -14
  57. package/dist/rpc/kafka/index.mjs +2 -2
  58. package/dist/rpc/nats/index.d.mts +4 -4
  59. package/dist/rpc/nats/index.d.ts +4 -4
  60. package/dist/rpc/nats/index.js +13 -13
  61. package/dist/rpc/nats/index.mjs +3 -3
  62. package/dist/rpc/rabbitmq/index.d.mts +4 -4
  63. package/dist/rpc/rabbitmq/index.d.ts +4 -4
  64. package/dist/rpc/rabbitmq/index.js +15 -15
  65. package/dist/rpc/rabbitmq/index.mjs +3 -3
  66. package/dist/rpc/redis/index.d.mts +4 -4
  67. package/dist/rpc/redis/index.d.ts +4 -4
  68. package/dist/rpc/redis/index.js +13 -13
  69. package/dist/rpc/redis/index.mjs +3 -3
  70. package/dist/test.d.mts +3 -3
  71. package/dist/test.d.ts +3 -3
  72. package/dist/test.js +6 -6
  73. package/dist/test.mjs +2 -2
  74. package/dist/{types-CbfaGkPA.d.ts → types-B-rUM9Fm.d.mts} +3 -3
  75. package/dist/{types--E-OCZhC.d.ts → types-CMeuFoyd.d.ts} +3 -3
  76. package/dist/{types-BxlzVoRv.d.mts → types-DKVhyZk_.d.mts} +3 -3
  77. package/dist/{types-BYqBeqrs.d.mts → types-MxxtkZXw.d.ts} +3 -3
  78. package/package.json +3 -2
  79. package/register/index.mjs +20 -11
  80. package/register/loader.mjs +13 -28
@@ -1,16 +1,16 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkVYMSCWXCjs = require('../../chunk-VYMSCWXC.js');
3
+ var _chunkV5EYXVJTjs = require('../../chunk-V5EYXVJT.js');
4
4
 
5
5
 
6
6
 
7
7
 
8
8
 
9
9
 
10
- var _chunkMENRZSGWjs = require('../../chunk-MENRZSGW.js');
10
+ var _chunkFX3LDQIIjs = require('../../chunk-FX3LDQII.js');
11
11
 
12
12
 
13
- var _chunkM5HGFUCVjs = require('../../chunk-M5HGFUCV.js');
13
+ var _chunk5RBTN33Ajs = require('../../chunk-5RBTN33A.js');
14
14
 
15
15
  // src/http/fastify/bind.ts
16
16
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
@@ -18,14 +18,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/fastify");
18
18
  function bind(fastify, data, opts = {}) {
19
19
  const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, fastifyOpts, dynamic = false } = opts;
20
20
  const { moduleMap, meta } = data;
21
- const metaMap = _chunkMENRZSGWjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
+ const metaMap = _chunkFX3LDQIIjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
22
  const { controller, http, func, tag } = meta2.data;
23
23
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _2 => _2.type])) {
24
24
  debug(`register method "${func}" in module "${tag}"`);
25
25
  return true;
26
26
  }
27
27
  });
28
- _chunkMENRZSGWjs.detectAopDep.call(void 0, meta, {
28
+ _chunkFX3LDQIIjs.detectAopDep.call(void 0, meta, {
29
29
  addons: [
30
30
  ...globalAddons,
31
31
  ...parallelAddons
@@ -33,28 +33,27 @@ function bind(fastify, data, opts = {}) {
33
33
  guards: globalGuards
34
34
  });
35
35
  fastify.register(async (fastify2, _, done) => {
36
- _chunkMENRZSGWjs.Context.applyAddons(globalAddons, fastify2, "fastify");
36
+ _chunkFX3LDQIIjs.Context.applyAddons(globalAddons, fastify2, "fastify");
37
37
  if (parallelRoute) {
38
38
  fastify2.register(async (fastify3, _opts, done2) => {
39
- _chunkMENRZSGWjs.Context.applyAddons(parallelAddons, fastify3, "fastify");
39
+ _chunkFX3LDQIIjs.Context.applyAddons(parallelAddons, fastify3, "fastify");
40
40
  fastify3.post(parallelRoute, async (req, res) => {
41
41
  const { body } = req;
42
42
  async function errorHandler(e) {
43
- const error = await _chunkMENRZSGWjs.Context.filterRecord.default(e);
43
+ const error = await _chunkFX3LDQIIjs.Context.filterRecord.default(e);
44
44
  return res.status(error.status).send(error);
45
45
  }
46
- _chunkM5HGFUCVjs.__name.call(void 0, errorHandler, "errorHandler");
47
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkMENRZSGWjs.BadRequestException)("data format should be an array"));
46
+ _chunk5RBTN33Ajs.__name.call(void 0, errorHandler, "errorHandler");
47
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkFX3LDQIIjs.BadRequestException)("data format should be an array"));
48
48
  try {
49
49
  return Promise.all(body.map((item, i) => {
50
50
  return new Promise(async (resolve) => {
51
51
  const { tag, func } = item;
52
52
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
53
- if (!metaMap.has(tag)) return resolve(await _chunkMENRZSGWjs.Context.filterRecord.default(new (0, _chunkMENRZSGWjs.BadRequestException)(`module "${tag}" doesn't exist`)));
53
+ if (!metaMap.has(tag)) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`module "${tag}" doesn't exist`)));
54
54
  const meta2 = metaMap.get(tag)[func];
55
- if (!meta2) return resolve(await _chunkMENRZSGWjs.Context.filterRecord.default(new (0, _chunkMENRZSGWjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
56
- const { data: { params } } = meta2;
57
- const aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
55
+ if (!meta2) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
56
+ const aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
58
57
  globalFilter,
59
58
  globalGuards,
60
59
  globalPipe
@@ -68,23 +67,21 @@ function bind(fastify, data, opts = {}) {
68
67
  meta: meta2,
69
68
  response: res,
70
69
  moduleMap,
71
- tag,
72
- func,
73
70
  app: fastify3,
74
- ..._chunkMENRZSGWjs.argToReq.call(void 0, params, item.args, req.headers),
71
+ ...item,
75
72
  // @ts-expect-error need @fastify/cookie
76
- getCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
73
+ getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
77
74
  // @ts-expect-error need @fastify/cookie
78
- setCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
75
+ setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
79
76
  // @ts-expect-error need @fastify/cookie
80
- delCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
81
- redirect: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
82
- setResHeaders: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
83
- setResStatus: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
84
- getRequest: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => req.raw, "getRequest"),
85
- getResponse: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => res.raw, "getResponse")
77
+ delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
78
+ redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
79
+ setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
80
+ setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
81
+ getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => req.raw, "getRequest"),
82
+ getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => res.raw, "getResponse")
86
83
  };
87
- const context = new (0, _chunkMENRZSGWjs.Context)(contextData);
84
+ const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
88
85
  context.run(aop, resolve, resolve);
89
86
  });
90
87
  })).then((ret) => {
@@ -103,16 +100,16 @@ function bind(fastify, data, opts = {}) {
103
100
  const { data: { addons, define, http } } = meta2;
104
101
  if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
105
102
  fastify2.register(async (fastify3, _opts, done2) => {
106
- _chunkMENRZSGWjs.Context.applyAddons(addons, fastify3, "fastify");
103
+ _chunkFX3LDQIIjs.Context.applyAddons(addons, fastify3, "fastify");
107
104
  let aop;
108
105
  if (!dynamic) {
109
- aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
106
+ aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
110
107
  globalFilter,
111
108
  globalGuards,
112
109
  globalPipe
113
110
  });
114
111
  }
115
- fastify3[http.type](http.prefix + http.route, _optionalChain([define, 'optionalAccess', _4 => _4.fastify]) || {}, async (req, res) => {
112
+ fastify3[http.type](_chunkFX3LDQIIjs.joinUrl.call(void 0, http.prefix, http.route), _optionalChain([define, 'optionalAccess', _4 => _4.fastify]) || {}, async (req, res) => {
116
113
  debug(`invoke method "${func}" in module "${tag}"`);
117
114
  const contextData = {
118
115
  type: "fastify",
@@ -129,23 +126,23 @@ function bind(fastify, data, opts = {}) {
129
126
  headers: req.headers,
130
127
  app: fastify3,
131
128
  // @ts-expect-error need @fastify/cookie
132
- getCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
129
+ getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
133
130
  // @ts-expect-error need @fastify/cookie
134
- setCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
131
+ setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
135
132
  // @ts-expect-error need @fastify/cookie
136
- delCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => res.clearCookie(key, {
133
+ delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => res.clearCookie(key, {
137
134
  url: ""
138
135
  }), "delCookie"),
139
- redirect: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
140
- setResHeaders: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
141
- setResStatus: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
142
- getRequest: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => req.raw, "getRequest"),
143
- getResponse: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => res.raw, "getResponse")
136
+ redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url, status) => res.redirect(url, status), "redirect"),
137
+ setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => res.headers(headers), "setResHeaders"),
138
+ setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
139
+ getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => req.raw, "getRequest"),
140
+ getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => res.raw, "getResponse")
144
141
  };
145
- const context = new (0, _chunkMENRZSGWjs.Context)(contextData);
142
+ const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
146
143
  if (http.headers) res.headers(http.headers);
147
144
  if (dynamic) {
148
- aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
145
+ aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
149
146
  globalFilter,
150
147
  globalGuards,
151
148
  globalPipe
@@ -166,11 +163,11 @@ function bind(fastify, data, opts = {}) {
166
163
  done();
167
164
  }, fastifyOpts);
168
165
  }
169
- _chunkM5HGFUCVjs.__name.call(void 0, bind, "bind");
166
+ _chunk5RBTN33Ajs.__name.call(void 0, bind, "bind");
170
167
  function Fastify(opts) {
171
- return _chunkVYMSCWXCjs.Define.call(void 0, "fastify", opts);
168
+ return _chunkV5EYXVJTjs.Define.call(void 0, "fastify", opts);
172
169
  }
173
- _chunkM5HGFUCVjs.__name.call(void 0, Fastify, "Fastify");
170
+ _chunk5RBTN33Ajs.__name.call(void 0, Fastify, "Fastify");
174
171
 
175
172
 
176
173
 
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  Define
3
- } from "../../chunk-JPSXNDXP.mjs";
3
+ } from "../../chunk-ODVWOXVB.mjs";
4
4
  import {
5
5
  BadRequestException,
6
6
  Context,
7
- argToReq,
8
7
  createControllerMetaMap,
9
- detectAopDep
10
- } from "../../chunk-IRXNF6ZE.mjs";
8
+ detectAopDep,
9
+ joinUrl
10
+ } from "../../chunk-CVPZWDXU.mjs";
11
11
  import {
12
12
  __name
13
- } from "../../chunk-C5BVKEGW.mjs";
13
+ } from "../../chunk-FXTJ3BJ6.mjs";
14
14
 
15
15
  // src/http/fastify/bind.ts
16
16
  import Debug from "debug";
@@ -53,7 +53,6 @@ function bind(fastify, data, opts = {}) {
53
53
  if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
54
54
  const meta2 = metaMap.get(tag)[func];
55
55
  if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
56
- const { data: { params } } = meta2;
57
56
  const aop = Context.getAop(meta2, {
58
57
  globalFilter,
59
58
  globalGuards,
@@ -68,10 +67,8 @@ function bind(fastify, data, opts = {}) {
68
67
  meta: meta2,
69
68
  response: res,
70
69
  moduleMap,
71
- tag,
72
- func,
73
70
  app: fastify3,
74
- ...argToReq(params, item.args, req.headers),
71
+ ...item,
75
72
  // @ts-expect-error need @fastify/cookie
76
73
  getCookie: /* @__PURE__ */ __name((key) => req.cookies[key], "getCookie"),
77
74
  // @ts-expect-error need @fastify/cookie
@@ -112,7 +109,7 @@ function bind(fastify, data, opts = {}) {
112
109
  globalPipe
113
110
  });
114
111
  }
115
- fastify3[http.type](http.prefix + http.route, define?.fastify || {}, async (req, res) => {
112
+ fastify3[http.type](joinUrl(http.prefix, http.route), define?.fastify || {}, async (req, res) => {
116
113
  debug(`invoke method "${func}" in module "${tag}"`);
117
114
  const contextData = {
118
115
  type: "fastify",
@@ -1,11 +1,11 @@
1
1
  import { H3Event, Router, _RequestMiddleware } from 'h3';
2
- import { F as Factory } from '../../core-DU7gQKSk.mjs';
3
- import { H as HttpContext, a as HttpOptions } from '../../types-BxlzVoRv.mjs';
2
+ import { F as Factory } from '../../core-BDkhrEyf.mjs';
3
+ import { H as HttpCtx, a as HttpOptions } from '../../types-DKVhyZk_.mjs';
4
4
  import 'phecda-core';
5
- import '../../meta-BTnLXuCa.mjs';
5
+ import '../../meta-BX5jhe4Z.mjs';
6
6
  import 'node:http';
7
7
 
8
- interface H3Ctx extends HttpContext {
8
+ interface H3Ctx extends HttpCtx {
9
9
  type: 'h3';
10
10
  event: H3Event;
11
11
  app: Router;
@@ -1,11 +1,11 @@
1
1
  import { H3Event, Router, _RequestMiddleware } from 'h3';
2
- import { F as Factory } from '../../core-CzElxZoF.js';
3
- import { H as HttpContext, a as HttpOptions } from '../../types--E-OCZhC.js';
2
+ import { F as Factory } from '../../core-D_cz0tKa.js';
3
+ import { H as HttpCtx, a as HttpOptions } from '../../types-CMeuFoyd.js';
4
4
  import 'phecda-core';
5
- import '../../meta-BTnLXuCa.js';
5
+ import '../../meta-BX5jhe4Z.js';
6
6
  import 'node:http';
7
7
 
8
- interface H3Ctx extends HttpContext {
8
+ interface H3Ctx extends HttpCtx {
9
9
  type: 'h3';
10
10
  event: H3Event;
11
11
  app: Router;
@@ -4,10 +4,10 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkMENRZSGWjs = require('../../chunk-MENRZSGW.js');
7
+ var _chunkFX3LDQIIjs = require('../../chunk-FX3LDQII.js');
8
8
 
9
9
 
10
- var _chunkM5HGFUCVjs = require('../../chunk-M5HGFUCV.js');
10
+ var _chunk5RBTN33Ajs = require('../../chunk-5RBTN33A.js');
11
11
 
12
12
  // src/http/h3/bind.ts
13
13
  var _h3 = require('h3');
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/h3");
16
16
  function bind(router, data, opts = {}) {
17
17
  const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
18
18
  const { moduleMap, meta } = data;
19
- const metaMap = _chunkMENRZSGWjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
19
+ const metaMap = _chunkFX3LDQIIjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
20
20
  const { controller, http, func, tag } = meta2.data;
21
21
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
22
22
  debug(`register method "${func}" in module "${tag}"`);
23
23
  return true;
24
24
  }
25
25
  });
26
- _chunkMENRZSGWjs.detectAopDep.call(void 0, meta, {
26
+ _chunkFX3LDQIIjs.detectAopDep.call(void 0, meta, {
27
27
  addons: [
28
28
  ...globalAddons,
29
29
  ...parallelAddons
@@ -32,32 +32,31 @@ function bind(router, data, opts = {}) {
32
32
  });
33
33
  registerRoute();
34
34
  function registerRoute() {
35
- _chunkMENRZSGWjs.Context.applyAddons(globalAddons, router, "h3");
35
+ _chunkFX3LDQIIjs.Context.applyAddons(globalAddons, router, "h3");
36
36
  if (parallelRoute) {
37
37
  const subRouter = _h3.createRouter.call(void 0, );
38
- _chunkMENRZSGWjs.Context.applyAddons(parallelAddons, subRouter, "h3");
38
+ _chunkFX3LDQIIjs.Context.applyAddons(parallelAddons, subRouter, "h3");
39
39
  subRouter.post(parallelRoute, _h3.eventHandler.call(void 0, {
40
- handler: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, async (event) => {
40
+ handler: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, async (event) => {
41
41
  const body = await _h3.readBody.call(void 0, event, {
42
42
  strict: true
43
43
  });
44
44
  async function errorHandler(e) {
45
- const error = await _chunkMENRZSGWjs.Context.filterRecord.default(e);
45
+ const error = await _chunkFX3LDQIIjs.Context.filterRecord.default(e);
46
46
  _h3.setResponseStatus.call(void 0, event, error.status);
47
47
  return error;
48
48
  }
49
- _chunkM5HGFUCVjs.__name.call(void 0, errorHandler, "errorHandler");
50
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkMENRZSGWjs.BadRequestException)("data format should be an array"));
49
+ _chunk5RBTN33Ajs.__name.call(void 0, errorHandler, "errorHandler");
50
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkFX3LDQIIjs.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 _chunkMENRZSGWjs.Context.filterRecord.default(new (0, _chunkMENRZSGWjs.BadRequestException)(`module "${tag}" doesn't exist`)));
56
+ if (!metaMap.has(tag)) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`module "${tag}" doesn't exist`)));
57
57
  const meta2 = metaMap.get(tag)[func];
58
- if (!meta2) return resolve(await _chunkMENRZSGWjs.Context.filterRecord.default(new (0, _chunkMENRZSGWjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
59
- const { data: { params } } = meta2;
60
- const aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
58
+ if (!meta2) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
59
+ const aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
61
60
  globalFilter,
62
61
  globalGuards,
63
62
  globalPipe
@@ -69,21 +68,19 @@ function bind(router, data, opts = {}) {
69
68
  event,
70
69
  meta: meta2,
71
70
  moduleMap,
72
- tag,
73
- func,
74
71
  parallel: true,
75
72
  app: router,
76
- ..._chunkMENRZSGWjs.argToReq.call(void 0, params, item.args, _h3.getRequestHeaders.call(void 0, event)),
77
- getCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
78
- setCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
79
- delCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
80
- redirect: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (url, status) => _h3.sendRedirect.call(void 0, event, url, status), "redirect"),
81
- setResHeaders: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
82
- setResStatus: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
83
- getRequest: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => event.node.req, "getRequest"),
84
- getResponse: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => event.node.res, "getResponse")
73
+ ...item,
74
+ getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
75
+ setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
76
+ delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
77
+ redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url, status) => _h3.sendRedirect.call(void 0, event, url, status), "redirect"),
78
+ setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
79
+ setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
80
+ getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => event.node.req, "getRequest"),
81
+ getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => event.node.res, "getResponse")
85
82
  };
86
- const context = new (0, _chunkMENRZSGWjs.Context)(contextData);
83
+ const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
87
84
  context.run(aop, resolve, resolve);
88
85
  });
89
86
  }));
@@ -102,15 +99,15 @@ function bind(router, data, opts = {}) {
102
99
  const needBody = params.some((item) => item.type === "body");
103
100
  let aop;
104
101
  if (!dynamic) {
105
- aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
102
+ aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
106
103
  globalFilter,
107
104
  globalGuards,
108
105
  globalPipe
109
106
  });
110
107
  }
111
108
  const subRouter = _h3.createRouter.call(void 0, );
112
- _chunkMENRZSGWjs.Context.applyAddons(addons, subRouter, "h3");
113
- subRouter[http.type](http.prefix + http.route, _h3.defineEventHandler.call(void 0, async (event) => {
109
+ _chunkFX3LDQIIjs.Context.applyAddons(addons, subRouter, "h3");
110
+ subRouter[http.type](_chunkFX3LDQIIjs.joinUrl.call(void 0, http.prefix, http.route), _h3.defineEventHandler.call(void 0, async (event) => {
114
111
  debug(`invoke method "${func}" in module "${tag}"`);
115
112
  const contextData = {
116
113
  type: "h3",
@@ -127,19 +124,19 @@ function bind(router, data, opts = {}) {
127
124
  body: needBody ? await _h3.readBody.call(void 0, event, {
128
125
  strict: true
129
126
  }) : void 0,
130
- getCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
131
- setCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
132
- redirect: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (url) => _h3.sendRedirect.call(void 0, event, url), "redirect"),
133
- setResHeaders: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
134
- setResStatus: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
135
- delCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
136
- getRequest: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => event.node.req, "getRequest"),
137
- getResponse: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => event.node.res, "getResponse")
127
+ getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
128
+ setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
129
+ redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url) => _h3.sendRedirect.call(void 0, event, url), "redirect"),
130
+ setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
131
+ setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
132
+ delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
133
+ getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => event.node.req, "getRequest"),
134
+ getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => event.node.res, "getResponse")
138
135
  };
139
- const context = new (0, _chunkMENRZSGWjs.Context)(contextData);
136
+ const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
140
137
  _h3.setHeaders.call(void 0, event, http.headers || {});
141
138
  if (dynamic) {
142
- aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
139
+ aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
143
140
  globalFilter,
144
141
  globalGuards,
145
142
  globalPipe
@@ -150,13 +147,13 @@ function bind(router, data, opts = {}) {
150
147
  return err;
151
148
  });
152
149
  }));
153
- router.use(http.prefix + http.route, _h3.useBase.call(void 0, "", subRouter.handler));
150
+ router.use(_chunkFX3LDQIIjs.joinUrl.call(void 0, http.prefix, http.route), _h3.useBase.call(void 0, "", subRouter.handler));
154
151
  }
155
152
  }
156
153
  }
157
- _chunkM5HGFUCVjs.__name.call(void 0, registerRoute, "registerRoute");
154
+ _chunk5RBTN33Ajs.__name.call(void 0, registerRoute, "registerRoute");
158
155
  }
159
- _chunkM5HGFUCVjs.__name.call(void 0, bind, "bind");
156
+ _chunk5RBTN33Ajs.__name.call(void 0, bind, "bind");
160
157
 
161
158
 
162
159
  exports.bind = bind;
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  BadRequestException,
3
3
  Context,
4
- argToReq,
5
4
  createControllerMetaMap,
6
- detectAopDep
7
- } from "../../chunk-IRXNF6ZE.mjs";
5
+ detectAopDep,
6
+ joinUrl
7
+ } from "../../chunk-CVPZWDXU.mjs";
8
8
  import {
9
9
  __name
10
- } from "../../chunk-C5BVKEGW.mjs";
10
+ } from "../../chunk-FXTJ3BJ6.mjs";
11
11
 
12
12
  // src/http/h3/bind.ts
13
13
  import { createRouter, defineEventHandler, deleteCookie, eventHandler, getCookie, getQuery, getRequestHeaders, getRouterParams, readBody, sendRedirect, setCookie, setHeaders, setResponseHeaders, setResponseStatus, useBase } from "h3";
@@ -56,7 +56,6 @@ function bind(router, data, opts = {}) {
56
56
  if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
57
57
  const meta2 = metaMap.get(tag)[func];
58
58
  if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
59
- const { data: { params } } = meta2;
60
59
  const aop = Context.getAop(meta2, {
61
60
  globalFilter,
62
61
  globalGuards,
@@ -69,11 +68,9 @@ function bind(router, data, opts = {}) {
69
68
  event,
70
69
  meta: meta2,
71
70
  moduleMap,
72
- tag,
73
- func,
74
71
  parallel: true,
75
72
  app: router,
76
- ...argToReq(params, item.args, getRequestHeaders(event)),
73
+ ...item,
77
74
  getCookie: /* @__PURE__ */ __name((key) => getCookie(event, key), "getCookie"),
78
75
  setCookie: /* @__PURE__ */ __name((key, value, opts2) => setCookie(event, key, value, opts2), "setCookie"),
79
76
  delCookie: /* @__PURE__ */ __name((key) => deleteCookie(event, key), "delCookie"),
@@ -110,7 +107,7 @@ function bind(router, data, opts = {}) {
110
107
  }
111
108
  const subRouter = createRouter();
112
109
  Context.applyAddons(addons, subRouter, "h3");
113
- subRouter[http.type](http.prefix + http.route, defineEventHandler(async (event) => {
110
+ subRouter[http.type](joinUrl(http.prefix, http.route), defineEventHandler(async (event) => {
114
111
  debug(`invoke method "${func}" in module "${tag}"`);
115
112
  const contextData = {
116
113
  type: "h3",
@@ -150,7 +147,7 @@ function bind(router, data, opts = {}) {
150
147
  return err;
151
148
  });
152
149
  }));
153
- router.use(http.prefix + http.route, useBase("", subRouter.handler));
150
+ router.use(joinUrl(http.prefix, http.route), useBase("", subRouter.handler));
154
151
  }
155
152
  }
156
153
  }
@@ -1,11 +1,11 @@
1
1
  import { Context, Hono, MiddlewareHandler } from 'hono';
2
- import { H as HttpContext, a as HttpOptions } from '../../types-BxlzVoRv.mjs';
3
- import { F as Factory } from '../../core-DU7gQKSk.mjs';
2
+ import { H as HttpCtx, a as HttpOptions } from '../../types-DKVhyZk_.mjs';
3
+ import { F as Factory } from '../../core-BDkhrEyf.mjs';
4
4
  import 'node:http';
5
- import '../../meta-BTnLXuCa.mjs';
5
+ import '../../meta-BX5jhe4Z.mjs';
6
6
  import 'phecda-core';
7
7
 
8
- interface HonoCtx extends HttpContext {
8
+ interface HonoCtx extends HttpCtx {
9
9
  type: 'hono';
10
10
  context: Context;
11
11
  app: Hono;
@@ -1,11 +1,11 @@
1
1
  import { Context, Hono, MiddlewareHandler } from 'hono';
2
- import { H as HttpContext, a as HttpOptions } from '../../types--E-OCZhC.js';
3
- import { F as Factory } from '../../core-CzElxZoF.js';
2
+ import { H as HttpCtx, a as HttpOptions } from '../../types-CMeuFoyd.js';
3
+ import { F as Factory } from '../../core-D_cz0tKa.js';
4
4
  import 'node:http';
5
- import '../../meta-BTnLXuCa.js';
5
+ import '../../meta-BX5jhe4Z.js';
6
6
  import 'phecda-core';
7
7
 
8
- interface HonoCtx extends HttpContext {
8
+ interface HonoCtx extends HttpCtx {
9
9
  type: 'hono';
10
10
  context: Context;
11
11
  app: Hono;