phecda-server 5.2.5 → 5.3.0

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 (79) hide show
  1. package/dist/{chunk-JJJ7AUEF.mjs → chunk-5E2AVYP2.mjs} +2 -2
  2. package/dist/{chunk-6QLTBEXP.js → chunk-AUAAKHWS.js} +38 -38
  3. package/dist/{chunk-2O6X54P5.mjs → chunk-BZKJ5NBU.mjs} +1 -1
  4. package/dist/{chunk-MGADYFW4.mjs → chunk-LHLQIQPH.mjs} +27 -25
  5. package/dist/{chunk-2NTXVYQC.mjs → chunk-MESZCLSS.mjs} +0 -2
  6. package/dist/{chunk-MKZOLLJS.js → chunk-N4ULJDEQ.js} +43 -41
  7. package/dist/{chunk-6T4UZ4LV.js → chunk-QYX5Q7KO.js} +60 -60
  8. package/dist/{chunk-H2FWLKXN.js → chunk-RVWBJ6LV.js} +1 -3
  9. package/dist/{core-C3cON4Um.d.ts → core-Bc2ENEHX.d.mts} +7 -5
  10. package/dist/{core-BIm7dkko.d.mts → core-dx9E5x2N.d.ts} +7 -5
  11. package/dist/helper.d.mts +1 -1
  12. package/dist/helper.d.ts +1 -1
  13. package/dist/helper.js +3 -3
  14. package/dist/helper.mjs +2 -2
  15. package/dist/index.d.mts +24 -19
  16. package/dist/index.d.ts +24 -19
  17. package/dist/index.js +72 -65
  18. package/dist/index.mjs +40 -33
  19. package/dist/rpc/bullmq/index.d.mts +3 -3
  20. package/dist/rpc/bullmq/index.d.ts +3 -3
  21. package/dist/rpc/bullmq/index.js +12 -12
  22. package/dist/rpc/bullmq/index.mjs +2 -2
  23. package/dist/rpc/kafka/index.d.mts +3 -3
  24. package/dist/rpc/kafka/index.d.ts +3 -3
  25. package/dist/rpc/kafka/index.js +12 -12
  26. package/dist/rpc/kafka/index.mjs +2 -2
  27. package/dist/rpc/nats/index.d.mts +3 -3
  28. package/dist/rpc/nats/index.d.ts +3 -3
  29. package/dist/rpc/nats/index.js +11 -11
  30. package/dist/rpc/nats/index.mjs +2 -2
  31. package/dist/rpc/rabbitmq/index.d.mts +3 -3
  32. package/dist/rpc/rabbitmq/index.d.ts +3 -3
  33. package/dist/rpc/rabbitmq/index.js +13 -13
  34. package/dist/rpc/rabbitmq/index.mjs +2 -2
  35. package/dist/rpc/redis/index.d.mts +3 -3
  36. package/dist/rpc/redis/index.d.ts +3 -3
  37. package/dist/rpc/redis/index.js +11 -11
  38. package/dist/rpc/redis/index.mjs +2 -2
  39. package/dist/server/elysia/index.d.mts +3 -3
  40. package/dist/server/elysia/index.d.ts +3 -3
  41. package/dist/server/elysia/index.js +39 -21
  42. package/dist/server/elysia/index.mjs +23 -5
  43. package/dist/server/express/index.d.mts +3 -3
  44. package/dist/server/express/index.d.ts +3 -3
  45. package/dist/server/express/index.js +36 -22
  46. package/dist/server/express/index.mjs +21 -7
  47. package/dist/server/fastify/index.d.mts +3 -3
  48. package/dist/server/fastify/index.d.ts +3 -3
  49. package/dist/server/fastify/index.js +41 -23
  50. package/dist/server/fastify/index.mjs +26 -8
  51. package/dist/server/h3/index.d.mts +3 -3
  52. package/dist/server/h3/index.d.ts +3 -3
  53. package/dist/server/h3/index.js +31 -19
  54. package/dist/server/h3/index.mjs +17 -5
  55. package/dist/server/hono/index.d.mts +3 -3
  56. package/dist/server/hono/index.d.ts +3 -3
  57. package/dist/server/hono/index.js +35 -18
  58. package/dist/server/hono/index.mjs +21 -4
  59. package/dist/server/hyper-express/index.d.mts +3 -3
  60. package/dist/server/hyper-express/index.d.ts +3 -3
  61. package/dist/server/hyper-express/index.js +31 -19
  62. package/dist/server/hyper-express/index.mjs +16 -4
  63. package/dist/server/koa/index.d.mts +3 -3
  64. package/dist/server/koa/index.d.ts +3 -3
  65. package/dist/server/koa/index.js +37 -23
  66. package/dist/server/koa/index.mjs +21 -7
  67. package/dist/test.d.mts +3 -3
  68. package/dist/test.d.ts +3 -3
  69. package/dist/test.js +14 -14
  70. package/dist/test.mjs +11 -11
  71. package/dist/{types-B-y2TwhC.d.mts → types-AgVwUXPC.d.mts} +2 -2
  72. package/dist/{types-CIZbw8S2.d.ts → types-B-ZFZajI.d.ts} +2 -2
  73. package/dist/types-BCJhmpQh.d.ts +45 -0
  74. package/dist/{types-CdQey96H.d.ts → types-BlIBlnVT.d.mts} +1 -2
  75. package/dist/{types-CdQey96H.d.mts → types-BlIBlnVT.d.ts} +1 -2
  76. package/dist/types-Dgxirc9f.d.mts +45 -0
  77. package/package.json +2 -2
  78. package/dist/types-ByP1fKMe.d.mts +0 -27
  79. package/dist/types-C5sdDiDQ.d.ts +0 -27
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  Define
3
- } from "../../chunk-JJJ7AUEF.mjs";
3
+ } from "../../chunk-5E2AVYP2.mjs";
4
4
  import {
5
5
  BadRequestException,
6
6
  Context,
7
7
  argToReq,
8
8
  createControllerMetaMap,
9
9
  detectAopDep
10
- } from "../../chunk-2O6X54P5.mjs";
10
+ } from "../../chunk-BZKJ5NBU.mjs";
11
11
  import {
12
12
  __name
13
- } from "../../chunk-2NTXVYQC.mjs";
13
+ } from "../../chunk-MESZCLSS.mjs";
14
14
 
