phecda-server 8.4.1 → 8.5.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 (47) hide show
  1. package/dist/{chunk-RS6H6TEX.js → chunk-5ZZAOOKE.js} +26 -26
  2. package/dist/{chunk-R73A7HS3.js → chunk-76UDKZOJ.js} +53 -53
  3. package/dist/{chunk-OUQM7GZH.js → chunk-LLF55NZP.js} +14 -4
  4. package/dist/{chunk-3OKDXHO7.mjs → chunk-MUUKKO67.mjs} +1 -1
  5. package/dist/{chunk-SRPCXPAQ.js → chunk-SKGOTR4T.js} +20 -20
  6. package/dist/{chunk-JRNXLEAU.mjs → chunk-URKOYTBU.mjs} +14 -4
  7. package/dist/{chunk-US2DTB3Z.mjs → chunk-WST6E6MQ.mjs} +1 -1
  8. package/dist/{chunk-YDJAOLT2.mjs → chunk-ZHNYWZRL.mjs} +1 -1
  9. package/dist/helper.d.mts +2 -1
  10. package/dist/helper.d.ts +2 -1
  11. package/dist/helper.js +5 -3
  12. package/dist/helper.mjs +4 -2
  13. package/dist/http/elysia/index.js +45 -41
  14. package/dist/http/elysia/index.mjs +10 -6
  15. package/dist/http/express/index.js +38 -38
  16. package/dist/http/express/index.mjs +3 -3
  17. package/dist/http/fastify/index.js +39 -39
  18. package/dist/http/fastify/index.mjs +4 -4
  19. package/dist/http/h3/index.js +39 -39
  20. package/dist/http/h3/index.mjs +3 -3
  21. package/dist/http/hono/index.js +35 -35
  22. package/dist/http/hono/index.mjs +3 -3
  23. package/dist/http/hyper-express/index.js +36 -36
  24. package/dist/http/hyper-express/index.mjs +3 -3
  25. package/dist/http/koa/index.js +38 -38
  26. package/dist/http/koa/index.mjs +3 -3
  27. package/dist/index.d.mts +6 -6
  28. package/dist/index.d.ts +6 -6
  29. package/dist/index.js +65 -65
  30. package/dist/index.mjs +27 -27
  31. package/dist/rpc/bullmq/index.js +11 -11
  32. package/dist/rpc/bullmq/index.mjs +2 -2
  33. package/dist/rpc/electron/index.js +8 -8
  34. package/dist/rpc/electron/index.mjs +2 -2
  35. package/dist/rpc/kafka/index.js +10 -10
  36. package/dist/rpc/kafka/index.mjs +2 -2
  37. package/dist/rpc/nats/index.js +11 -11
  38. package/dist/rpc/nats/index.mjs +2 -2
  39. package/dist/rpc/rabbitmq/index.js +12 -12
  40. package/dist/rpc/rabbitmq/index.mjs +2 -2
  41. package/dist/rpc/redis/index.js +10 -10
  42. package/dist/rpc/redis/index.mjs +2 -2
  43. package/dist/rpc/ws/index.js +7 -7
  44. package/dist/rpc/ws/index.mjs +2 -2
  45. package/dist/test.js +6 -6
  46. package/dist/test.mjs +2 -2
  47. package/package.json +2 -2
@@ -3,10 +3,10 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkR73A7HS3js = require('../../chunk-R73A7HS3.js');
6
+ var _chunk76UDKZOJjs = require('../../chunk-76UDKZOJ.js');
7
7
 
8
8
 
9
- var _chunkOUQM7GZHjs = require('../../chunk-OUQM7GZH.js');
9
+ var _chunkLLF55NZPjs = require('../../chunk-LLF55NZP.js');
10
10
 
11
11
  // src/http/hono/bind.ts
12
12
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
@@ -14,16 +14,16 @@ var _hono = require('hono');
14
14
  var _cookie = require('hono/cookie');
15
15
  var debug = _debug2.default.call(void 0, "phecda-server/hono");
