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
@@ -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');
@@ -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 = _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', _2 => _2.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,28 +33,28 @@ function bind(fastify, data, opts = {}) {
33
33
  guards: globalGuards
34
34
  });
35
35
  fastify.register(async (fastify2, _, done) => {
36
- _chunkSW5IKE5Hjs.Context.applyAddons(globalAddons, fastify2, "fastify");
36
+ _chunkGSPBHZBHjs.Context.applyAddons(globalAddons, fastify2, "fastify");
37
37
  if (parallelRoute) {
38
38
  fastify2.register(async (fastify3, _opts, done2) => {
39
- _chunkSW5IKE5Hjs.Context.applyAddons(parallelAddons, fastify3, "fastify");
39
+ _chunkGSPBHZBHjs.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 _chunkSW5IKE5Hjs.Context.filterRecord.default(e);
43
+ const error = await _chunkGSPBHZBHjs.Context.filterRecord.default(e);
44
44
  return res.status(error.status).send(error);
45
45
  }
46
46
  _chunkJ5CFUN4Vjs.__name.call(void 0, errorHandler, "errorHandler");
47
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkSW5IKE5Hjs.BadRequestException)("data format should be an array"));
47
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkGSPBHZBHjs.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 _chunkSW5IKE5Hjs.Context.filterRecord.default(new (0, _chunkSW5IKE5Hjs.BadRequestException)(`module "${tag}" doesn't exist`)));
53
+ if (!metaMap.has(tag)) return resolve(await _chunkGSPBHZBHjs.Context.filterRecord.default(new (0, _chunkGSPBHZBHjs.BadRequestException)(`module "${tag}" doesn't exist`)));
54
54
  const meta2 = metaMap.get(tag)[func];
55
- if (!meta2) return resolve(await _chunkSW5IKE5Hjs.Context.filterRecord.default(new (0, _chunkSW5IKE5Hjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
55
+ if (!meta2) return resolve(await _chunkGSPBHZBHjs.Context.filterRecord.default(new (0, _chunkGSPBHZBHjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
56
56
  const { data: { params } } = meta2;
57
- const aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
57
+ const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
58
58
  globalFilter,
59
59
  globalGuards,
60
60
  globalPipe
@@ -70,7 +70,7 @@ function bind(fastify, data, opts = {}) {
70
70
  tag,
71
71
  func,
72
72
  app: fastify3,
73
- ..._chunkSW5IKE5Hjs.argToReq.call(void 0, params, item.args, req.headers),
73
+ ..._chunkGSPBHZBHjs.argToReq.call(void 0, params, item.args, req.headers),
74
74
  // @ts-expect-error need @fastify/cookie
75
75
  getCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
76
76
  // @ts-expect-error need @fastify/cookie
@@ -83,7 +83,7 @@ function bind(fastify, data, opts = {}) {
83
83
  getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => req.raw, "getRequest"),
84
84
  getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => res.raw, "getResponse")
85
85
  };
86
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
86
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
87
87
  context.run(aop, resolve, resolve);
88
88
  });
89
89
  })).then((ret) => {
@@ -102,10 +102,10 @@ function bind(fastify, data, opts = {}) {
102
102
  const { data: { addons, define, http } } = meta2;
103
103
  if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
104
104
  fastify2.register(async (fastify3, _opts, done2) => {
105
- _chunkSW5IKE5Hjs.Context.applyAddons(addons, fastify3, "fastify");
105
+ _chunkGSPBHZBHjs.Context.applyAddons(addons, fastify3, "fastify");
106
106
  let aop;
107
107
  if (!dynamic) {
108
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
108
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
109
109
  globalFilter,
110
110
  globalGuards,
111
111
  globalPipe
@@ -140,10 +140,10 @@ function bind(fastify, data, opts = {}) {
140
140
  getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => req.raw, "getRequest"),
141
141
  getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => res.raw, "getResponse")
142
142
  };
143
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
143
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
144
144
  if (http.headers) res.headers(http.headers);
145
145
  if (dynamic) {
146
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
146
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
147
147
  globalFilter,
148
148
  globalGuards,
149
149
  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";
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkSW5IKE5Hjs = require('../../chunk-SW5IKE5H.js');
7
+ var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
8
8
 
9
9
 
10
10
  var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
@@ -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 = _chunkSW5IKE5Hjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
19
+ const metaMap = _chunkGSPBHZBHjs.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
- _chunkSW5IKE5Hjs.detectAopDep.call(void 0, meta, {
26
+ _chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
27
27
  addons: [
28
28
  ...globalAddons,
29
29
  ...parallelAddons
@@ -32,32 +32,32 @@ function bind(router, data, opts = {}) {
32
32
  });
33
33
  registerRoute();
34
34
  function registerRoute() {
35
- _chunkSW5IKE5Hjs.Context.applyAddons(globalAddons, router, "h3");
35
+ _chunkGSPBHZBHjs.Context.applyAddons(globalAddons, router, "h3");
36
36
  if (parallelRoute) {
37
37
  const subRouter = _h3.createRouter.call(void 0, );
38
- _chunkSW5IKE5Hjs.Context.applyAddons(parallelAddons, subRouter, "h3");
38
+ _chunkGSPBHZBHjs.Context.applyAddons(parallelAddons, subRouter, "h3");
39
39
  subRouter.post(parallelRoute, _h3.eventHandler.call(void 0, {
40
40
  handler: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__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 _chunkSW5IKE5Hjs.Context.filterRecord.default(e);
45
+ const error = await _chunkGSPBHZBHjs.Context.filterRecord.default(e);
46
46
  _h3.setResponseStatus.call(void 0, event, 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
  globalFilter,
62
62
  globalGuards,
63
63
  globalPipe
@@ -72,7 +72,7 @@ function bind(router, data, opts = {}) {
72
72
  func,
73
73
  parallel: true,
74
74
  app: router,
75
- ..._chunkSW5IKE5Hjs.argToReq.call(void 0, params, item.args, _h3.getRequestHeaders.call(void 0, event)),
75
+ ..._chunkGSPBHZBHjs.argToReq.call(void 0, params, item.args, _h3.getRequestHeaders.call(void 0, event)),
76
76
  getCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
77
77
  setCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
78
78
  delCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
@@ -82,7 +82,7 @@ function bind(router, data, opts = {}) {
82
82
  getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => event.node.req, "getRequest"),
83
83
  getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => event.node.res, "getResponse")
84
84
  };
85
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
85
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
86
86
  context.run(aop, resolve, resolve);
87
87
  });
88
88
  }));
@@ -101,14 +101,14 @@ function bind(router, data, opts = {}) {
101
101
  const needBody = params.some((item) => item.type === "body");
102
102
  let aop;
103
103
  if (!dynamic) {
104
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
104
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
105
105
  globalFilter,
106
106
  globalGuards,
107
107
  globalPipe
108
108
  });
109
109
  }
110
110
  const subRouter = _h3.createRouter.call(void 0, );
111
- _chunkSW5IKE5Hjs.Context.applyAddons(addons, subRouter, "h3");
111
+ _chunkGSPBHZBHjs.Context.applyAddons(addons, subRouter, "h3");
112
112
  subRouter[http.type](http.prefix + http.route, _h3.defineEventHandler.call(void 0, async (event) => {
113
113
  debug(`invoke method "${func}" in module "${tag}"`);
114
114
  const contextData = {
@@ -134,10 +134,10 @@ function bind(router, data, opts = {}) {
134
134
  getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => event.node.req, "getRequest"),
135
135
  getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => event.node.res, "getResponse")
136
136
  };
137
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
137
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
138
138
  _h3.setHeaders.call(void 0, event, http.headers || {});
139
139
  if (dynamic) {
140
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
140
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
141
141
  globalFilter,
142
142
  globalGuards,
143
143
  globalPipe
@@ -4,7 +4,7 @@ import {
4
4
  argToReq,
5
5
  createControllerMetaMap,
6
6
  detectAopDep
7
- } from "../../chunk-P75VKZJY.mjs";
7
+ } from "../../chunk-V7EI76QQ.mjs";
8
8
  import {
9
9
  __name
10
10
  } from "../../chunk-WHJ5FALK.mjs";
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkSW5IKE5Hjs = require('../../chunk-SW5IKE5H.js');
7
+ var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
8
8
 
9
9
 
10
10
  var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
@@ -17,14 +17,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hono");
17
17
  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
- const metaMap = _chunkSW5IKE5Hjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
20
+ const metaMap = _chunkGSPBHZBHjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
21
  const { controller, http, func, tag } = meta2.data;
22
22
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
23
23
  debug(`register method "${func}" in module "${tag}"`);
24
24
  return true;
25
25
  }
26
26
  });
27
- _chunkSW5IKE5Hjs.detectAopDep.call(void 0, meta, {
27
+ _chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
28
28
  addons: [
29
29
  ...globalAddons,
30
30
  ...parallelAddons
@@ -35,26 +35,26 @@ function bind(router, data, opts = {}) {
35
35
  function registerRoute() {
36
36
  if (parallelRoute) {
37
37
  const subApp = new (0, _hono.Hono)();
38
- _chunkSW5IKE5Hjs.Context.applyAddons(parallelAddons, subApp, "hono");
38
+ _chunkGSPBHZBHjs.Context.applyAddons(parallelAddons, subApp, "hono");
39
39
  subApp.post("", async (c) => {
40
40
  const body = await c.req.json();
41
41
  async function errorHandler(e) {
42
- const error = await _chunkSW5IKE5Hjs.Context.filterRecord.default(e);
42
+ const error = await _chunkGSPBHZBHjs.Context.filterRecord.default(e);
43
43
  c.status(error.status);
44
44
  return c.json(error);
45
45
  }
46
46
  _chunkJ5CFUN4Vjs.__name.call(void 0, errorHandler, "errorHandler");
47
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkSW5IKE5Hjs.BadRequestException)("data format should be an array"));
47
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkGSPBHZBHjs.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 _chunkSW5IKE5Hjs.Context.filterRecord.default(new (0, _chunkSW5IKE5Hjs.BadRequestException)(`module "${tag}" doesn't exist`)));
53
+ if (!metaMap.has(tag)) return resolve(await _chunkGSPBHZBHjs.Context.filterRecord.default(new (0, _chunkGSPBHZBHjs.BadRequestException)(`module "${tag}" doesn't exist`)));
54
54
  const meta2 = metaMap.get(tag)[func];
55
- if (!meta2) return resolve(await _chunkSW5IKE5Hjs.Context.filterRecord.default(new (0, _chunkSW5IKE5Hjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
55
+ if (!meta2) return resolve(await _chunkGSPBHZBHjs.Context.filterRecord.default(new (0, _chunkGSPBHZBHjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
56
56
  const { data: { params } } = meta2;
57
- const aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
57
+ const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
58
58
  globalFilter,
59
59
  globalGuards,
60
60
  globalPipe
@@ -69,7 +69,7 @@ function bind(router, data, opts = {}) {
69
69
  tag,
70
70
  func,
71
71
  app: router,
72
- ..._chunkSW5IKE5Hjs.argToReq.call(void 0, params, item.args, c.req.header()),
72
+ ..._chunkGSPBHZBHjs.argToReq.call(void 0, params, item.args, c.req.header()),
73
73
  getCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
74
74
  delCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
75
75
  setCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
@@ -81,7 +81,7 @@ function bind(router, data, opts = {}) {
81
81
  getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => c.req.raw, "getRequest"),
82
82
  getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => c.res, "getResponse")
83
83
  };
84
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
84
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
85
85
  context.run(aop, resolve, resolve);
86
86
  });
87
87
  })).then((ret) => {
@@ -101,14 +101,14 @@ function bind(router, data, opts = {}) {
101
101
  const needBody = params.some((item) => item.type === "body");
102
102
  let aop;
103
103
  if (!dynamic) {
104
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
104
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
105
105
  globalFilter,
106
106
  globalGuards,
107
107
  globalPipe
108
108
  });
109
109
  }
110
110
  const subApp = new (0, _hono.Hono)();
111
- _chunkSW5IKE5Hjs.Context.applyAddons(addons, subApp, "hono");
111
+ _chunkGSPBHZBHjs.Context.applyAddons(addons, subApp, "hono");
112
112
  subApp[http.type](http.route, async (c) => {
113
113
  debug(`invoke method "${func}" in module "${tag}"`);
114
114
  const contextData = {
@@ -134,12 +134,12 @@ function bind(router, data, opts = {}) {
134
134
  getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => c.req.raw, "getRequest"),
135
135
  getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => c.res, "getResponse")
136
136
  };
137
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
137
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
138
138
  if (http.headers) {
139
139
  for (const name in http.headers) c.header(name, http.headers[name]);
140
140
  }
141
141
  if (dynamic) {
142
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
142
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
143
143
  globalFilter,
144
144
  globalGuards,
145
145
  globalPipe
@@ -4,7 +4,7 @@ import {
4
4
  argToReq,
5
5
  createControllerMetaMap,
6
6
  detectAopDep
7
- } from "../../chunk-P75VKZJY.mjs";
7
+ } from "../../chunk-V7EI76QQ.mjs";
8
8
  import {
9
9
  __name
10
10
  } from "../../chunk-WHJ5FALK.mjs";
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkSW5IKE5Hjs = require('../../chunk-SW5IKE5H.js');
7
+ var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
8
8
 
9
9
 
10
10
  var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hyper-express");
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 = _chunkSW5IKE5Hjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
19
+ const metaMap = _chunkGSPBHZBHjs.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
- _chunkSW5IKE5Hjs.detectAopDep.call(void 0, meta, {
26
+ _chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
27
27
  addons: [
28
28
  ...globalAddons,
29
29
  ...parallelAddons
@@ -32,27 +32,27 @@ function bind(router, data, opts = {}) {
32
32
  });
33
33
  registerRoute();
34
34
  async function registerRoute() {
35
- _chunkSW5IKE5Hjs.Context.applyAddons(globalAddons, router, "hyper-express");
35
+ _chunkGSPBHZBHjs.Context.applyAddons(globalAddons, router, "hyper-express");
36
36
  if (parallelRoute) {
37
37
  const subRouter = new (0, _hyperexpress.Router)();
38
38
  subRouter.post(parallelRoute, async (req, res, next) => {
39
39
  const body = await req.json();
40
40
  async function errorHandler(e) {
41
- const error = await _chunkSW5IKE5Hjs.Context.filterRecord.default(e);
41
+ const error = await _chunkGSPBHZBHjs.Context.filterRecord.default(e);
42
42
  return res.status(error.status).json(error);
43
43
  }
44
44
  _chunkJ5CFUN4Vjs.__name.call(void 0, errorHandler, "errorHandler");
45
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkSW5IKE5Hjs.BadRequestException)("data format should be an array"));
45
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkGSPBHZBHjs.BadRequestException)("data format should be an array"));
46
46
  try {
47
47
  return Promise.all(body.map((item, i) => {
48
48
  return new Promise(async (resolve) => {
49
49
  const { tag, func } = item;
50
50
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
51
- if (!metaMap.has(tag)) return resolve(await _chunkSW5IKE5Hjs.Context.filterRecord.default(new (0, _chunkSW5IKE5Hjs.BadRequestException)(`module "${tag}" doesn't exist`)));
51
+ if (!metaMap.has(tag)) return resolve(await _chunkGSPBHZBHjs.Context.filterRecord.default(new (0, _chunkGSPBHZBHjs.BadRequestException)(`module "${tag}" doesn't exist`)));
52
52
  const meta2 = metaMap.get(tag)[func];
53
- if (!meta2) return resolve(await _chunkSW5IKE5Hjs.Context.filterRecord.default(new (0, _chunkSW5IKE5Hjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
53
+ if (!meta2) return resolve(await _chunkGSPBHZBHjs.Context.filterRecord.default(new (0, _chunkGSPBHZBHjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
54
54
  const { data: { params } } = meta2;
55
- const aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
55
+ const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
56
56
  globalFilter,
57
57
  globalGuards,
58
58
  globalPipe
@@ -68,7 +68,7 @@ function bind(router, data, opts = {}) {
68
68
  tag,
69
69
  func,
70
70
  app: router,
71
- ..._chunkSW5IKE5Hjs.argToReq.call(void 0, params, item.args, req.headers),
71
+ ..._chunkGSPBHZBHjs.argToReq.call(void 0, params, item.args, req.headers),
72
72
  next,
73
73
  getCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
74
74
  setCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _2 => _2.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
@@ -79,7 +79,7 @@ function bind(router, data, opts = {}) {
79
79
  getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => req, "getRequest"),
80
80
  getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => res, "getResponse")
81
81
  };
82
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
82
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
83
83
  context.run(aop, resolve, resolve);
84
84
  });
85
85
  })).then((ret) => {
@@ -99,14 +99,14 @@ function bind(router, data, opts = {}) {
99
99
  const needBody = params.some((item) => item.type === "body");
100
100
  let aop;
101
101
  if (!dynamic) {
102
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
102
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
103
103
  globalFilter,
104
104
  globalGuards,
105
105
  globalPipe
106
106
  });
107
107
  }
108
108
  const subRouter = new (0, _hyperexpress.Router)();
109
- _chunkSW5IKE5Hjs.Context.applyAddons(addons, subRouter, "hyper-express");
109
+ _chunkGSPBHZBHjs.Context.applyAddons(addons, subRouter, "hyper-express");
110
110
  subRouter[http.type](http.prefix + http.route, async (req, res, next) => {
111
111
  debug(`invoke method "${func}" in module "${tag}"`);
112
112
  const contextData = {
@@ -132,12 +132,12 @@ function bind(router, data, opts = {}) {
132
132
  getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => req, "getRequest"),
133
133
  getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => res, "getResponse")
134
134
  };
135
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
135
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
136
136
  if (http.headers) {
137
137
  for (const name in http.headers) res.set(name, http.headers[name]);
138
138
  }
139
139
  if (dynamic) {
140
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
140
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
141
141
  globalFilter,
142
142
  globalGuards,
143
143
  globalPipe
@@ -4,7 +4,7 @@ import {
4
4
  argToReq,
5
5
  createControllerMetaMap,
6
6
  detectAopDep
7
- } from "../../chunk-P75VKZJY.mjs";
7
+ } from "../../chunk-V7EI76QQ.mjs";
8
8
  import {
9
9
  __name
10
10
  } 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
@@ -34,29 +34,29 @@ function bind(router, data, opts = {}) {
34
34
  });
35
35
  registerRoute();
36
36
  function registerRoute() {
37
- _chunkSW5IKE5Hjs.Context.applyAddons(globalAddons, router, "koa");
37
+ _chunkGSPBHZBHjs.Context.applyAddons(globalAddons, router, "koa");
38
38
  if (parallelRoute) {
39
39
  const subRouter = new (0, _router2.default)();
40
- _chunkSW5IKE5Hjs.Context.applyAddons(parallelAddons, subRouter, "koa");
40
+ _chunkGSPBHZBHjs.Context.applyAddons(parallelAddons, subRouter, "koa");
41
41
  subRouter.post(parallelRoute, async (ctx, next) => {
42
42
  const { body } = ctx.request;
43
43
  async function errorHandler(e) {
44
- const error = await _chunkSW5IKE5Hjs.Context.filterRecord.default(e);
44
+ const error = await _chunkGSPBHZBHjs.Context.filterRecord.default(e);
45
45
  ctx.status = error.status;
46
46
  ctx.body = error;
47
47
  }
48
48
  _chunkJ5CFUN4Vjs.__name.call(void 0, errorHandler, "errorHandler");
49
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkSW5IKE5Hjs.BadRequestException)("data format should be an array"));
49
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkGSPBHZBHjs.BadRequestException)("data format should be an array"));
50
50
  try {
51
51
  return Promise.all(body.map((item, i) => {
52
52
  return new Promise(async (resolve) => {
53
53
  const { tag, func } = item;
54
54
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
55
- if (!metaMap.has(tag)) return resolve(await _chunkSW5IKE5Hjs.Context.filterRecord.default(new (0, _chunkSW5IKE5Hjs.BadRequestException)(`module "${tag}" doesn't exist`)));
55
+ if (!metaMap.has(tag)) return resolve(await _chunkGSPBHZBHjs.Context.filterRecord.default(new (0, _chunkGSPBHZBHjs.BadRequestException)(`module "${tag}" doesn't exist`)));
56
56
  const meta2 = metaMap.get(tag)[func];
57
- if (!meta2) return resolve(await _chunkSW5IKE5Hjs.Context.filterRecord.default(new (0, _chunkSW5IKE5Hjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
57
+ if (!meta2) return resolve(await _chunkGSPBHZBHjs.Context.filterRecord.default(new (0, _chunkGSPBHZBHjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
58
58
  const { data: { params } } = meta2;
59
- const aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
59
+ const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
60
60
  globalGuards,
61
61
  globalFilter,
62
62
  globalPipe
@@ -70,7 +70,7 @@ function bind(router, data, opts = {}) {
70
70
  parallel: true,
71
71
  next,
72
72
  app: router,
73
- ..._chunkSW5IKE5Hjs.argToReq.call(void 0, params, item.args, ctx.headers),
73
+ ..._chunkGSPBHZBHjs.argToReq.call(void 0, params, item.args, ctx.headers),
74
74
  tag,
75
75
  func,
76
76
  getCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
@@ -84,7 +84,7 @@ function bind(router, data, opts = {}) {
84
84
  getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => ctx.req, "getRequest"),
85
85
  getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => ctx.res, "getResponse")
86
86
  };
87
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
87
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
88
88
  context.run(aop, resolve, resolve);
89
89
  });
90
90
  })).then((ret) => {
@@ -103,14 +103,14 @@ function bind(router, data, opts = {}) {
103
103
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
104
104
  let aop;
105
105
  if (!dynamic) {
106
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
106
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
107
107
  globalFilter,
108
108
  globalGuards,
109
109
  globalPipe
110
110
  });
111
111
  }
112
112
  const subRouter = new (0, _router2.default)();
113
- _chunkSW5IKE5Hjs.Context.applyAddons(addons, subRouter, "koa");
113
+ _chunkGSPBHZBHjs.Context.applyAddons(addons, subRouter, "koa");
114
114
  router[http.type](http.prefix + http.route, async (ctx, next) => {
115
115
  debug(`invoke method "${func}" in module "${tag}"`);
116
116
  const contextData = {
@@ -137,10 +137,10 @@ function bind(router, data, opts = {}) {
137
137
  getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => ctx.req, "getRequest"),
138
138
  getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => ctx.res, "getResponse")
139
139
  };
140
- const context = new (0, _chunkSW5IKE5Hjs.Context)(contextData);
140
+ const context = new (0, _chunkGSPBHZBHjs.Context)(contextData);
141
141
  if (http.headers) ctx.set(http.headers);
142
142
  if (dynamic) {
143
- aop = _chunkSW5IKE5Hjs.Context.getAop(meta2, {
143
+ aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
144
144
  globalFilter,
145
145
  globalGuards,
146
146
  globalPipe
@@ -160,7 +160,7 @@ function bind(router, data, opts = {}) {
160
160
  }
161
161
  }
162
162
  _chunkJ5CFUN4Vjs.__name.call(void 0, registerRoute, "registerRoute");
163
- _chunkSW5IKE5Hjs.HMR.call(void 0, async () => {
163
+ _chunkGSPBHZBHjs.HMR.call(void 0, async () => {
164
164
  router.stack = originStack;
165
165
  registerRoute();
166
166
  });
@@ -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";
package/dist/index.d.mts CHANGED
@@ -138,7 +138,7 @@ declare class Context<Data extends BaseContext> {
138
138
  declare function addPipe<C extends BaseContext>(key: PropertyKey, pipe: PipeType<C>): void;
139
139
  declare function addFilter<C extends BaseContext>(key: PropertyKey, filter: FilterType<C>): void;
140
140
  declare function addGuard<C extends BaseContext>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
141
- declare function addAddon<T>(key: PropertyKey, addon: (router: any, framework: string) => T, priority?: number): void;
141
+ declare function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority?: number): void;
142
142
 
143
143
  declare class RPCGenerator extends Generator {
144
144
  name: string;
@@ -207,7 +207,7 @@ declare abstract class PFilter<C extends BaseContext = any, E extends Exception
207
207
  }
208
208
 
209
209
  declare abstract class PGuard<C extends BaseContext = any> extends ServerBase {
210
- abstract use(ctx: C): Promise<boolean> | boolean;
210
+ abstract use(ctx: C, next: () => Promise<any>): any;
211
211
  readonly key: PropertyKey;
212
212
  priority: number;
213
213
  constructor(tag?: string);
@@ -230,7 +230,7 @@ declare abstract class PAddon extends ServerBase {
230
230
  readonly key: PropertyKey;
231
231
  priority: number;
232
232
  constructor(tag?: string);
233
- abstract use<Addon = any>(framework: string): Addon | undefined;
233
+ abstract use(router: any, framework: string): undefined;
234
234
  }
235
235
 
236
236
  interface PExtension<C extends BaseContext = any, E extends Exception = Exception> {