phecda-server 6.0.0 → 6.0.2

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 (71) hide show
  1. package/dist/{chunk-TZYATAJX.js → chunk-7SYPUIBY.js} +2 -5
  2. package/dist/{chunk-2UTKBEZE.mjs → chunk-F3W3NN7F.mjs} +5 -0
  3. package/dist/{chunk-YUXERDQ6.mjs → chunk-WXFZZZRY.mjs} +8 -11
  4. package/dist/{chunk-PALEEADE.js → chunk-XCND2QW3.js} +6 -1
  5. package/dist/{core-Blq8frmr.d.ts → core-2SNw8m2B.d.mts} +1 -1
  6. package/dist/{core-D2oL8Ge0.d.mts → core-BmJJLUqj.d.ts} +1 -1
  7. package/dist/helper.d.mts +1 -1
  8. package/dist/helper.d.ts +1 -1
  9. package/dist/helper.js +2 -2
  10. package/dist/helper.mjs +1 -1
  11. package/dist/index.d.mts +10 -9
  12. package/dist/index.d.ts +10 -9
  13. package/dist/index.js +28 -26
  14. package/dist/index.mjs +12 -10
  15. package/dist/{types-BlIBlnVT.d.mts → meta-KtfiBIde.d.mts} +44 -44
  16. package/dist/{types-BlIBlnVT.d.ts → meta-KtfiBIde.d.ts} +44 -44
  17. package/dist/rpc/bullmq/index.d.mts +3 -3
  18. package/dist/rpc/bullmq/index.d.ts +3 -3
  19. package/dist/rpc/bullmq/index.js +6 -6
  20. package/dist/rpc/bullmq/index.mjs +1 -1
  21. package/dist/rpc/kafka/index.d.mts +3 -3
  22. package/dist/rpc/kafka/index.d.ts +3 -3
  23. package/dist/rpc/kafka/index.js +5 -5
  24. package/dist/rpc/kafka/index.mjs +1 -1
  25. package/dist/rpc/nats/index.d.mts +3 -3
  26. package/dist/rpc/nats/index.d.ts +3 -3
  27. package/dist/rpc/nats/index.js +5 -5
  28. package/dist/rpc/nats/index.mjs +1 -1
  29. package/dist/rpc/rabbitmq/index.d.mts +3 -3
  30. package/dist/rpc/rabbitmq/index.d.ts +3 -3
  31. package/dist/rpc/rabbitmq/index.js +6 -6
  32. package/dist/rpc/rabbitmq/index.mjs +1 -1
  33. package/dist/rpc/redis/index.d.mts +3 -3
  34. package/dist/rpc/redis/index.d.ts +3 -3
  35. package/dist/rpc/redis/index.js +6 -6
  36. package/dist/rpc/redis/index.mjs +1 -1
  37. package/dist/server/elysia/index.d.mts +3 -3
  38. package/dist/server/elysia/index.d.ts +3 -3
  39. package/dist/server/elysia/index.js +29 -17
  40. package/dist/server/elysia/index.mjs +16 -4
  41. package/dist/server/express/index.d.mts +3 -3
  42. package/dist/server/express/index.d.ts +3 -3
  43. package/dist/server/express/index.js +20 -16
  44. package/dist/server/express/index.mjs +7 -3
  45. package/dist/server/fastify/index.d.mts +3 -3
  46. package/dist/server/fastify/index.d.ts +3 -3
  47. package/dist/server/fastify/index.js +21 -17
  48. package/dist/server/fastify/index.mjs +8 -4
  49. package/dist/server/h3/index.d.mts +3 -3
  50. package/dist/server/h3/index.d.ts +3 -3
  51. package/dist/server/h3/index.js +18 -14
  52. package/dist/server/h3/index.mjs +7 -3
  53. package/dist/server/hono/index.d.mts +3 -3
  54. package/dist/server/hono/index.d.ts +3 -3
  55. package/dist/server/hono/index.js +19 -15
  56. package/dist/server/hono/index.mjs +7 -3
  57. package/dist/server/hyper-express/index.d.mts +3 -3
  58. package/dist/server/hyper-express/index.d.ts +3 -3
  59. package/dist/server/hyper-express/index.js +19 -15
  60. package/dist/server/hyper-express/index.mjs +7 -3
  61. package/dist/server/koa/index.d.mts +3 -3
  62. package/dist/server/koa/index.d.ts +3 -3
  63. package/dist/server/koa/index.js +20 -16
  64. package/dist/server/koa/index.mjs +7 -3
  65. package/dist/test.d.mts +3 -3
  66. package/dist/test.d.ts +3 -3
  67. package/dist/{types-Dgxirc9f.d.mts → types-BvD3B5Ny.d.mts} +4 -2
  68. package/dist/{types-BCJhmpQh.d.ts → types-DIw7B6Up.d.ts} +4 -2
  69. package/dist/{types-B-ZFZajI.d.ts → types-JVT0mgLD.d.ts} +1 -1
  70. package/dist/{types-AgVwUXPC.d.mts → types-t9D1fU6G.d.mts} +1 -1
  71. package/package.json +1 -1
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkTZYATAJXjs = require('../../chunk-TZYATAJX.js');
7
+ var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
8
8
 