16
16
  function bind(router, data, opts = {}) {
17
- const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
17
+ const { globalGuards, parallelRoute, globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
18
18
  const { moduleMap, meta } = data;
19
- const metaMap = _chunkR73A7HS3js.createControllerMetaMap.call(void 0, meta, (meta2) => {
19
+ const metaMap = _chunk76UDKZOJjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
20
20
  const { controller, http, method, tag } = meta2.data;
21
21
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
22
22
  debug(`register method "${method}" in module "${tag}"`);
23
23
  return true;
24
24
  }
25
25
  });
26
- _chunkR73A7HS3js.detectAopDep.call(void 0, meta, {
26
+ _chunk76UDKZOJjs.detectAopDep.call(void 0, meta, {
27
27
  addons: [
28
28
  ...globalAddons,
29
29
  ...parallelAddons
@@ -34,26 +34,26 @@ function bind(router, data, opts = {}) {
34
34
  function registerRoute() {
35
35
  if (parallelRoute) {
36
36
  const subApp = new (0, _hono.Hono)();
37
- _chunkR73A7HS3js.Context.applyAddons(parallelAddons, subApp, "hono");
37
+ _chunk76UDKZOJjs.Context.applyAddons(parallelAddons, subApp, "hono");
38
38
  subApp.post("", async (c) => {
39
39
  const body = await c.req.json();
40
40
  async function errorHandler(e) {
41
- const error = await _chunkR73A7HS3js.Context.filterRecord.default(e);
41
+ const error = await _chunk76UDKZOJjs.Context.filterRecord.default(e);
42
42
  c.status(error.status);
43
43
  return c.json(error);
44
44
  }
45
- _chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
46
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkR73A7HS3js.BadRequestException)("data format should be an array"));
45
+ _chunkLLF55NZPjs.__name.call(void 0, errorHandler, "errorHandler");
46
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunk76UDKZOJjs.BadRequestException)("data format should be an array"));
47
47
  try {
48
48
  return Promise.all(body.map((item, i) => {
49
49
  return new Promise(async (resolve) => {
50
50
  if (!item) return resolve(null);
51
51
  const { tag, method } = item;
52
52
  debug(`(parallel)invoke method "${method}" in module "${tag}"`);
53
- if (!metaMap.has(tag)) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`module "${tag}" doesn't exist`)));
53
+ if (!metaMap.has(tag)) return resolve(await _chunk76UDKZOJjs.Context.filterRecord.default(new (0, _chunk76UDKZOJjs.BadRequestException)(`module "${tag}" doesn't exist`)));
54
54
  const meta2 = metaMap.get(tag)[method];
55
- if (!meta2) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
56
- const aop = _chunkR73A7HS3js.Context.getAop(meta2, {
55
+ if (!meta2) return resolve(await _chunk76UDKZOJjs.Context.filterRecord.default(new (0, _chunk76UDKZOJjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
56
+ const aop = _chunk76UDKZOJjs.Context.getAop(meta2, {
57
57
  globalFilter,
58
58
  globalGuards,
59
59
  globalPipe
@@ -68,18 +68,18 @@ function bind(router, data, opts = {}) {
68
68
  moduleMap,
69
69
  app: router,
70
70
  ...item,
71
- getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
72
- delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
73
- setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
74
- redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
75
- setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => {
71
+ getCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
72
+ delCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
73
+ setCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
74
+ redirect: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
75
+ setResHeaders: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (headers) => {
76
76
  for (const name in headers) c.header(name, headers[name]);
77
77
  }, "setResHeaders"),
78
- setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
79
- getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => c.req.raw, "getRequest"),
80
- getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => c.res, "getResponse")
78
+ setResStatus: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
79
+ getRequest: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, () => c.req.raw, "getRequest"),
80
+ getResponse: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, () => c.res, "getResponse")
81
81
  };
82
- const context = new (0, _chunkR73A7HS3js.Context)(contextData);
82
+ const context = new (0, _chunk76UDKZOJjs.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 = _chunkR73A7HS3js.Context.getAop(meta2, {
102
+ aop = _chunk76UDKZOJjs.Context.getAop(meta2, {
103
103
  globalFilter,
104
104
  globalGuards,
105
105
  globalPipe
106
106
  });
107
107
  }
108
108
  const subApp = new (0, _hono.Hono)();
109
- _chunkR73A7HS3js.Context.applyAddons(addons, subApp, "hono");
109
+ _chunk76UDKZOJjs.Context.applyAddons(addons, subApp, "hono");
110
110
  subApp[http.method](http.route, async (c) => {
111
111
  debug(`invoke method "${method}" in module "${tag}"`);
112
112
  const contextData = {
@@ -122,23 +122,23 @@ function bind(router, data, opts = {}) {
122
122
  params: c.req.param(),
123
123
  headers: c.req.header(),
124
124
  app: router,
125
- getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
126
- delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
127
- setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
128
- redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
129
- setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => {
125
+ getCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
126
+ delCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
127
+ setCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
128
+ redirect: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
129
+ setResHeaders: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (headers) => {
130
130
  for (const name in headers) c.header(name, headers[name]);
131
131
  }, "setResHeaders"),
132
- setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
133
- getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => c.req.raw, "getRequest"),
134
- getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => c.res, "getResponse")
132
+ setResStatus: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
133
+ getRequest: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, () => c.req.raw, "getRequest"),
134
+ getResponse: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, () => c.res, "getResponse")
135
135
  };
136
- const context = new (0, _chunkR73A7HS3js.Context)(contextData);
136
+ const context = new (0, _chunk76UDKZOJjs.Context)(contextData);
137
137
  if (http.headers) {
138
138
  for (const name in http.headers) c.header(name, http.headers[name]);
139
139
  }
140
140
  if (dynamic) {
141
- aop = _chunkR73A7HS3js.Context.getAop(meta2, {
141
+ aop = _chunk76UDKZOJjs.Context.getAop(meta2, {
142
142
  globalFilter,
143
143
  globalGuards,
144
144
  globalPipe
@@ -157,9 +157,9 @@ function bind(router, data, opts = {}) {
157
157
  }
158
158
  }
159
159
  }
160
- _chunkOUQM7GZHjs.__name.call(void 0, registerRoute, "registerRoute");
160
+ _chunkLLF55NZPjs.__name.call(void 0, registerRoute, "registerRoute");
161
161
  }
162
- _chunkOUQM7GZHjs.__name.call(void 0, bind, "bind");
162
+ _chunkLLF55NZPjs.__name.call(void 0, bind, "bind");
163
163
 
164
164
 
165
165
  exports.bind = bind;
@@ -3,10 +3,10 @@ import {
3
3
  Context,
4
4
  createControllerMetaMap,
5
5
  detectAopDep
6
- } from "../../chunk-US2DTB3Z.mjs";
6
+ } from "../../chunk-WST6E6MQ.mjs";
7
7
  import {
8
8
  __name
9
- } from "../../chunk-JRNXLEAU.mjs";
9
+ } from "../../chunk-URKOYTBU.mjs";
10
10
 
11
11
  // src/http/hono/bind.ts
12
12
  import Debug from "debug";
@@ -14,7 +14,7 @@ import { Hono } from "hono";
14
14
  import { deleteCookie, getCookie, setCookie } from "hono/cookie";
15
15
  var debug = Debug("phecda-server/hono");
16
16
  function bind(router, data, opts = {}) {
17
- const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
17
+ const { globalGuards, parallelRoute, globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
18
18
  const { moduleMap, meta } = data;
19
19
  const metaMap = createControllerMetaMap(meta, (meta2) => {
20
20
  const { controller, http, method, tag } = meta2.data;
@@ -4,26 +4,26 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkR73A7HS3js = require('../../chunk-R73A7HS3.js');
7
+ var _chunk76UDKZOJjs = require('../../chunk-76UDKZOJ.js');
8
8
 
9
9
 
10
- var _chunkOUQM7GZHjs = require('../../chunk-OUQM7GZH.js');
10
+ var _chunkLLF55NZPjs = require('../../chunk-LLF55NZP.js');
11
11
 
12
12
  // src/http/hyper-express/bind.ts
13
13
  var _hyperexpress = require('hyper-express');
14
14
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
15
15
  var debug = _debug2.default.call(void 0, "phecda-server/hyper-express");
16
16
  function bind(router, data, opts = {}) {
17
- const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
17
+ const { globalGuards, parallelRoute, globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
18
18
  const { moduleMap, meta } = data;
19
- const metaMap = _chunkR73A7HS3js.createControllerMetaMap.call(void 0, meta, (meta2) => {
19
+ const metaMap = _chunk76UDKZOJjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
20
20
  const { controller, http, method, tag } = meta2.data;
21
21
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
22
22
  debug(`register method "${method}" in module "${tag}"`);
23
23
  return true;
24
24
  }
25
25
  });
26
- _chunkR73A7HS3js.detectAopDep.call(void 0, meta, {
26
+ _chunk76UDKZOJjs.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
- _chunkR73A7HS3js.Context.applyAddons(globalAddons, router, "hyper-express");
35
+ _chunk76UDKZOJjs.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 _chunkR73A7HS3js.Context.filterRecord.default(e);
41
+ const error = await _chunk76UDKZOJjs.Context.filterRecord.default(e);
42
42
  return res.status(error.status).json(error);
43
43
  }
44
- _chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
45
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkR73A7HS3js.BadRequestException)("data format should be an array"));
44
+ _chunkLLF55NZPjs.__name.call(void 0, errorHandler, "errorHandler");
45
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunk76UDKZOJjs.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
  if (!item) return resolve(null);
50
50
  const { tag, method } = item;
51
51
  debug(`(parallel)invoke method "${method}" in module "${tag}"`);
52
- if (!metaMap.has(tag)) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`module "${tag}" doesn't exist`)));
52
+ if (!metaMap.has(tag)) return resolve(await _chunk76UDKZOJjs.Context.filterRecord.default(new (0, _chunk76UDKZOJjs.BadRequestException)(`module "${tag}" doesn't exist`)));
53
53
  const meta2 = metaMap.get(tag)[method];
54
- if (!meta2) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
55
- const aop = _chunkR73A7HS3js.Context.getAop(meta2, {
54
+ if (!meta2) return resolve(await _chunk76UDKZOJjs.Context.filterRecord.default(new (0, _chunk76UDKZOJjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
55
+ const aop = _chunk76UDKZOJjs.Context.getAop(meta2, {
56
56
  globalFilter,
57
57
  globalGuards,
58
58
  globalPipe
@@ -69,16 +69,16 @@ function bind(router, data, opts = {}) {
69
69
  app: router,
70
70
  ...item,
71
71
  next,
72
- getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
73
- setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _2 => _2.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
74
- delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
75
- redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
76
- setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
77
- setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
78
- getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => req, "getRequest"),
79
- getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => res, "getResponse")
72
+ getCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
73
+ setCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _2 => _2.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
74
+ delCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
75
+ redirect: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
76
+ setResHeaders: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
77
+ setResStatus: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
78
+ getRequest: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, () => req, "getRequest"),
79
+ getResponse: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, () => res, "getResponse")
80
80
  };
81
- const context = new (0, _chunkR73A7HS3js.Context)(contextData);
81
+ const context = new (0, _chunk76UDKZOJjs.Context)(contextData);
82
82
  context.run(aop, resolve, resolve);
83
83
  });
84
84
  })).then((ret) => {
@@ -98,15 +98,15 @@ function bind(router, data, opts = {}) {
98
98
  const needBody = params.some((item) => item.type === "body");
99
99
  let aop;
100
100
  if (!dynamic) {
101
- aop = _chunkR73A7HS3js.Context.getAop(meta2, {
101
+ aop = _chunk76UDKZOJjs.Context.getAop(meta2, {
102
102
  globalFilter,
103
103
  globalGuards,
104
104
  globalPipe
105
105
  });
106
106
  }
107
107
  const subRouter = new (0, _hyperexpress.Router)();
108
- _chunkR73A7HS3js.Context.applyAddons(addons, subRouter, "hyper-express");
109
- subRouter[http.method](_chunkR73A7HS3js.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
108
+ _chunk76UDKZOJjs.Context.applyAddons(addons, subRouter, "hyper-express");
109
+ subRouter[http.method](_chunk76UDKZOJjs.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
110
110
  debug(`invoke method "${method}" in module "${tag}"`);
111
111
  const contextData = {
112
112
  type: "hyper-express",
@@ -123,21 +123,21 @@ function bind(router, data, opts = {}) {
123
123
  params: req.path_parameters,
124
124
  headers: req.headers,
125
125
  next,
126
- getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
127
- setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _4 => _4.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
128
- delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
129
- redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
130
- setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
131
- setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
132
- getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => req, "getRequest"),
133
- getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => res, "getResponse")
126
+ getCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
127
+ setCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _4 => _4.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
128
+ delCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
129
+ redirect: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
130
+ setResHeaders: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
131
+ setResStatus: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
132
+ getRequest: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, () => req, "getRequest"),
133
+ getResponse: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, () => res, "getResponse")
134
134
  };
135
- const context = new (0, _chunkR73A7HS3js.Context)(contextData);
135
+ const context = new (0, _chunk76UDKZOJjs.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 = _chunkR73A7HS3js.Context.getAop(meta2, {
140
+ aop = _chunk76UDKZOJjs.Context.getAop(meta2, {
141
141
  globalFilter,
142
142
  globalGuards,
143
143
  globalPipe
@@ -156,9 +156,9 @@ function bind(router, data, opts = {}) {
156
156
  }
157
157
  }
158
158
  }
159
- _chunkOUQM7GZHjs.__name.call(void 0, registerRoute, "registerRoute");
159
+ _chunkLLF55NZPjs.__name.call(void 0, registerRoute, "registerRoute");
160
160
  }
161
- _chunkOUQM7GZHjs.__name.call(void 0, bind, "bind");
161
+ _chunkLLF55NZPjs.__name.call(void 0, bind, "bind");
162
162
 
163
163
 
164
164
  exports.bind = bind;
@@ -4,17 +4,17 @@ import {
4
4
  createControllerMetaMap,
5
5
  detectAopDep,
6
6
  joinUrl
7
- } from "../../chunk-US2DTB3Z.mjs";
7
+ } from "../../chunk-WST6E6MQ.mjs";
8
8
  import {
9
9
  __name
10
- } from "../../chunk-JRNXLEAU.mjs";
10
+ } from "../../chunk-URKOYTBU.mjs";
11
11
 
12
12
  // src/http/hyper-express/bind.ts
13
13
  import { Router } from "hyper-express";
14
14
  import Debug from "debug";
15
15
  var debug = Debug("phecda-server/hyper-express");
16
16
  function bind(router, data, opts = {}) {
17
- const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
17
+ const { globalGuards, parallelRoute, globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
18
18
  const { moduleMap, meta } = data;
19
19
  const metaMap = createControllerMetaMap(meta, (meta2) => {
20
20
  const { controller, http, method, tag } = meta2.data;
@@ -4,28 +4,28 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkR73A7HS3js = require('../../chunk-R73A7HS3.js');
7
+ var _chunk76UDKZOJjs = require('../../chunk-76UDKZOJ.js');
8
8
 
9
9
 
10
10
 
11
- var _chunkOUQM7GZHjs = require('../../chunk-OUQM7GZH.js');
11
+ var _chunkLLF55NZPjs = require('../../chunk-LLF55NZP.js');
12
12
 
13
13
  // src/http/koa/bind.ts
14
14
  var _router = require('@koa/router'); var _router2 = _interopRequireDefault(_router);
15
15
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
16
16
  var debug = _debug2.default.call(void 0, "phecda-server/koa");
17
17
  function bind(router, data, opts = {}) {
18
- const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
18
+ const { globalGuards, parallelRoute, 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 = _chunkR73A7HS3js.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
+ const metaMap = _chunk76UDKZOJjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
22
  const { controller, http, method, tag } = meta2.data;
23
23
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
24
24
  debug(`register method "${method}" in module "${tag}"`);
25
25
  return true;
26
26
  }
27
27
  });
28
- _chunkR73A7HS3js.detectAopDep.call(void 0, meta, {
28
+ _chunk76UDKZOJjs.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
- _chunkR73A7HS3js.Context.applyAddons(globalAddons, router, "koa");
37
+ _chunk76UDKZOJjs.Context.applyAddons(globalAddons, router, "koa");
38
38
  if (parallelRoute) {
39
39
  const subRouter = new (0, _router2.default)();
40
- _chunkR73A7HS3js.Context.applyAddons(parallelAddons, subRouter, "koa");
40
+ _chunk76UDKZOJjs.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 _chunkR73A7HS3js.Context.filterRecord.default(e);
44
+ const error = await _chunk76UDKZOJjs.Context.filterRecord.default(e);
45
45
  ctx.status = error.status;
46
46
  ctx.body = error;
47
47
  }
48
- _chunkOUQM7GZHjs.__name.call(void 0, errorHandler, "errorHandler");
49
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkR73A7HS3js.BadRequestException)("data format should be an array"));
48
+ _chunkLLF55NZPjs.__name.call(void 0, errorHandler, "errorHandler");
49
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunk76UDKZOJjs.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
  if (!item) return resolve(null);
54
54
  const { tag, method } = item;
55
55
  debug(`(parallel)invoke method "${method}" in module "${tag}"`);
56
- if (!metaMap.has(tag)) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`module "${tag}" doesn't exist`)));
56
+ if (!metaMap.has(tag)) return resolve(await _chunk76UDKZOJjs.Context.filterRecord.default(new (0, _chunk76UDKZOJjs.BadRequestException)(`module "${tag}" doesn't exist`)));
57
57
  const meta2 = metaMap.get(tag)[method];
58
- if (!meta2) return resolve(await _chunkR73A7HS3js.Context.filterRecord.default(new (0, _chunkR73A7HS3js.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
59
- const aop = _chunkR73A7HS3js.Context.getAop(meta2, {
58
+ if (!meta2) return resolve(await _chunk76UDKZOJjs.Context.filterRecord.default(new (0, _chunk76UDKZOJjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
59
+ const aop = _chunk76UDKZOJjs.Context.getAop(meta2, {
60
60
  globalGuards,
61
61
  globalFilter,
62
62
  globalPipe
@@ -72,18 +72,18 @@ function bind(router, data, opts = {}) {
72
72
  next,
73
73
  app: router,
74
74
  ...item,
75
- getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
76
- setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
77
- delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
75
+ getCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
76
+ setCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
77
+ delCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
78
78
  expires: /* @__PURE__ */ new Date(0)
79
79
  }), "delCookie"),
80
- redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
81
- setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
82
- setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
83
- getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => ctx.req, "getRequest"),
84
- getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => ctx.res, "getResponse")
80
+ redirect: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
81
+ setResHeaders: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
82
+ setResStatus: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
83
+ getRequest: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, () => ctx.req, "getRequest"),
84
+ getResponse: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, () => ctx.res, "getResponse")
85
85
  };
86
- const context = new (0, _chunkR73A7HS3js.Context)(contextData);
86
+ const context = new (0, _chunk76UDKZOJjs.Context)(contextData);
87
87
  context.run(aop, resolve, resolve);
88
88
  });
89
89
  })).then((ret) => {
@@ -102,15 +102,15 @@ function bind(router, data, opts = {}) {
102
102
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.method])) continue;
103
103
  let aop;
104
104
  if (!dynamic) {
105
- aop = _chunkR73A7HS3js.Context.getAop(meta2, {
105
+ aop = _chunk76UDKZOJjs.Context.getAop(meta2, {
106
106
  globalFilter,
107
107
  globalGuards,
108
108
  globalPipe
109
109
  });
110
110
  }
111
111
  const subRouter = new (0, _router2.default)();
112
- _chunkR73A7HS3js.Context.applyAddons(addons, subRouter, "koa");
113
- router[http.method](_chunkR73A7HS3js.joinUrl.call(void 0, http.prefix, http.route), async (ctx, next) => {
112
+ _chunk76UDKZOJjs.Context.applyAddons(addons, subRouter, "koa");
113
+ router[http.method](_chunk76UDKZOJjs.joinUrl.call(void 0, http.prefix, http.route), async (ctx, next) => {
114
114
  debug(`invoke method "${method}" in module "${tag}"`);
115
115
  const contextData = {
116
116
  type: "koa",
@@ -126,21 +126,21 @@ function bind(router, data, opts = {}) {
126
126
  body: ctx.request.body,
127
127
  headers: ctx.headers,
128
128
  next,
129
- getCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
130
- setCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
131
- delCookie: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
129
+ getCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
130
+ setCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
131
+ delCookie: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
132
132
  expires: /* @__PURE__ */ new Date(0)
133
133
  }), "delCookie"),
134
- redirect: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
135
- setResHeaders: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
136
- setResStatus: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
137
- getRequest: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => ctx.req, "getRequest"),
138
- getResponse: /* @__PURE__ */ _chunkOUQM7GZHjs.__name.call(void 0, () => ctx.res, "getResponse")
134
+ redirect: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
135
+ setResHeaders: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
136
+ setResStatus: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
137
+ getRequest: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, () => ctx.req, "getRequest"),
138
+ getResponse: /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, () => ctx.res, "getResponse")
139
139
  };
140
- const context = new (0, _chunkR73A7HS3js.Context)(contextData);
140
+ const context = new (0, _chunk76UDKZOJjs.Context)(contextData);
141
141
  if (http.headers) ctx.set(http.headers);
142
142
  if (dynamic) {
143
- aop = _chunkR73A7HS3js.Context.getAop(meta2, {
143
+ aop = _chunk76UDKZOJjs.Context.getAop(meta2, {
144
144
  globalFilter,
145
145
  globalGuards,
146
146
  globalPipe
@@ -159,13 +159,13 @@ function bind(router, data, opts = {}) {
159
159
  }
160
160
  }
161
161
  }
162
- _chunkOUQM7GZHjs.__name.call(void 0, registerRoute, "registerRoute");
163
- _chunkOUQM7GZHjs.HMR.call(void 0, async () => {
162
+ _chunkLLF55NZPjs.__name.call(void 0, registerRoute, "registerRoute");
163
+ _chunkLLF55NZPjs.HMR.call(void 0, async () => {
164
164
  router.stack = originStack;
165
165
  registerRoute();
166
166
  });
167
167
  }
168
- _chunkOUQM7GZHjs.__name.call(void 0, bind, "bind");
168
+ _chunkLLF55NZPjs.__name.call(void 0, bind, "bind");
169
169
 
170
170
 
171
171
  exports.bind = bind;
@@ -4,18 +4,18 @@ import {
4
4
  createControllerMetaMap,
5
5
  detectAopDep,
6
6
  joinUrl
7
- } from "../../chunk-US2DTB3Z.mjs";
7
+ } from "../../chunk-WST6E6MQ.mjs";
8
8
  import {
9
9
  HMR,
10
10
  __name
11
- } from "../../chunk-JRNXLEAU.mjs";
11
+ } from "../../chunk-URKOYTBU.mjs";
12
12
 
13
13
  // src/http/koa/bind.ts
14
14
  import Router from "@koa/router";
15
15
  import Debug from "debug";
16
16
  var debug = Debug("phecda-server/koa");
17
17
  function bind(router, data, opts = {}) {
18
- const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
18
+ const { globalGuards, parallelRoute, 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
21
  const metaMap = createControllerMetaMap(meta, (meta2) => {
package/dist/index.d.mts CHANGED
@@ -303,20 +303,20 @@ declare class RpcBase<Ctx extends RpcCtx = RpcCtx> extends ServerBase {
303
303
 
304
304
  declare abstract class PFilter<Ctx extends BaseCtx = any, E extends Exception = Exception> extends ServerBase {
305
305
  readonly key: PropertyKey;
306
- constructor(tag?: string);
306
+ init(): Promise<void>;
307
307
  abstract use(error: Error | E, ctx?: Ctx): BaseError;
308
308
  }
309
309
 
310
310
  declare abstract class PGuard<Ctx extends BaseCtx = any> extends ServerBase {
311
- abstract use(ctx: Ctx, next: () => Promise<any>): any;
312
311
  readonly key: PropertyKey;
313
312
  priority: number;
314
- constructor(tag?: string);
313
+ init(): Promise<void>;
314
+ abstract use(ctx: Ctx, next: () => Promise<any>): any;
315
315
  }
316
316
 
317
317
  declare abstract class PPipe<Ctx extends BaseCtx = any> extends ServerBase {
318
318
  readonly key: PropertyKey;
319
- constructor(tag?: string);
319
+ init(): Promise<void>;
320
320
  abstract use(param: {
321
321
  arg: any;
322
322
  option?: any;
@@ -330,7 +330,7 @@ declare abstract class PPipe<Ctx extends BaseCtx = any> extends ServerBase {
330
330
  declare abstract class PAddon extends ServerBase {
331
331
  readonly key: PropertyKey;
332
332
  priority: number;
333
- constructor(tag?: string);
333
+ init(): Promise<void>;
334
334
  abstract use(router: any, framework: string): undefined;
335
335
  }
336
336
 
@@ -351,7 +351,7 @@ declare class PExtension extends ServerBase {
351
351
  readonly key: PropertyKey;
352
352
  guardPriority: number;
353
353
  addonPriority: number;
354
- constructor(tag?: string);
354
+ protected init(): Promise<void>;
355
355
  }
356
356
 
357
357
  declare const defaultFilter: FilterType;