15
15
  // src/server/fastify/bind.ts
16
16
  import Debug from "debug";
@@ -72,7 +72,16 @@ function bind(fastify, data, opts = {}) {
72
72
  tag,
73
73
  func,
74
74
  app: fastify3,
75
- ...argToReq(params, item.args, req.headers)
75
+ ...argToReq(params, item.args, req.headers),
76
+ // @ts-expect-error need @fastify/cookie
77
+ getCookie: /* @__PURE__ */ __name((key) => req.cookies[key], "getCookie"),
78
+ // @ts-expect-error need @fastify/cookie
79
+ setCookie: /* @__PURE__ */ __name((key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
80
+ // @ts-expect-error need @fastify/cookie
81
+ delCookie: /* @__PURE__ */ __name((key) => res.clearCookie(key), "delCookie"),
82
+ redirect: /* @__PURE__ */ __name((url, status) => res.redirect(url, status), "redirect"),
83
+ setResHeaders: /* @__PURE__ */ __name((headers) => res.headers(headers), "setResHeaders"),
84
+ setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus")
76
85
  };
77
86
  const context = new Context(contextData);
78
87
  context.run({
@@ -116,12 +125,21 @@ function bind(fastify, data, opts = {}) {
116
125
  body: req.body,
117
126
  params: req.params,
118
127
  headers: req.headers,
119
- app: fastify3
128
+ app: fastify3,
129
+ // @ts-expect-error need @fastify/cookie
130
+ getCookie: /* @__PURE__ */ __name((key) => req.cookies[key], "getCookie"),
131
+ // @ts-expect-error need @fastify/cookie
132
+ setCookie: /* @__PURE__ */ __name((key, value, opts2) => res.setCookie(key, value, opts2), "setCookie"),
133
+ // @ts-expect-error need @fastify/cookie
134
+ delCookie: /* @__PURE__ */ __name((key) => res.clearCookie(key, {
135
+ path: ""
136
+ }), "delCookie"),
137
+ redirect: /* @__PURE__ */ __name((url, status) => res.redirect(url, status), "redirect"),
138
+ setResHeaders: /* @__PURE__ */ __name((headers) => res.headers(headers), "setResHeaders"),
139
+ setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus")
120
140
  };
121
141
  const context = new Context(contextData);
122
- if (http.headers) {
123
- for (const name in http.headers) res.header(name, http.headers[name]);
124
- }
142
+ if (http.headers) res.headers(http.headers);
125
143
  return context.run({
126
144
  globalGuards,
127
145
  globalInterceptors,
@@ -1,8 +1,8 @@
1
1
  import { H3Event, Router, _RequestMiddleware } from 'h3';
2
- import { F as Factory } from '../../core-BIm7dkko.mjs';
3
- import { a as HttpContext, H as HttpOptions } from '../../types-ByP1fKMe.mjs';
2
+ import { F as Factory } from '../../core-Bc2ENEHX.mjs';
3
+ import { H as HttpContext, a as HttpOptions } from '../../types-Dgxirc9f.mjs';
4
4
  import 'phecda-core';
5
- import '../../types-CdQey96H.mjs';
5
+ import '../../types-BlIBlnVT.mjs';
6
6
  import 'node:http';
7
7
 
8
8
  interface H3Ctx extends HttpContext {
@@ -1,8 +1,8 @@
1
1
  import { H3Event, Router, _RequestMiddleware } from 'h3';
2
- import { F as Factory } from '../../core-C3cON4Um.js';
3
- import { a as HttpContext, H as HttpOptions } from '../../types-C5sdDiDQ.js';
2
+ import { F as Factory } from '../../core-dx9E5x2N.js';
3
+ import { H as HttpContext, a as HttpOptions } from '../../types-BCJhmpQh.js';
4
4
  import 'phecda-core';
5
- import '../../types-CdQey96H.js';
5
+ import '../../types-BlIBlnVT.js';
6
6
  import 'node:http';
7
7
 
8
8
  interface H3Ctx extends HttpContext {
@@ -4,10 +4,10 @@
4
4
 
5
5
 
6
6
 
7
- var _chunk6T4UZ4LVjs = require('../../chunk-6T4UZ4LV.js');
7
+ var _chunkQYX5Q7KOjs = require('../../chunk-QYX5Q7KO.js');
8
8
 
9
9
 
10
- var _chunkH2FWLKXNjs = require('../../chunk-H2FWLKXN.js');
10
+ var _chunkRVWBJ6LVjs = require('../../chunk-RVWBJ6LV.js');
11
11
 
12
12
  // src/server/h3/bind.ts
13
13
  var _h3 = require('h3');
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/h3");
16
16
  function bind(router, data, opts = {}) {
17
17
  const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
18
18
  const { moduleMap, meta } = data;
19
- const metaMap = _chunk6T4UZ4LVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
19
+ const metaMap = _chunkQYX5Q7KOjs.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
- _chunk6T4UZ4LVjs.detectAopDep.call(void 0, meta, {
26
+ _chunkQYX5Q7KOjs.detectAopDep.call(void 0, meta, {
27
27
  plugins: [
28
28
  ...globalPlugins,
29
29
  ...parallelPlugins
@@ -35,29 +35,29 @@ function bind(router, data, opts = {}) {
35
35
  async function registerRoute() {
36
36
  if (parallelRoute) {
37
37
  router.post(parallelRoute, _h3.eventHandler.call(void 0, {
38
- onRequest: _chunk6T4UZ4LVjs.Context.usePlugin([
38
+ onRequest: _chunkQYX5Q7KOjs.Context.usePlugin([
39
39
  ...globalPlugins,
40
40
  ...parallelPlugins
41
41
  ], "h3").map(_h3.defineRequestMiddleware),
42
- handler: /* @__PURE__ */ _chunkH2FWLKXNjs.__name.call(void 0, async (event) => {
42
+ handler: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, async (event) => {
43
43
  const body = await _h3.readBody.call(void 0, event, {
44
44
  strict: true
45
45
  });
46
46
  async function errorHandler(e) {
47
- const error = await _chunk6T4UZ4LVjs.Context.filterRecord.default(e);
47
+ const error = await _chunkQYX5Q7KOjs.Context.filterRecord.default(e);
48
48
  _h3.setResponseStatus.call(void 0, event, error.status);
49
49
  return error;
50
50
  }
51
- _chunkH2FWLKXNjs.__name.call(void 0, errorHandler, "errorHandler");
52
- if (!Array.isArray(body)) return errorHandler(new (0, _chunk6T4UZ4LVjs.BadRequestException)("data format should be an array"));
51
+ _chunkRVWBJ6LVjs.__name.call(void 0, errorHandler, "errorHandler");
52
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkQYX5Q7KOjs.BadRequestException)("data format should be an array"));
53
53
  try {
54
54
  return Promise.all(body.map((item, i) => {
55
55
  return new Promise(async (resolve) => {
56
56
  const { tag, func } = item;
57
57
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
58
- if (!metaMap.has(tag)) return resolve(await _chunk6T4UZ4LVjs.Context.filterRecord.default(new (0, _chunk6T4UZ4LVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
58
+ if (!metaMap.has(tag)) return resolve(await _chunkQYX5Q7KOjs.Context.filterRecord.default(new (0, _chunkQYX5Q7KOjs.BadRequestException)(`module "${tag}" doesn't exist`)));
59
59
  const meta2 = metaMap.get(tag)[func];
60
- if (!meta2) return resolve(await _chunk6T4UZ4LVjs.Context.filterRecord.default(new (0, _chunk6T4UZ4LVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
60
+ if (!meta2) return resolve(await _chunkQYX5Q7KOjs.Context.filterRecord.default(new (0, _chunkQYX5Q7KOjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
61
61
  const { data: { params } } = meta2;
62
62
  const contextData = {
63
63
  type: "h3",
@@ -69,9 +69,15 @@ function bind(router, data, opts = {}) {
69
69
  func,
70
70
  parallel: true,
71
71
  app: router,
72
- ..._chunk6T4UZ4LVjs.argToReq.call(void 0, params, item.args, _h3.getRequestHeaders.call(void 0, event))
72
+ ..._chunkQYX5Q7KOjs.argToReq.call(void 0, params, item.args, _h3.getRequestHeaders.call(void 0, event)),
73
+ getCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
74
+ setCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
75
+ delCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie"),
76
+ redirect: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (url, status) => _h3.sendRedirect.call(void 0, event, url, status), "redirect"),
77
+ setResHeaders: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
78
+ setResStatus: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus")
73
79
  };
74
- const context = new (0, _chunk6T4UZ4LVjs.Context)(contextData);
80
+ const context = new (0, _chunkQYX5Q7KOjs.Context)(contextData);
75
81
  context.run({
76
82
  globalGuards,
77
83
  globalInterceptors,
@@ -93,11 +99,11 @@ function bind(router, data, opts = {}) {
93
99
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
94
100
  const needBody = params.some((item) => item.type === "body");
95
101
  router[http.type](http.prefix + http.route, _h3.eventHandler.call(void 0, {
96
- onRequest: _chunk6T4UZ4LVjs.Context.usePlugin([
102
+ onRequest: _chunkQYX5Q7KOjs.Context.usePlugin([
97
103
  ...globalPlugins,
98
104
  ...plugins
99
105
  ], "h3").map(_h3.defineRequestMiddleware),
100
- handler: /* @__PURE__ */ _chunkH2FWLKXNjs.__name.call(void 0, async (event) => {
106
+ handler: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, async (event) => {
101
107
  debug(`invoke method "${func}" in module "${tag}"`);
102
108
  const contextData = {
103
109
  type: "h3",
@@ -112,9 +118,15 @@ function bind(router, data, opts = {}) {
112
118
  app: router,
113
119
  body: needBody ? await _h3.readBody.call(void 0, event, {
114
120
  strict: true
115
- }) : void 0
121
+ }) : void 0,
122
+ getCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key) => _h3.getCookie.call(void 0, event, key), "getCookie"),
123
+ setCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key, value, opts2) => _h3.setCookie.call(void 0, event, key, value, opts2), "setCookie"),
124
+ redirect: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (url) => _h3.sendRedirect.call(void 0, event, url), "redirect"),
125
+ setResHeaders: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (headers) => _h3.setResponseHeaders.call(void 0, event, headers), "setResHeaders"),
126
+ setResStatus: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (code) => _h3.setResponseStatus.call(void 0, event, code), "setResStatus"),
127
+ delCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key) => _h3.deleteCookie.call(void 0, event, key), "delCookie")
116
128
  };
117
- const context = new (0, _chunk6T4UZ4LVjs.Context)(contextData);
129
+ const context = new (0, _chunkQYX5Q7KOjs.Context)(contextData);
118
130
  _h3.setHeaders.call(void 0, event, http.headers || {});
119
131
  return context.run({
120
132
  globalGuards,
@@ -130,9 +142,9 @@ function bind(router, data, opts = {}) {
130
142
  }
131
143
  }
132
144
  }
133
- _chunkH2FWLKXNjs.__name.call(void 0, registerRoute, "registerRoute");
145
+ _chunkRVWBJ6LVjs.__name.call(void 0, registerRoute, "registerRoute");
134
146
  }
135
- _chunkH2FWLKXNjs.__name.call(void 0, bind, "bind");
147
+ _chunkRVWBJ6LVjs.__name.call(void 0, bind, "bind");
136
148
 
137
149
 
138
150
  exports.bind = bind;
@@ -4,13 +4,13 @@ import {
4
4
  argToReq,
5
5
  createControllerMetaMap,
6
6
  detectAopDep
7
- } from "../../chunk-2O6X54P5.mjs";
7
+ } from "../../chunk-BZKJ5NBU.mjs";
8
8
  import {
9
9
  __name
10
- } from "../../chunk-2NTXVYQC.mjs";
10
+ } from "../../chunk-MESZCLSS.mjs";
11
11
 
12
12
  // src/server/h3/bind.ts
13
- import { defineRequestMiddleware, eventHandler, getQuery, getRequestHeaders, getRouterParams, readBody, setHeaders, setResponseStatus } from "h3";
13
+ import { defineRequestMiddleware, deleteCookie, eventHandler, getCookie, getQuery, getRequestHeaders, getRouterParams, readBody, sendRedirect, setCookie, setHeaders, setResponseHeaders, setResponseStatus } from "h3";
14
14
  import Debug from "debug";
15
15
  var debug = Debug("phecda-server/h3");
16
16
  function bind(router, data, opts = {}) {
@@ -69,7 +69,13 @@ function bind(router, data, opts = {}) {
69
69
  func,
70
70
  parallel: true,
71
71
  app: router,
72
- ...argToReq(params, item.args, getRequestHeaders(event))
72
+ ...argToReq(params, item.args, getRequestHeaders(event)),
73
+ getCookie: /* @__PURE__ */ __name((key) => getCookie(event, key), "getCookie"),
74
+ setCookie: /* @__PURE__ */ __name((key, value, opts2) => setCookie(event, key, value, opts2), "setCookie"),
75
+ delCookie: /* @__PURE__ */ __name((key) => deleteCookie(event, key), "delCookie"),
76
+ redirect: /* @__PURE__ */ __name((url, status) => sendRedirect(event, url, status), "redirect"),
77
+ setResHeaders: /* @__PURE__ */ __name((headers) => setResponseHeaders(event, headers), "setResHeaders"),
78
+ setResStatus: /* @__PURE__ */ __name((code) => setResponseStatus(event, code), "setResStatus")
73
79
  };
74
80
  const context = new Context(contextData);
75
81
  context.run({
@@ -112,7 +118,13 @@ function bind(router, data, opts = {}) {
112
118
  app: router,
113
119
  body: needBody ? await readBody(event, {
114
120
  strict: true
115
- }) : void 0
121
+ }) : void 0,
122
+ getCookie: /* @__PURE__ */ __name((key) => getCookie(event, key), "getCookie"),
123
+ setCookie: /* @__PURE__ */ __name((key, value, opts2) => setCookie(event, key, value, opts2), "setCookie"),
124
+ redirect: /* @__PURE__ */ __name((url) => sendRedirect(event, url), "redirect"),
125
+ setResHeaders: /* @__PURE__ */ __name((headers) => setResponseHeaders(event, headers), "setResHeaders"),
126
+ setResStatus: /* @__PURE__ */ __name((code) => setResponseStatus(event, code), "setResStatus"),
127
+ delCookie: /* @__PURE__ */ __name((key) => deleteCookie(event, key), "delCookie")
116
128
  };
117
129
  const context = new Context(contextData);
118
130
  setHeaders(event, http.headers || {});
@@ -1,8 +1,8 @@
1
1
  import { Context, Hono, MiddlewareHandler } from 'hono';
2
- import { a as HttpContext, H as HttpOptions } from '../../types-ByP1fKMe.mjs';
3
- import { F as Factory } from '../../core-BIm7dkko.mjs';
2
+ import { H as HttpContext, a as HttpOptions } from '../../types-Dgxirc9f.mjs';
3
+ import { F as Factory } from '../../core-Bc2ENEHX.mjs';
4
4
  import 'node:http';
5
- import '../../types-CdQey96H.mjs';
5
+ import '../../types-BlIBlnVT.mjs';
6
6
  import 'phecda-core';
7
7
 
8
8
  interface HonoCtx extends HttpContext {
@@ -1,8 +1,8 @@
1
1
  import { Context, Hono, MiddlewareHandler } from 'hono';
2
- import { a as HttpContext, H as HttpOptions } from '../../types-C5sdDiDQ.js';
3
- import { F as Factory } from '../../core-C3cON4Um.js';
2
+ import { H as HttpContext, a as HttpOptions } from '../../types-BCJhmpQh.js';
3
+ import { F as Factory } from '../../core-dx9E5x2N.js';
4
4
  import 'node:http';
5
- import '../../types-CdQey96H.js';
5
+ import '../../types-BlIBlnVT.js';
6
6
  import 'phecda-core';
7
7
 
8
8
  interface HonoCtx extends HttpContext {
@@ -4,25 +4,26 @@
4
4
 
5
5
 
6
6
 
7
- var _chunk6T4UZ4LVjs = require('../../chunk-6T4UZ4LV.js');
7
+ var _chunkQYX5Q7KOjs = require('../../chunk-QYX5Q7KO.js');
8
8
 
9
9
 
10
- var _chunkH2FWLKXNjs = require('../../chunk-H2FWLKXN.js');
10
+ var _chunkRVWBJ6LVjs = require('../../chunk-RVWBJ6LV.js');
11
11
 
12
12
  // src/server/hono/bind.ts
13
13
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
14
+ var _cookie = require('hono/cookie');
14
15
  var debug = _debug2.default.call(void 0, "phecda-server/hono");
15
16
  function bind(router, data, opts = {}) {
16
17
  const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
17
18
  const { moduleMap, meta } = data;
18
- const metaMap = _chunk6T4UZ4LVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
19
+ const metaMap = _chunkQYX5Q7KOjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
19
20
  const { controller, http, func, tag } = meta2.data;
20
21
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
21
22
  debug(`register method "${func}" in module "${tag}"`);
22
23
  return true;
23
24
  }
24
25
  });
25
- _chunk6T4UZ4LVjs.detectAopDep.call(void 0, meta, {
26
+ _chunkQYX5Q7KOjs.detectAopDep.call(void 0, meta, {
26
27
  plugins: [
27
28
  ...globalPlugins,
28
29
  ...parallelPlugins
@@ -32,25 +33,25 @@ function bind(router, data, opts = {}) {
32
33
  });
33
34
  registerRoute();
34
35
  async function registerRoute() {
35
- _chunk6T4UZ4LVjs.Context.usePlugin(globalPlugins, "hono").forEach((p) => router.use(p));
36
+ _chunkQYX5Q7KOjs.Context.usePlugin(globalPlugins, "hono").forEach((p) => router.use(p));
36
37
  if (parallelRoute) {
37
- router.post(parallelRoute, ..._chunk6T4UZ4LVjs.Context.usePlugin(parallelPlugins, "hono"), async (c) => {
38
+ router.post(parallelRoute, ..._chunkQYX5Q7KOjs.Context.usePlugin(parallelPlugins, "hono"), async (c) => {
38
39
  const body = await c.req.json();
39
40
  async function errorHandler(e) {
40
- const error = await _chunk6T4UZ4LVjs.Context.filterRecord.default(e);
41
+ const error = await _chunkQYX5Q7KOjs.Context.filterRecord.default(e);
41
42
  c.status(error.status);
42
43
  return c.json(error);
43
44
  }
44
- _chunkH2FWLKXNjs.__name.call(void 0, errorHandler, "errorHandler");
45
- if (!Array.isArray(body)) return errorHandler(new (0, _chunk6T4UZ4LVjs.BadRequestException)("data format should be an array"));
45
+ _chunkRVWBJ6LVjs.__name.call(void 0, errorHandler, "errorHandler");
46
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkQYX5Q7KOjs.BadRequestException)("data format should be an array"));
46
47
  try {
47
48
  return Promise.all(body.map((item, i) => {
48
49
  return new Promise(async (resolve) => {
49
50
  const { tag, func } = item;
50
51
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
51
- if (!metaMap.has(tag)) return resolve(await _chunk6T4UZ4LVjs.Context.filterRecord.default(new (0, _chunk6T4UZ4LVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
52
+ if (!metaMap.has(tag)) return resolve(await _chunkQYX5Q7KOjs.Context.filterRecord.default(new (0, _chunkQYX5Q7KOjs.BadRequestException)(`module "${tag}" doesn't exist`)));
52
53
  const meta2 = metaMap.get(tag)[func];
53
- if (!meta2) return resolve(await _chunk6T4UZ4LVjs.Context.filterRecord.default(new (0, _chunk6T4UZ4LVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
54
+ if (!meta2) return resolve(await _chunkQYX5Q7KOjs.Context.filterRecord.default(new (0, _chunkQYX5Q7KOjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
54
55
  const { data: { params } } = meta2;
55
56
  const contextData = {
56
57
  type: "hono",
@@ -62,9 +63,17 @@ function bind(router, data, opts = {}) {
62
63
  tag,
63
64
  func,
64
65
  app: router,
65
- ..._chunk6T4UZ4LVjs.argToReq.call(void 0, params, item.args, c.req.header())
66
+ ..._chunkQYX5Q7KOjs.argToReq.call(void 0, params, item.args, c.req.header()),
67
+ getCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
68
+ delCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
69
+ setCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
70
+ redirect: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
71
+ setResHeaders: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (headers) => {
72
+ for (const name in headers) c.header(name, headers[name]);
73
+ }, "setResHeaders"),
74
+ setResStatus: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (status) => c.status(status), "setResStatus")
66
75
  };
67
- const context = new (0, _chunk6T4UZ4LVjs.Context)(contextData);
76
+ const context = new (0, _chunkQYX5Q7KOjs.Context)(contextData);
68
77
  context.run({
69
78
  globalGuards,
70
79
  globalInterceptors,
@@ -86,7 +95,7 @@ function bind(router, data, opts = {}) {
86
95
  const { data: { params, plugins, http } } = meta2;
87
96
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
88
97
  const needBody = params.some((item) => item.type === "body");
89
- router[http.type](http.prefix + http.route, ..._chunk6T4UZ4LVjs.Context.usePlugin(plugins, "hono"), async (c) => {
98
+ router[http.type](http.prefix + http.route, ..._chunkQYX5Q7KOjs.Context.usePlugin(plugins, "hono"), async (c) => {
90
99
  debug(`invoke method "${func}" in module "${tag}"`);
91
100
  const contextData = {
92
101
  type: "hono",
@@ -99,9 +108,17 @@ function bind(router, data, opts = {}) {
99
108
  body: needBody ? await c.req.json() : void 0,
100
109
  params: c.req.param(),
101
110
  headers: c.req.header(),
102
- app: router
111
+ app: router,
112
+ getCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key) => _cookie.getCookie.call(void 0, c, key), "getCookie"),
113
+ delCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key) => _cookie.deleteCookie.call(void 0, c, key), "delCookie"),
114
+ setCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key, value, opts2) => _cookie.setCookie.call(void 0, c, key, value, opts2), "setCookie"),
115
+ redirect: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
116
+ setResHeaders: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (headers) => {
117
+ for (const name in headers) c.header(name, headers[name]);
118
+ }, "setResHeaders"),
119
+ setResStatus: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (status) => c.status(status), "setResStatus")
103
120
  };
104
- const context = new (0, _chunk6T4UZ4LVjs.Context)(contextData);
121
+ const context = new (0, _chunkQYX5Q7KOjs.Context)(contextData);
105
122
  if (http.headers) {
106
123
  for (const name in http.headers) c.header(name, http.headers[name]);
107
124
  }
@@ -122,9 +139,9 @@ function bind(router, data, opts = {}) {
122
139
  }
123
140
  }
124
141
  }
125
- _chunkH2FWLKXNjs.__name.call(void 0, registerRoute, "registerRoute");
142
+ _chunkRVWBJ6LVjs.__name.call(void 0, registerRoute, "registerRoute");
126
143
  }
127
- _chunkH2FWLKXNjs.__name.call(void 0, bind, "bind");
144
+ _chunkRVWBJ6LVjs.__name.call(void 0, bind, "bind");
128
145
 
129
146
 
130
147
  exports.bind = bind;
@@ -4,13 +4,14 @@ import {
4
4
  argToReq,
5
5
  createControllerMetaMap,
6
6
  detectAopDep
7
- } from "../../chunk-2O6X54P5.mjs";
7
+ } from "../../chunk-BZKJ5NBU.mjs";
8
8
  import {
9
9
  __name
10
- } from "../../chunk-2NTXVYQC.mjs";
10
+ } from "../../chunk-MESZCLSS.mjs";
11
11
 
12
12
  // src/server/hono/bind.ts
13
13
  import Debug from "debug";
14
+ import { deleteCookie, getCookie, setCookie } from "hono/cookie";
14
15
  var debug = Debug("phecda-server/hono");
15
16
  function bind(router, data, opts = {}) {
16
17
  const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
@@ -62,7 +63,15 @@ function bind(router, data, opts = {}) {
62
63
  tag,
63
64
  func,
64
65
  app: router,
65
- ...argToReq(params, item.args, c.req.header())
66
+ ...argToReq(params, item.args, c.req.header()),
67
+ getCookie: /* @__PURE__ */ __name((key) => getCookie(c, key), "getCookie"),
68
+ delCookie: /* @__PURE__ */ __name((key) => deleteCookie(c, key), "delCookie"),
69
+ setCookie: /* @__PURE__ */ __name((key, value, opts2) => setCookie(c, key, value, opts2), "setCookie"),
70
+ redirect: /* @__PURE__ */ __name((url) => c.redirect(url), "redirect"),
71
+ setResHeaders: /* @__PURE__ */ __name((headers) => {
72
+ for (const name in headers) c.header(name, headers[name]);
73
+ }, "setResHeaders"),
74
+ setResStatus: /* @__PURE__ */ __name((status) => c.status(status), "setResStatus")
66
75
  };
67
76
  const context = new Context(contextData);
68
77
  context.run({
@@ -99,7 +108,15 @@ function bind(router, data, opts = {}) {
99
108
  body: needBody ? await c.req.json() : void 0,
100
109
  params: c.req.param(),
101
110
  headers: c.req.header(),
102
- app: router
111
+ app: router,
112
+ getCookie: /* @__PURE__ */ __name((key) => getCookie(c, key), "getCookie"),
113
+ delCookie: /* @__PURE__ */ __name((key) => deleteCookie(c, key), "delCookie"),
114
+ setCookie: /* @__PURE__ */ __name((key, value, opts2) => setCookie(c, key, value, opts2), "setCookie"),
115
+ redirect: /* @__PURE__ */ __name((url) => c.redirect(url), "redirect"),
116
+ setResHeaders: /* @__PURE__ */ __name((headers) => {
117
+ for (const name in headers) c.header(name, headers[name]);
118
+ }, "setResHeaders"),
119
+ setResStatus: /* @__PURE__ */ __name((status) => c.status(status), "setResStatus")
103
120
  };
104
121
  const context = new Context(contextData);
105
122
  if (http.headers) {
@@ -1,8 +1,8 @@
1
1
  import { Request, Response, Router, MiddlewareHandler } from 'hyper-express';
2
- import { a as HttpContext, H as HttpOptions } from '../../types-ByP1fKMe.mjs';
3
- import { F as Factory } from '../../core-BIm7dkko.mjs';
2
+ import { H as HttpContext, a as HttpOptions } from '../../types-Dgxirc9f.mjs';
3
+ import { F as Factory } from '../../core-Bc2ENEHX.mjs';
4
4
  import 'node:http';
5
- import '../../types-CdQey96H.mjs';
5
+ import '../../types-BlIBlnVT.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 { a as HttpContext, H as HttpOptions } from '../../types-C5sdDiDQ.js';
3
- import { F as Factory } from '../../core-C3cON4Um.js';
2
+ import { H as HttpContext, a as HttpOptions } from '../../types-BCJhmpQh.js';
3
+ import { F as Factory } from '../../core-dx9E5x2N.js';
4
4
  import 'node:http';
5
- import '../../types-CdQey96H.js';
5
+ import '../../types-BlIBlnVT.js';
6
6
  import 'phecda-core';
7
7
 
8
8
  interface HyperExpressCtx extends HttpContext {
@@ -4,10 +4,10 @@
4
4
 
5
5
 
6
6
 
7
- var _chunk6T4UZ4LVjs = require('../../chunk-6T4UZ4LV.js');
7
+ var _chunkQYX5Q7KOjs = require('../../chunk-QYX5Q7KO.js');
8
8
 
9
9
 
10
- var _chunkH2FWLKXNjs = require('../../chunk-H2FWLKXN.js');
10
+ var _chunkRVWBJ6LVjs = require('../../chunk-RVWBJ6LV.js');
11
11
 
12
12
  // src/server/hyper-express/bind.ts
13
13
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
@@ -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 = _chunk6T4UZ4LVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
18
+ const metaMap = _chunkQYX5Q7KOjs.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
- _chunk6T4UZ4LVjs.detectAopDep.call(void 0, meta, {
25
+ _chunkQYX5Q7KOjs.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
- _chunk6T4UZ4LVjs.Context.usePlugin(globalPlugins, "hyper-express").forEach((p) => router.use(p));
35
+ _chunkQYX5Q7KOjs.Context.usePlugin(globalPlugins, "hyper-express").forEach((p) => router.use(p));
36
36
  if (parallelRoute) {
37
37
  router.post(parallelRoute, {
38
- middlewares: _chunk6T4UZ4LVjs.Context.usePlugin(parallelPlugins, "hyper-express")
38
+ middlewares: _chunkQYX5Q7KOjs.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 _chunk6T4UZ4LVjs.Context.filterRecord.default(e);
42
+ const error = await _chunkQYX5Q7KOjs.Context.filterRecord.default(e);
43
43
  return res.status(error.status).json(error);
44
44
  }
45
- _chunkH2FWLKXNjs.__name.call(void 0, errorHandler, "errorHandler");
46
- if (!Array.isArray(body)) return errorHandler(new (0, _chunk6T4UZ4LVjs.BadRequestException)("data format should be an array"));
45
+ _chunkRVWBJ6LVjs.__name.call(void 0, errorHandler, "errorHandler");
46
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkQYX5Q7KOjs.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 _chunk6T4UZ4LVjs.Context.filterRecord.default(new (0, _chunk6T4UZ4LVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
52
+ if (!metaMap.has(tag)) return resolve(await _chunkQYX5Q7KOjs.Context.filterRecord.default(new (0, _chunkQYX5Q7KOjs.BadRequestException)(`module "${tag}" doesn't exist`)));
53
53
  const meta2 = metaMap.get(tag)[func];
54
- if (!meta2) return resolve(await _chunk6T4UZ4LVjs.Context.filterRecord.default(new (0, _chunk6T4UZ4LVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
54
+ if (!meta2) return resolve(await _chunkQYX5Q7KOjs.Context.filterRecord.default(new (0, _chunkQYX5Q7KOjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
55
55
  const { data: { params } } = meta2;
56
56
  const contextData = {
57
57
  type: "hyper-express",
@@ -65,9 +65,15 @@ function bind(router, data, opts = {}) {
65
65
  func,
66
66
  next,
67
67
  app: router,
68
- ..._chunk6T4UZ4LVjs.argToReq.call(void 0, params, item.args, req.headers)
68
+ ..._chunkQYX5Q7KOjs.argToReq.call(void 0, params, item.args, req.headers),
69
+ getCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
70
+ setCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__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
+ delCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
72
+ redirect: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
73
+ setResHeaders: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
74
+ setResStatus: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
69
75
  };
70
- const context = new (0, _chunk6T4UZ4LVjs.Context)(contextData);
76
+ const context = new (0, _chunkQYX5Q7KOjs.Context)(contextData);
71
77
  context.run({
72
78
  globalGuards,
73
79
  globalInterceptors,
@@ -87,9 +93,9 @@ function bind(router, data, opts = {}) {
87
93
  for (const func in record) {
88
94
  const meta2 = metaMap.get(tag)[func];
89
95
  const { data: { params, plugins, http } } = meta2;
90
- if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
96
+ if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
91
97
  const needBody = params.some((item) => item.type === "body");
92
- router[http.type](http.prefix + http.route, ..._chunk6T4UZ4LVjs.Context.usePlugin(plugins, "hyper-express"), async (req, res, next) => {
98
+ router[http.type](http.prefix + http.route, ..._chunkQYX5Q7KOjs.Context.usePlugin(plugins, "hyper-express"), async (req, res, next) => {
93
99
  debug(`invoke method "${func}" in module "${tag}"`);
94
100
  const contextData = {
95
101
  type: "hyper-express",
@@ -104,9 +110,15 @@ function bind(router, data, opts = {}) {
104
110
  app: router,
105
111
  params: req.path_parameters,
106
112
  headers: req.headers,
107
- next
113
+ next,
114
+ getCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
115
+ setCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _4 => _4.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
116
+ delCookie: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
117
+ redirect: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
118
+ setResHeaders: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
119
+ setResStatus: /* @__PURE__ */ _chunkRVWBJ6LVjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
108
120
  };
109
- const context = new (0, _chunk6T4UZ4LVjs.Context)(contextData);
121
+ const context = new (0, _chunkQYX5Q7KOjs.Context)(contextData);
110
122
  if (http.headers) {
111
123
  for (const name in http.headers) res.set(name, http.headers[name]);
112
124
  }
@@ -127,9 +139,9 @@ function bind(router, data, opts = {}) {
127
139
  }
128
140
  }
129
141
  }
130
- _chunkH2FWLKXNjs.__name.call(void 0, registerRoute, "registerRoute");
142
+ _chunkRVWBJ6LVjs.__name.call(void 0, registerRoute, "registerRoute");
131
143
  }
132
- _chunkH2FWLKXNjs.__name.call(void 0, bind, "bind");
144
+ _chunkRVWBJ6LVjs.__name.call(void 0, bind, "bind");
133
145
 
134
146
 
135
147
  exports.bind = bind;