9
9
 
10
10
  var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hono");
16
16
  function bind(router, data, opts = {}) {
17
17
  const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
18
18
  const { moduleMap, meta } = data;
19
- const metaMap = _chunkTZYATAJXjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
19
+ const metaMap = _chunk7SYPUIBYjs.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
- _chunkTZYATAJXjs.detectAopDep.call(void 0, meta, {
26
+ _chunk7SYPUIBYjs.detectAopDep.call(void 0, meta, {
27
27
  plugins: [
28
28
  ...globalPlugins,
29
29
  ...parallelPlugins
@@ -33,25 +33,25 @@ function bind(router, data, opts = {}) {
33
33
  });
34
34
  registerRoute();
35
35
  async function registerRoute() {
36
- _chunkTZYATAJXjs.Context.usePlugin(globalPlugins, "hono").forEach((p) => router.use(p));
36
+ _chunk7SYPUIBYjs.Context.usePlugin(globalPlugins, "hono").forEach((p) => router.use(p));
37
37
  if (parallelRoute) {
38
- router.post(parallelRoute, ..._chunkTZYATAJXjs.Context.usePlugin(parallelPlugins, "hono"), async (c) => {
38
+ router.post(parallelRoute, ..._chunk7SYPUIBYjs.Context.usePlugin(parallelPlugins, "hono"), async (c) => {
39
39
  const body = await c.req.json();
40
40
  async function errorHandler(e) {
41
- const error = await _chunkTZYATAJXjs.Context.filterRecord.default(e);
41
+ const error = await _chunk7SYPUIBYjs.Context.filterRecord.default(e);
42
42
  c.status(error.status);
43
43
  return c.json(error);
44
44
  }
45
45
  _chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
46
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkTZYATAJXjs.BadRequestException)("data format should be an array"));
46
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunk7SYPUIBYjs.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
  const { tag, func } = item;
51
51
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
52
- if (!metaMap.has(tag)) return resolve(await _chunkTZYATAJXjs.Context.filterRecord.default(new (0, _chunkTZYATAJXjs.BadRequestException)(`module "${tag}" doesn't exist`)));
52
+ if (!metaMap.has(tag)) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`module "${tag}" doesn't exist`)));
53
53
  const meta2 = metaMap.get(tag)[func];
54
- if (!meta2) return resolve(await _chunkTZYATAJXjs.Context.filterRecord.default(new (0, _chunkTZYATAJXjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
54
+ if (!meta2) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
55
55
  const { data: { params } } = meta2;
56
56
  const contextData = {
57
57
  type: "hono",
@@ -63,7 +63,7 @@ function bind(router, data, opts = {}) {
63
63
  tag,
64
64
  func,
65
65
  app: router,
66
- ..._chunkTZYATAJXjs.argToReq.call(void 0, params, item.args, c.req.header()),
66
+ ..._chunk7SYPUIBYjs.argToReq.call(void 0, params, item.args, c.req.header()),
67
67
  getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
68
68
  delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
69
69
  setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
@@ -71,9 +71,11 @@ function bind(router, data, opts = {}) {
71
71
  setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => {
72
72
  for (const name in headers) c.header(name, headers[name]);
73
73
  }, "setResHeaders"),
74
- setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.status(status), "setResStatus")
74
+ setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
75
+ getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => c.req.raw, "getRequest"),
76
+ getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => c.res, "getResponse")
75
77
  };
76
- const context = new (0, _chunkTZYATAJXjs.Context)(contextData);
78
+ const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
77
79
  context.run({
78
80
  globalGuards,
79
81
  globalInterceptors,
@@ -95,7 +97,7 @@ function bind(router, data, opts = {}) {
95
97
  const { data: { params, plugins, http } } = meta2;
96
98
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
97
99
  const needBody = params.some((item) => item.type === "body");
98
- router[http.type](http.prefix + http.route, ..._chunkTZYATAJXjs.Context.usePlugin(plugins, "hono"), async (c) => {
100
+ router[http.type](http.prefix + http.route, ..._chunk7SYPUIBYjs.Context.usePlugin(plugins, "hono"), async (c) => {
99
101
  debug(`invoke method "${func}" in module "${tag}"`);
100
102
  const contextData = {
101
103
  type: "hono",
@@ -116,9 +118,11 @@ function bind(router, data, opts = {}) {
116
118
  setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => {
117
119
  for (const name in headers) c.header(name, headers[name]);
118
120
  }, "setResHeaders"),
119
- setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.status(status), "setResStatus")
121
+ setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => c.status(status), "setResStatus"),
122
+ getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => c.req.raw, "getRequest"),
123
+ getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => c.res, "getResponse")
120
124
  };
121
- const context = new (0, _chunkTZYATAJXjs.Context)(contextData);
125
+ const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
122
126
  if (http.headers) {
123
127
  for (const name in http.headers) c.header(name, http.headers[name]);
124
128
  }
@@ -4,7 +4,7 @@ import {
4
4
  argToReq,
5
5
  createControllerMetaMap,
6
6
  detectAopDep
7
- } from "../../chunk-YUXERDQ6.mjs";
7
+ } from "../../chunk-WXFZZZRY.mjs";
8
8
  import {
9
9
  __name
10
10
  } from "../../chunk-UXD62LGG.mjs";
@@ -71,7 +71,9 @@ function bind(router, data, opts = {}) {
71
71
  setResHeaders: /* @__PURE__ */ __name((headers) => {
72
72
  for (const name in headers) c.header(name, headers[name]);
73
73
  }, "setResHeaders"),
74
- setResStatus: /* @__PURE__ */ __name((status) => c.status(status), "setResStatus")
74
+ setResStatus: /* @__PURE__ */ __name((status) => c.status(status), "setResStatus"),
75
+ getRequest: /* @__PURE__ */ __name(() => c.req.raw, "getRequest"),
76
+ getResponse: /* @__PURE__ */ __name(() => c.res, "getResponse")
75
77
  };
76
78
  const context = new Context(contextData);
77
79
  context.run({
@@ -116,7 +118,9 @@ function bind(router, data, opts = {}) {
116
118
  setResHeaders: /* @__PURE__ */ __name((headers) => {
117
119
  for (const name in headers) c.header(name, headers[name]);
118
120
  }, "setResHeaders"),
119
- setResStatus: /* @__PURE__ */ __name((status) => c.status(status), "setResStatus")
121
+ setResStatus: /* @__PURE__ */ __name((status) => c.status(status), "setResStatus"),
122
+ getRequest: /* @__PURE__ */ __name(() => c.req.raw, "getRequest"),
123
+ getResponse: /* @__PURE__ */ __name(() => c.res, "getResponse")
120
124
  };
121
125
  const context = new Context(contextData);
122
126
  if (http.headers) {
@@ -1,8 +1,8 @@
1
1
  import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
2
- import { H as HttpContext, a as HttpOptions } from '../../types-Dgxirc9f.mjs';
3
- import { F as Factory } from '../../core-D2oL8Ge0.mjs';
2
+ import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
3
+ import { F as Factory } from '../../core-2SNw8m2B.mjs';
4
4
  import 'node:http';
5
- import '../../types-BlIBlnVT.mjs';
5
+ import '../../meta-KtfiBIde.mjs';
6
6
  import 'phecda-core';
7
7
 
8
8
  interface HyperExpressCtx extends HttpContext {
@@ -1,8 +1,8 @@
1
1
  import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
2
- import { H as HttpContext, a as HttpOptions } from '../../types-BCJhmpQh.js';
3
- import { F as Factory } from '../../core-Blq8frmr.js';
2
+ import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
3
+ import { F as Factory } from '../../core-BmJJLUqj.js';
4
4
  import 'node:http';
5
- import '../../types-BlIBlnVT.js';
5
+ import '../../meta-KtfiBIde.js';
6
6
  import 'phecda-core';
7
7
 
8
8
  interface HyperExpressCtx extends HttpContext {
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkTZYATAJXjs = require('../../chunk-TZYATAJX.js');
7
+ var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
8
8
 
9
9
 
10
10
  var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
@@ -15,14 +15,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hyper-express");
15
15
  function bind(router, data, opts = {}) {
16
16
  const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
17
17
  const { moduleMap, meta } = data;
18
- const metaMap = _chunkTZYATAJXjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
18
+ const metaMap = _chunk7SYPUIBYjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
19
19
  const { controller, http, func, tag } = meta2.data;
20
20
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
21
21
  debug(`register method "${func}" in module "${tag}"`);
22
22
  return true;
23
23
  }
24
24
  });
25
- _chunkTZYATAJXjs.detectAopDep.call(void 0, meta, {
25
+ _chunk7SYPUIBYjs.detectAopDep.call(void 0, meta, {
26
26
  plugins: [
27
27
  ...globalPlugins,
28
28
  ...parallelPlugins
@@ -32,26 +32,26 @@ function bind(router, data, opts = {}) {
32
32
  });
33
33
  registerRoute();
34
34
  async function registerRoute() {
35
- _chunkTZYATAJXjs.Context.usePlugin(globalPlugins, "hyper-express").forEach((p) => router.use(p));
35
+ _chunk7SYPUIBYjs.Context.usePlugin(globalPlugins, "hyper-express").forEach((p) => router.use(p));
36
36
  if (parallelRoute) {
37
37
  router.post(parallelRoute, {
38
- middlewares: _chunkTZYATAJXjs.Context.usePlugin(parallelPlugins, "hyper-express")
38
+ middlewares: _chunk7SYPUIBYjs.Context.usePlugin(parallelPlugins, "hyper-express")
39
39
  }, async (req, res, next) => {
40
40
  const body = await req.json();
41
41
  async function errorHandler(e) {
42
- const error = await _chunkTZYATAJXjs.Context.filterRecord.default(e);
42
+ const error = await _chunk7SYPUIBYjs.Context.filterRecord.default(e);
43
43
  return res.status(error.status).json(error);
44
44
  }
45
45
  _chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
46
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkTZYATAJXjs.BadRequestException)("data format should be an array"));
46
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunk7SYPUIBYjs.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
  const { tag, func } = item;
51
51
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
52
- if (!metaMap.has(tag)) return resolve(await _chunkTZYATAJXjs.Context.filterRecord.default(new (0, _chunkTZYATAJXjs.BadRequestException)(`module "${tag}" doesn't exist`)));
52
+ if (!metaMap.has(tag)) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`module "${tag}" doesn't exist`)));
53
53
  const meta2 = metaMap.get(tag)[func];
54
- if (!meta2) return resolve(await _chunkTZYATAJXjs.Context.filterRecord.default(new (0, _chunkTZYATAJXjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
54
+ if (!meta2) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
55
55
  const { data: { params } } = meta2;
56
56
  const contextData = {
57
57
  type: "hyper-express",
@@ -65,15 +65,17 @@ function bind(router, data, opts = {}) {
65
65
  func,
66
66
  next,
67
67
  app: router,
68
- ..._chunkTZYATAJXjs.argToReq.call(void 0, params, item.args, req.headers),
68
+ ..._chunk7SYPUIBYjs.argToReq.call(void 0, params, item.args, req.headers),
69
69
  getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
70
70
  setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _2 => _2.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
71
71
  delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
72
72
  redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
73
73
  setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
74
- setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
74
+ setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
75
+ getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => req, "getRequest"),
76
+ getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => res, "getResponse")
75
77
  };
76
- const context = new (0, _chunkTZYATAJXjs.Context)(contextData);
78
+ const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
77
79
  context.run({
78
80
  globalGuards,
79
81
  globalInterceptors,
@@ -95,7 +97,7 @@ function bind(router, data, opts = {}) {
95
97
  const { data: { params, plugins, http } } = meta2;
96
98
  if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
97
99
  const needBody = params.some((item) => item.type === "body");
98
- router[http.type](http.prefix + http.route, ..._chunkTZYATAJXjs.Context.usePlugin(plugins, "hyper-express"), async (req, res, next) => {
100
+ router[http.type](http.prefix + http.route, ..._chunk7SYPUIBYjs.Context.usePlugin(plugins, "hyper-express"), async (req, res, next) => {
99
101
  debug(`invoke method "${func}" in module "${tag}"`);
100
102
  const contextData = {
101
103
  type: "hyper-express",
@@ -116,9 +118,11 @@ function bind(router, data, opts = {}) {
116
118
  delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
117
119
  redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
118
120
  setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
119
- setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
121
+ setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
122
+ getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => req, "getRequest"),
123
+ getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => res, "getResponse")
120
124
  };
121
- const context = new (0, _chunkTZYATAJXjs.Context)(contextData);
125
+ const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
122
126
  if (http.headers) {
123
127
  for (const name in http.headers) res.set(name, http.headers[name]);
124
128
  }
@@ -4,7 +4,7 @@ import {
4
4
  argToReq,
5
5
  createControllerMetaMap,
6
6
  detectAopDep
7
- } from "../../chunk-YUXERDQ6.mjs";
7
+ } from "../../chunk-WXFZZZRY.mjs";
8
8
  import {
9
9
  __name
10
10
  } from "../../chunk-UXD62LGG.mjs";
@@ -71,7 +71,9 @@ function bind(router, data, opts = {}) {
71
71
  delCookie: /* @__PURE__ */ __name((key) => res.clearCookie(key), "delCookie"),
72
72
  redirect: /* @__PURE__ */ __name((url) => res.redirect(url), "redirect"),
73
73
  setResHeaders: /* @__PURE__ */ __name((headers) => res.set(headers), "setResHeaders"),
74
- setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus")
74
+ setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus"),
75
+ getRequest: /* @__PURE__ */ __name(() => req, "getRequest"),
76
+ getResponse: /* @__PURE__ */ __name(() => res, "getResponse")
75
77
  };
76
78
  const context = new Context(contextData);
77
79
  context.run({
@@ -116,7 +118,9 @@ function bind(router, data, opts = {}) {
116
118
  delCookie: /* @__PURE__ */ __name((key) => res.clearCookie(key), "delCookie"),
117
119
  redirect: /* @__PURE__ */ __name((url) => res.redirect(url), "redirect"),
118
120
  setResHeaders: /* @__PURE__ */ __name((headers) => res.set(headers), "setResHeaders"),
119
- setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus")
121
+ setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus"),
122
+ getRequest: /* @__PURE__ */ __name(() => req, "getRequest"),
123
+ getResponse: /* @__PURE__ */ __name(() => res, "getResponse")
120
124
  };
121
125
  const context = new Context(contextData);
122
126
  if (http.headers) {
@@ -1,9 +1,9 @@
1
1
  import Router, { RouterParamContext } from '@koa/router';
2
2
  import { DefaultContext, DefaultState } from 'koa';
3
- import { H as HttpContext, a as HttpOptions } from '../../types-Dgxirc9f.mjs';
4
- import { F as Factory } from '../../core-D2oL8Ge0.mjs';
3
+ import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
4
+ import { F as Factory } from '../../core-2SNw8m2B.mjs';
5
5
  import 'node:http';
6
- import '../../types-BlIBlnVT.mjs';
6
+ import '../../meta-KtfiBIde.mjs';
7
7
  import 'phecda-core';
8
8
 
9
9
  interface KoaCtx extends HttpContext {
@@ -1,9 +1,9 @@
1
1
  import Router, { RouterParamContext } from '@koa/router';
2
2
  import { DefaultContext, DefaultState } from 'koa';
3
- import { H as HttpContext, a as HttpOptions } from '../../types-BCJhmpQh.js';
4
- import { F as Factory } from '../../core-Blq8frmr.js';
3
+ import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
4
+ import { F as Factory } from '../../core-BmJJLUqj.js';
5
5
  import 'node:http';
6
- import '../../types-BlIBlnVT.js';
6
+ import '../../meta-KtfiBIde.js';
7
7
  import 'phecda-core';
8
8
 
9
9
  interface KoaCtx extends HttpContext {
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkTZYATAJXjs = require('../../chunk-TZYATAJX.js');
8
+ var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
9
9
 
10
10
 
11
11
  var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
@@ -17,14 +17,14 @@ function bind(router, data, opts = {}) {
17
17
  const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
18
18
  const { moduleMap, meta } = data;
19
19
  const originStack = router.stack.slice(0, router.stack.length);
20
- const metaMap = _chunkTZYATAJXjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
20
+ const metaMap = _chunk7SYPUIBYjs.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
- _chunkTZYATAJXjs.detectAopDep.call(void 0, meta, {
27
+ _chunk7SYPUIBYjs.detectAopDep.call(void 0, meta, {
28
28
  plugins: [
29
29
  ...globalPlugins,
30
30
  ...parallelPlugins
@@ -34,25 +34,25 @@ function bind(router, data, opts = {}) {
34
34
  });
35
35
  registerRoute();
36
36
  async function registerRoute() {
37
- _chunkTZYATAJXjs.Context.usePlugin(globalPlugins, "koa").forEach((p) => router.use(p));
37
+ _chunk7SYPUIBYjs.Context.usePlugin(globalPlugins, "koa").forEach((p) => router.use(p));
38
38
  if (parallelRoute) {
39
- router.post(parallelRoute, ..._chunkTZYATAJXjs.Context.usePlugin(parallelPlugins, "koa"), async (ctx, next) => {
39
+ router.post(parallelRoute, ..._chunk7SYPUIBYjs.Context.usePlugin(parallelPlugins, "koa"), async (ctx, next) => {
40
40
  const { body } = ctx.request;
41
41
  async function errorHandler(e) {
42
- const error = await _chunkTZYATAJXjs.Context.filterRecord.default(e);
42
+ const error = await _chunk7SYPUIBYjs.Context.filterRecord.default(e);
43
43
  ctx.status = error.status;
44
44
  ctx.body = error;
45
45
  }
46
46
  _chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
47
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkTZYATAJXjs.BadRequestException)("data format should be an array"));
47
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunk7SYPUIBYjs.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 _chunkTZYATAJXjs.Context.filterRecord.default(new (0, _chunkTZYATAJXjs.BadRequestException)(`module "${tag}" doesn't exist`)));
53
+ if (!metaMap.has(tag)) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`module "${tag}" doesn't exist`)));
54
54
  const meta2 = metaMap.get(tag)[func];
55
- if (!meta2) return resolve(await _chunkTZYATAJXjs.Context.filterRecord.default(new (0, _chunkTZYATAJXjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
55
+ if (!meta2) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
56
56
  const { data: { params } } = meta2;
57
57
  const contextData = {
58
58
  type: "koa",
@@ -63,7 +63,7 @@ function bind(router, data, opts = {}) {
63
63
  parallel: true,
64
64
  next,
65
65
  app: router,
66
- ..._chunkTZYATAJXjs.argToReq.call(void 0, params, item.args, ctx.headers),
66
+ ..._chunk7SYPUIBYjs.argToReq.call(void 0, params, item.args, ctx.headers),
67
67
  tag,
68
68
  func,
69
69
  getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
@@ -73,9 +73,11 @@ function bind(router, data, opts = {}) {
73
73
  }), "delCookie"),
74
74
  redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
75
75
  setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
76
- setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus")
76
+ setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
77
+ getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => ctx.req, "getRequest"),
78
+ getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => ctx.res, "getResponse")
77
79
  };
78
- const context = new (0, _chunkTZYATAJXjs.Context)(contextData);
80
+ const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
79
81
  context.run({
80
82
  globalGuards,
81
83
  globalInterceptors,
@@ -96,7 +98,7 @@ function bind(router, data, opts = {}) {
96
98
  const meta2 = metaMap.get(tag)[func];
97
99
  const { data: { plugins, http } } = meta2;
98
100
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
99
- router[http.type](http.prefix + http.route, ..._chunkTZYATAJXjs.Context.usePlugin(plugins, "koa"), async (ctx, next) => {
101
+ router[http.type](http.prefix + http.route, ..._chunk7SYPUIBYjs.Context.usePlugin(plugins, "koa"), async (ctx, next) => {
100
102
  debug(`invoke method "${func}" in module "${tag}"`);
101
103
  const contextData = {
102
104
  type: "koa",
@@ -118,9 +120,11 @@ function bind(router, data, opts = {}) {
118
120
  }), "delCookie"),
119
121
  redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
120
122
  setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
121
- setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus")
123
+ setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
124
+ getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => ctx.req, "getRequest"),
125
+ getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => ctx.res, "getResponse")
122
126
  };
123
- const context = new (0, _chunkTZYATAJXjs.Context)(contextData);
127
+ const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
124
128
  if (http.headers) ctx.set(http.headers);
125
129
  await context.run({
126
130
  globalGuards,
@@ -140,7 +144,7 @@ function bind(router, data, opts = {}) {
140
144
  }
141
145
  }
142
146
  _chunkGHFSIZUOjs.__name.call(void 0, registerRoute, "registerRoute");
143
- _chunkTZYATAJXjs.HMR.call(void 0, async () => {
147
+ _chunk7SYPUIBYjs.HMR.call(void 0, async () => {
144
148
  router.stack = originStack;
145
149
  registerRoute();
146
150
  });
@@ -5,7 +5,7 @@ import {
5
5
  argToReq,
6
6
  createControllerMetaMap,
7
7
  detectAopDep
8
- } from "../../chunk-YUXERDQ6.mjs";
8
+ } from "../../chunk-WXFZZZRY.mjs";
9
9
  import {
10
10
  __name
11
11
  } from "../../chunk-UXD62LGG.mjs";
@@ -73,7 +73,9 @@ function bind(router, data, opts = {}) {
73
73
  }), "delCookie"),
74
74
  redirect: /* @__PURE__ */ __name((url) => ctx.redirect(url), "redirect"),
75
75
  setResHeaders: /* @__PURE__ */ __name((headers) => ctx.set(headers), "setResHeaders"),
76
- setResStatus: /* @__PURE__ */ __name((status) => ctx.status = status, "setResStatus")
76
+ setResStatus: /* @__PURE__ */ __name((status) => ctx.status = status, "setResStatus"),
77
+ getRequest: /* @__PURE__ */ __name(() => ctx.req, "getRequest"),
78
+ getResponse: /* @__PURE__ */ __name(() => ctx.res, "getResponse")
77
79
  };
78
80
  const context = new Context(contextData);
79
81
  context.run({
@@ -118,7 +120,9 @@ function bind(router, data, opts = {}) {
118
120
  }), "delCookie"),
119
121
  redirect: /* @__PURE__ */ __name((url) => ctx.redirect(url), "redirect"),
120
122
  setResHeaders: /* @__PURE__ */ __name((headers) => ctx.set(headers), "setResHeaders"),
121
- setResStatus: /* @__PURE__ */ __name((status) => ctx.status = status, "setResStatus")
123
+ setResStatus: /* @__PURE__ */ __name((status) => ctx.status = status, "setResStatus"),
124
+ getRequest: /* @__PURE__ */ __name(() => ctx.req, "getRequest"),
125
+ getResponse: /* @__PURE__ */ __name(() => ctx.res, "getResponse")
122
126
  };
123
127
  const context = new Context(contextData);
124
128
  if (http.headers) ctx.set(http.headers);
package/dist/test.d.mts CHANGED
@@ -2,8 +2,8 @@ import * as supertest from 'supertest';
2
2
  import { Test } from 'supertest';
3
3
  import { Server } from 'node:http';
4
4
  import { Construct } from 'phecda-core';
5
- import { F as Factory } from './core-D2oL8Ge0.mjs';
6
- import { P as PickFunc } from './types-BlIBlnVT.mjs';
5
+ import { F as Factory } from './core-2SNw8m2B.mjs';
6
+ import { P as PickFunc } from './meta-KtfiBIde.mjs';
7
7
 
8
8
  declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
9
9
  get<C extends T[number]>(Model: C): InstanceType<C>;
@@ -11,7 +11,7 @@ declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
11
11
  type SuperTestRequest<T> = {
12
12
  [K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;
13
13
  };
14
- declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "use" | "on" | "set" | "query" | "type" | "accept" | "auth" | "withCredentials" | "retry" | "ok" | "redirects" | "timeout" | "buffer" | "serialize" | "parse" | "ca" | "key" | "pfx" | "cert"> & {
14
+ declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "type" | "key" | "query" | "use" | "on" | "set" | "accept" | "auth" | "withCredentials" | "retry" | "ok" | "redirects" | "timeout" | "buffer" | "serialize" | "parse" | "ca" | "pfx" | "cert"> & {
15
15
  module: <T extends Construct>(Module: T) => SuperTestRequest<PickFunc<InstanceType<T>>>;
16
16
  }>;
17
17
 
package/dist/test.d.ts CHANGED
@@ -2,8 +2,8 @@ import * as supertest from 'supertest';
2
2
  import { Test } from 'supertest';
3
3
  import { Server } from 'node:http';
4
4
  import { Construct } from 'phecda-core';
5
- import { F as Factory } from './core-Blq8frmr.js';
6
- import { P as PickFunc } from './types-BlIBlnVT.js';
5
+ import { F as Factory } from './core-BmJJLUqj.js';
6
+ import { P as PickFunc } from './meta-KtfiBIde.js';
7
7
 
8
8
  declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
9
9
  get<C extends T[number]>(Model: C): InstanceType<C>;
@@ -11,7 +11,7 @@ declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
11
11
  type SuperTestRequest<T> = {
12
12
  [K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;
13
13
  };
14
- declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "use" | "on" | "set" | "query" | "type" | "accept" | "auth" | "withCredentials" | "retry" | "ok" | "redirects" | "timeout" | "buffer" | "serialize" | "parse" | "ca" | "key" | "pfx" | "cert"> & {
14
+ declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "type" | "key" | "query" | "use" | "on" | "set" | "accept" | "auth" | "withCredentials" | "retry" | "ok" | "redirects" | "timeout" | "buffer" | "serialize" | "parse" | "ca" | "pfx" | "cert"> & {
15
15
  module: <T extends Construct>(Module: T) => SuperTestRequest<PickFunc<InstanceType<T>>>;
16
16
  }>;
17
17
 
@@ -1,5 +1,5 @@
1
- import { IncomingHttpHeaders } from 'node:http';
2
- import { D as DefaultOptions, B as BaseContext } from './types-BlIBlnVT.mjs';
1
+ import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
2
+ import { D as DefaultOptions, B as BaseContext } from './meta-KtfiBIde.mjs';
3
3
 
4
4
  interface HttpOptions extends DefaultOptions {
5
5
  /**
@@ -28,6 +28,8 @@ interface HttpContext extends BaseContext {
28
28
  delCookie(key: string): void;
29
29
  setResHeaders: (headers: Record<string, string>) => void;
30
30
  setResStatus: (status: number) => void;
31
+ getRequest: () => IncomingMessage;
32
+ getResponse: () => ServerResponse;
31
33
  }
32
34
  interface CookieSerializeOptions {
33
35
  domain?: string | undefined;
@@ -1,5 +1,5 @@
1
- import { IncomingHttpHeaders } from 'node:http';
2
- import { D as DefaultOptions, B as BaseContext } from './types-BlIBlnVT.js';
1
+ import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
2
+ import { D as DefaultOptions, B as BaseContext } from './meta-KtfiBIde.js';
3
3
 
4
4
  interface HttpOptions extends DefaultOptions {
5
5
  /**
@@ -28,6 +28,8 @@ interface HttpContext extends BaseContext {
28
28
  delCookie(key: string): void;
29
29
  setResHeaders: (headers: Record<string, string>) => void;
30
30
  setResStatus: (status: number) => void;
31
+ getRequest: () => IncomingMessage;
32
+ getResponse: () => ServerResponse;
31
33
  }
32
34
  interface CookieSerializeOptions {
33
35
  domain?: string | undefined;
@@ -1,4 +1,4 @@
1
- import { D as DefaultOptions, B as BaseContext } from './types-BlIBlnVT.js';
1
+ import { D as DefaultOptions, B as BaseContext } from './meta-KtfiBIde.js';
2
2
 
3
3
  interface RpcServerOptions extends DefaultOptions {
4
4
  }
@@ -1,4 +1,4 @@
1
- import { D as DefaultOptions, B as BaseContext } from './types-BlIBlnVT.mjs';
1
+ import { D as DefaultOptions, B as BaseContext } from './meta-KtfiBIde.mjs';
2
2
 
3
3
  interface RpcServerOptions extends DefaultOptions {
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-server",
3
- "version": "6.0.0",
3
+ "version": "6.0.2",
4
4
  "description": "server framework that provide IOC/type-reuse/http&rpc-adaptor",
5
5
  "author": "fgsreally",
6
6
  "license": "MIT",