phecda-server 5.2.3 → 5.2.5

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 (77) hide show
  1. package/dist/{chunk-VYDBNZJ2.mjs → chunk-2NTXVYQC.mjs} +1 -8
  2. package/dist/{chunk-Q4AGVGVA.mjs → chunk-2O6X54P5.mjs} +103 -105
  3. package/dist/{chunk-AWY6FTH4.js → chunk-6QLTBEXP.js} +70 -86
  4. package/dist/{chunk-H6NYBVBV.js → chunk-6T4UZ4LV.js} +130 -132
  5. package/dist/{chunk-FNJWO324.js → chunk-H2FWLKXN.js} +2 -9
  6. package/dist/{chunk-IJNA24EZ.mjs → chunk-JJJ7AUEF.mjs} +39 -55
  7. package/dist/{chunk-YAVIRFUE.mjs → chunk-MGADYFW4.mjs} +28 -49
  8. package/dist/{chunk-J5SL4QLN.js → chunk-MKZOLLJS.js} +39 -60
  9. package/dist/core-BIm7dkko.d.mts +27 -0
  10. package/dist/{core-7f6d2be6.d.ts → core-C3cON4Um.d.ts} +1 -1
  11. package/dist/helper.d.mts +27 -0
  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 +246 -0
  16. package/dist/index.d.ts +7 -7
  17. package/dist/index.js +73 -64
  18. package/dist/index.mjs +48 -39
  19. package/dist/rpc/bullmq/index.d.mts +21 -0
  20. package/dist/rpc/bullmq/index.d.ts +4 -4
  21. package/dist/rpc/bullmq/index.js +30 -43
  22. package/dist/rpc/bullmq/index.mjs +20 -33
  23. package/dist/rpc/kafka/index.d.mts +24 -0
  24. package/dist/rpc/kafka/index.d.ts +4 -4
  25. package/dist/rpc/kafka/index.js +25 -34
  26. package/dist/rpc/kafka/index.mjs +17 -26
  27. package/dist/rpc/nats/index.d.mts +15 -0
  28. package/dist/rpc/nats/index.d.ts +4 -4
  29. package/dist/rpc/nats/index.js +33 -46
  30. package/dist/rpc/nats/index.mjs +24 -37
  31. package/dist/rpc/rabbitmq/index.d.mts +16 -0
  32. package/dist/rpc/rabbitmq/index.d.ts +4 -4
  33. package/dist/rpc/rabbitmq/index.js +34 -46
  34. package/dist/rpc/rabbitmq/index.mjs +23 -35
  35. package/dist/rpc/redis/index.d.mts +23 -0
  36. package/dist/rpc/redis/index.d.ts +4 -4
  37. package/dist/rpc/redis/index.js +27 -38
  38. package/dist/rpc/redis/index.mjs +18 -29
  39. package/dist/server/elysia/index.d.mts +18 -0
  40. package/dist/server/elysia/index.d.ts +4 -4
  41. package/dist/server/elysia/index.js +22 -27
  42. package/dist/server/elysia/index.mjs +8 -13
  43. package/dist/server/express/index.d.mts +18 -0
  44. package/dist/server/express/index.d.ts +4 -4
  45. package/dist/server/express/index.js +24 -33
  46. package/dist/server/express/index.mjs +11 -20
  47. package/dist/server/fastify/index.d.mts +20 -0
  48. package/dist/server/fastify/index.d.ts +4 -4
  49. package/dist/server/fastify/index.js +23 -30
  50. package/dist/server/fastify/index.mjs +10 -17
  51. package/dist/server/h3/index.d.mts +16 -0
  52. package/dist/server/h3/index.d.ts +4 -4
  53. package/dist/server/h3/index.js +21 -25
  54. package/dist/server/h3/index.mjs +10 -14
  55. package/dist/server/hono/index.d.mts +16 -0
  56. package/dist/server/hono/index.d.ts +4 -4
  57. package/dist/server/hono/index.js +22 -30
  58. package/dist/server/hono/index.mjs +10 -18
  59. package/dist/server/hyper-express/index.d.mts +18 -0
  60. package/dist/server/hyper-express/index.d.ts +4 -4
  61. package/dist/server/hyper-express/index.js +23 -32
  62. package/dist/server/hyper-express/index.mjs +11 -20
  63. package/dist/server/koa/index.d.mts +18 -0
  64. package/dist/server/koa/index.d.ts +4 -4
  65. package/dist/server/koa/index.js +22 -29
  66. package/dist/server/koa/index.mjs +9 -16
  67. package/dist/test.d.mts +18 -0
  68. package/dist/test.d.ts +3 -3
  69. package/dist/test.js +14 -22
  70. package/dist/test.mjs +10 -18
  71. package/dist/types-B-y2TwhC.d.mts +17 -0
  72. package/dist/types-ByP1fKMe.d.mts +27 -0
  73. package/dist/{types-68f2ec2a.d.ts → types-C5sdDiDQ.d.ts} +11 -2
  74. package/dist/{types-f3b79218.d.ts → types-CIZbw8S2.d.ts} +2 -2
  75. package/dist/{types-81be0ba3.d.ts → types-CdQey96H.d.mts} +1 -1
  76. package/dist/types-CdQey96H.d.ts +108 -0
  77. package/package.json +3 -3
@@ -1,16 +1,16 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkAWY6FTH4js = require('../../chunk-AWY6FTH4.js');
3
+ var _chunk6QLTBEXPjs = require('../../chunk-6QLTBEXP.js');
4
4
 
5
5
 
6
6
 
7
7
 
8
8
 
9
9
 
10
- var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
10
+ var _chunk6T4UZ4LVjs = require('../../chunk-6T4UZ4LV.js');
11
11
 
12
12
 
13
- var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
13
+ var _chunkH2FWLKXNjs = require('../../chunk-H2FWLKXN.js');
14
14
 
15
15
  // src/server/elysia/bind.ts
16
16
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
@@ -19,14 +19,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/elysia");
19
19
  function bind(app, data, opts = {}) {
20
20
  const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
21
21
  const { moduleMap, meta } = data;
22
- const metaMap = _chunkH6NYBVBVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
+ const metaMap = _chunk6T4UZ4LVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
23
23
  const { controller, http, func, tag } = meta2.data;
24
24
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
25
25
  debug(`register method "${func}" in module "${tag}"`);
26
26
  return true;
27
27
  }
28
28
  });
29
- _chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
29
+ _chunk6T4UZ4LVjs.detectAopDep.call(void 0, meta, {
30
30
  plugins: [
31
31
  ...globalPlugins,
32
32
  ...parallelPlugins
@@ -36,30 +36,27 @@ function bind(app, data, opts = {}) {
36
36
  });
37
37
  registerRoute();
38
38
  async function registerRoute() {
39
- _chunkH6NYBVBVjs.Context.usePlugin(globalPlugins, "elysia").forEach((p) => p(app));
39
+ _chunk6T4UZ4LVjs.Context.usePlugin(globalPlugins, "elysia").forEach((p) => p(app));
40
40
  const parallelRouter = new (0, _elysia.Elysia)();
41
- _chunkH6NYBVBVjs.Context.usePlugin(parallelPlugins, "elysia").forEach((p) => p(parallelRouter));
41
+ _chunk6T4UZ4LVjs.Context.usePlugin(parallelPlugins, "elysia").forEach((p) => p(parallelRouter));
42
42
  if (parallelRoute) {
43
43
  parallelRouter.post(parallelRoute, async (c) => {
44
44
  const { body } = c;
45
45
  async function errorHandler(e) {
46
- const error = await _chunkH6NYBVBVjs.Context.filterRecord.default(e);
46
+ const error = await _chunk6T4UZ4LVjs.Context.filterRecord.default(e);
47
47
  c.set.status = error.status;
48
48
  return error;
49
49
  }
50
- _chunkFNJWO324js.__name.call(void 0, errorHandler, "errorHandler");
51
- if (!Array.isArray(body))
52
- return errorHandler(new (0, _chunkH6NYBVBVjs.BadRequestException)("data format should be an array"));
50
+ _chunkH2FWLKXNjs.__name.call(void 0, errorHandler, "errorHandler");
51
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunk6T4UZ4LVjs.BadRequestException)("data format should be an array"));
53
52
  try {
54
53
  return Promise.all(body.map((item, i) => {
55
54
  return new Promise(async (resolve) => {
56
55
  const { tag, func } = item;
57
56
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
58
- if (!metaMap.has(tag))
59
- return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
57
+ if (!metaMap.has(tag)) return resolve(await _chunk6T4UZ4LVjs.Context.filterRecord.default(new (0, _chunk6T4UZ4LVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
60
58
  const meta2 = metaMap.get(tag)[func];
61
- if (!meta2)
62
- return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
59
+ if (!meta2) return resolve(await _chunk6T4UZ4LVjs.Context.filterRecord.default(new (0, _chunk6T4UZ4LVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
63
60
  const { data: { params } } = meta2;
64
61
  const contextData = {
65
62
  type: "elysia",
@@ -71,9 +68,9 @@ function bind(app, data, opts = {}) {
71
68
  tag,
72
69
  func,
73
70
  app,
74
- ..._chunkH6NYBVBVjs.argToReq.call(void 0, params, item.args, c.headers)
71
+ ..._chunk6T4UZ4LVjs.argToReq.call(void 0, params, item.args, c.headers)
75
72
  };
76
- const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
73
+ const context = new (0, _chunk6T4UZ4LVjs.Context)(contextData);
77
74
  context.run({
78
75
  globalGuards,
79
76
  globalInterceptors,
@@ -95,9 +92,8 @@ function bind(app, data, opts = {}) {
95
92
  const meta2 = metaMap.get(tag)[func];
96
93
  const { data: { define, plugins, http } } = meta2;
97
94
  const funcRouter = new (0, _elysia.Elysia)();
98
- if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
99
- continue;
100
- _chunkH6NYBVBVjs.Context.usePlugin(plugins, "elysia").forEach((p) => p(funcRouter));
95
+ if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
96
+ _chunk6T4UZ4LVjs.Context.usePlugin(plugins, "elysia").forEach((p) => p(funcRouter));
101
97
  funcRouter[http.type](http.prefix + http.route, async (c) => {
102
98
  debug(`invoke method "${func}" in module "${tag}"`);
103
99
  const contextData = {
@@ -113,9 +109,8 @@ function bind(app, data, opts = {}) {
113
109
  headers: c.headers,
114
110
  app
115
111
  };
116
- const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
117
- if (http.headers)
118
- c.set.headers = http.headers;
112
+ const context = new (0, _chunk6T4UZ4LVjs.Context)(contextData);
113
+ if (http.headers) c.set.headers = http.headers;
119
114
  return context.run({
120
115
  globalGuards,
121
116
  globalInterceptors,
@@ -130,13 +125,13 @@ function bind(app, data, opts = {}) {
130
125
  }
131
126
  }
132
127
  }
133
- _chunkFNJWO324js.__name.call(void 0, registerRoute, "registerRoute");
128
+ _chunkH2FWLKXNjs.__name.call(void 0, registerRoute, "registerRoute");
134
129
  }
135
- _chunkFNJWO324js.__name.call(void 0, bind, "bind");
130
+ _chunkH2FWLKXNjs.__name.call(void 0, bind, "bind");
136
131
  function Elysia(opts) {
137
- return _chunkAWY6FTH4js.Define.call(void 0, "elysia", opts);
132
+ return _chunk6QLTBEXPjs.Define.call(void 0, "elysia", opts);
138
133
  }
139
- _chunkFNJWO324js.__name.call(void 0, Elysia, "Elysia");
134
+ _chunkH2FWLKXNjs.__name.call(void 0, Elysia, "Elysia");
140
135
 
141
136
 
142
137
 
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  Define
3
- } from "../../chunk-IJNA24EZ.mjs";
3
+ } from "../../chunk-JJJ7AUEF.mjs";
4
4
  import {
5
5
  BadRequestException,
6
6
  Context,
7
7
  argToReq,
8
8
  createControllerMetaMap,
9
9
  detectAopDep
10
- } from "../../chunk-Q4AGVGVA.mjs";
10
+ } from "../../chunk-2O6X54P5.mjs";
11
11
  import {
12
12
  __name
13
- } from "../../chunk-VYDBNZJ2.mjs";
13
+ } from "../../chunk-2NTXVYQC.mjs";
14
14
 
15
15
  // src/server/elysia/bind.ts
16
16
  import Debug from "debug";
@@ -48,18 +48,15 @@ function bind(app, data, opts = {}) {
48
48
  return error;
49
49
  }
50
50
  __name(errorHandler, "errorHandler");
51
- if (!Array.isArray(body))
52
- return errorHandler(new BadRequestException("data format should be an array"));
51
+ if (!Array.isArray(body)) return errorHandler(new BadRequestException("data format should be an array"));
53
52
  try {
54
53
  return Promise.all(body.map((item, i) => {
55
54
  return new Promise(async (resolve) => {
56
55
  const { tag, func } = item;
57
56
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
58
- if (!metaMap.has(tag))
59
- return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
57
+ if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
60
58
  const meta2 = metaMap.get(tag)[func];
61
- if (!meta2)
62
- return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
59
+ if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
63
60
  const { data: { params } } = meta2;
64
61
  const contextData = {
65
62
  type: "elysia",
@@ -95,8 +92,7 @@ function bind(app, data, opts = {}) {
95
92
  const meta2 = metaMap.get(tag)[func];
96
93
  const { data: { define, plugins, http } } = meta2;
97
94
  const funcRouter = new App();
98
- if (!http?.type)
99
- continue;
95
+ if (!http?.type) continue;
100
96
  Context.usePlugin(plugins, "elysia").forEach((p) => p(funcRouter));
101
97
  funcRouter[http.type](http.prefix + http.route, async (c) => {
102
98
  debug(`invoke method "${func}" in module "${tag}"`);
@@ -114,8 +110,7 @@ function bind(app, data, opts = {}) {
114
110
  app
115
111
  };
116
112
  const context = new Context(contextData);
117
- if (http.headers)
118
- c.set.headers = http.headers;
113
+ if (http.headers) c.set.headers = http.headers;
119
114
  return context.run({
120
115
  globalGuards,
121
116
  globalInterceptors,
@@ -0,0 +1,18 @@
1
+ import { Request, Response, Router, RequestHandler } from 'express';
2
+ import { a as HttpContext, H as HttpOptions } from '../../types-ByP1fKMe.mjs';
3
+ import { F as Factory } from '../../core-BIm7dkko.mjs';
4
+ import 'node:http';
5
+ import '../../types-CdQey96H.mjs';
6
+ import 'phecda-core';
7
+
8
+ interface ExpressCtx extends HttpContext {
9
+ type: 'express';
10
+ request: Request;
11
+ response: Response;
12
+ next: Function;
13
+ app: Router;
14
+ }
15
+ type Plugin = RequestHandler;
16
+ declare function bind(router: Router, data: Awaited<ReturnType<typeof Factory>>, opts?: HttpOptions): void;
17
+
18
+ export { type ExpressCtx, type Plugin, bind };
@@ -1,8 +1,8 @@
1
1
  import { Request, Response, Router, RequestHandler } from 'express';
2
- import { a as HttpContext, H as HttpOptions } from '../../types-68f2ec2a.js';
3
- import { F as Factory } from '../../core-7f6d2be6.js';
2
+ import { a as HttpContext, H as HttpOptions } from '../../types-C5sdDiDQ.js';
3
+ import { F as Factory } from '../../core-C3cON4Um.js';
4
4
  import 'node:http';
5
- import '../../types-81be0ba3.js';
5
+ import '../../types-CdQey96H.js';
6
6
  import 'phecda-core';
7
7
 
8
8
  interface ExpressCtx extends HttpContext {
@@ -15,4 +15,4 @@ interface ExpressCtx extends HttpContext {
15
15
  type Plugin = RequestHandler;
16
16
  declare function bind(router: Router, data: Awaited<ReturnType<typeof Factory>>, opts?: HttpOptions): void;
17
17
 
18
- export { ExpressCtx, Plugin, bind };
18
+ export { type ExpressCtx, type Plugin, bind };
@@ -5,10 +5,10 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
8
+ var _chunk6T4UZ4LVjs = require('../../chunk-6T4UZ4LV.js');
9
9
 
10
10
 
11
- var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
11
+ var _chunkH2FWLKXNjs = require('../../chunk-H2FWLKXN.js');
12
12
 
13
13
  // src/server/express/bind.ts
14
14
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
@@ -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 = _chunkH6NYBVBVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
20
+ const metaMap = _chunk6T4UZ4LVjs.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
- _chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
27
+ _chunk6T4UZ4LVjs.detectAopDep.call(void 0, meta, {
28
28
  plugins: [
29
29
  ...globalPlugins,
30
30
  ...parallelPlugins
@@ -33,32 +33,29 @@ function bind(router, data, opts = {}) {
33
33
  interceptors: globalInterceptors
34
34
  });
35
35
  registerRoute();
36
- _chunkH6NYBVBVjs.HMR.call(void 0, async () => {
36
+ _chunk6T4UZ4LVjs.HMR.call(void 0, async () => {
37
37
  router.stack = originStack;
38
38
  registerRoute();
39
39
  });
40
40
  async function registerRoute() {
41
- _chunkH6NYBVBVjs.Context.usePlugin(globalPlugins, "express").forEach((p) => router.use(p));
41
+ _chunk6T4UZ4LVjs.Context.usePlugin(globalPlugins, "express").forEach((p) => router.use(p));
42
42
  if (parallelRoute) {
43
- router.post(parallelRoute, ..._chunkH6NYBVBVjs.Context.usePlugin(parallelPlugins, "express"), async (req, res, next) => {
43
+ router.post(parallelRoute, ..._chunk6T4UZ4LVjs.Context.usePlugin(parallelPlugins, "express"), async (req, res, next) => {
44
44
  const { body } = req;
45
45
  async function errorHandler(e) {
46
- const error = await _chunkH6NYBVBVjs.Context.filterRecord.default(e);
46
+ const error = await _chunk6T4UZ4LVjs.Context.filterRecord.default(e);
47
47
  return res.status(error.status).json(error);
48
48
  }
49
- _chunkFNJWO324js.__name.call(void 0, errorHandler, "errorHandler");
50
- if (!Array.isArray(body))
51
- return errorHandler(new (0, _chunkH6NYBVBVjs.BadRequestException)("data format should be an array"));
49
+ _chunkH2FWLKXNjs.__name.call(void 0, errorHandler, "errorHandler");
50
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunk6T4UZ4LVjs.BadRequestException)("data format should be an array"));
52
51
  try {
53
52
  return Promise.all(body.map((item, i) => {
54
53
  return new Promise(async (resolve) => {
55
54
  const { tag, func } = item;
56
55
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
57
- if (!metaMap.has(tag))
58
- return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
56
+ if (!metaMap.has(tag)) return resolve(await _chunk6T4UZ4LVjs.Context.filterRecord.default(new (0, _chunk6T4UZ4LVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
59
57
  const meta2 = metaMap.get(tag)[func];
60
- if (!meta2)
61
- return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
58
+ if (!meta2) return resolve(await _chunk6T4UZ4LVjs.Context.filterRecord.default(new (0, _chunk6T4UZ4LVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
62
59
  const { data: { params } } = meta2;
63
60
  const contextData = {
64
61
  type: "express",
@@ -72,9 +69,9 @@ function bind(router, data, opts = {}) {
72
69
  func,
73
70
  next,
74
71
  app: router,
75
- ..._chunkH6NYBVBVjs.argToReq.call(void 0, params, item.args, req.headers)
72
+ ..._chunk6T4UZ4LVjs.argToReq.call(void 0, params, item.args, req.headers)
76
73
  };
77
- const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
74
+ const context = new (0, _chunk6T4UZ4LVjs.Context)(contextData);
78
75
  context.run({
79
76
  globalGuards,
80
77
  globalInterceptors,
@@ -94,9 +91,8 @@ function bind(router, data, opts = {}) {
94
91
  for (const func in record) {
95
92
  const meta2 = metaMap.get(tag)[func];
96
93
  const { data: { plugins, http } } = meta2;
97
- if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
98
- continue;
99
- router[http.type](http.prefix + http.route, ..._chunkH6NYBVBVjs.Context.usePlugin(plugins, "express"), async (req, res, next) => {
94
+ if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
95
+ router[http.type](http.prefix + http.route, ..._chunk6T4UZ4LVjs.Context.usePlugin(plugins, "express"), async (req, res, next) => {
100
96
  debug(`invoke method "${func}" in module "${tag}"`);
101
97
  const contextData = {
102
98
  type: "express",
@@ -113,10 +109,9 @@ function bind(router, data, opts = {}) {
113
109
  app: router,
114
110
  next
115
111
  };
116
- const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
112
+ const context = new (0, _chunk6T4UZ4LVjs.Context)(contextData);
117
113
  if (http.headers) {
118
- for (const name in http.headers)
119
- res.set(name, http.headers[name]);
114
+ for (const name in http.headers) res.set(name, http.headers[name]);
120
115
  }
121
116
  await context.run({
122
117
  globalGuards,
@@ -124,24 +119,20 @@ function bind(router, data, opts = {}) {
124
119
  globalFilter,
125
120
  globalPipe
126
121
  }, (returnData) => {
127
- if (res.writableEnded)
128
- return;
129
- if (typeof returnData === "string")
130
- res.send(returnData);
131
- else
132
- res.json(returnData);
122
+ if (res.writableEnded) return;
123
+ if (typeof returnData === "string") res.send(returnData);
124
+ else res.json(returnData);
133
125
  }, (err) => {
134
- if (res.writableEnded)
135
- return;
126
+ if (res.writableEnded) return;
136
127
  res.status(err.status).json(err);
137
128
  });
138
129
  });
139
130
  }
140
131
  }
141
132
  }
142
- _chunkFNJWO324js.__name.call(void 0, registerRoute, "registerRoute");
133
+ _chunkH2FWLKXNjs.__name.call(void 0, registerRoute, "registerRoute");
143
134
  }
144
- _chunkFNJWO324js.__name.call(void 0, bind, "bind");
135
+ _chunkH2FWLKXNjs.__name.call(void 0, bind, "bind");
145
136
 
146
137
 
147
138
  exports.bind = bind;
@@ -5,10 +5,10 @@ import {
5
5
  argToReq,
6
6
  createControllerMetaMap,
7
7
  detectAopDep
8
- } from "../../chunk-Q4AGVGVA.mjs";
8
+ } from "../../chunk-2O6X54P5.mjs";
9
9
  import {
10
10
  __name
11
- } from "../../chunk-VYDBNZJ2.mjs";
11
+ } from "../../chunk-2NTXVYQC.mjs";
12
12
 
13
13
  // src/server/express/bind.ts
14
14
  import Debug from "debug";
@@ -47,18 +47,15 @@ function bind(router, data, opts = {}) {
47
47
  return res.status(error.status).json(error);
48
48
  }
49
49
  __name(errorHandler, "errorHandler");
50
- if (!Array.isArray(body))
51
- return errorHandler(new BadRequestException("data format should be an array"));
50
+ if (!Array.isArray(body)) return errorHandler(new BadRequestException("data format should be an array"));
52
51
  try {
53
52
  return Promise.all(body.map((item, i) => {
54
53
  return new Promise(async (resolve) => {
55
54
  const { tag, func } = item;
56
55
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
57
- if (!metaMap.has(tag))
58
- return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
56
+ if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
59
57
  const meta2 = metaMap.get(tag)[func];
60
- if (!meta2)
61
- return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
58
+ if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
62
59
  const { data: { params } } = meta2;
63
60
  const contextData = {
64
61
  type: "express",
@@ -94,8 +91,7 @@ function bind(router, data, opts = {}) {
94
91
  for (const func in record) {
95
92
  const meta2 = metaMap.get(tag)[func];
96
93
  const { data: { plugins, http } } = meta2;
97
- if (!http?.type)
98
- continue;
94
+ if (!http?.type) continue;
99
95
  router[http.type](http.prefix + http.route, ...Context.usePlugin(plugins, "express"), async (req, res, next) => {
100
96
  debug(`invoke method "${func}" in module "${tag}"`);
101
97
  const contextData = {
@@ -115,8 +111,7 @@ function bind(router, data, opts = {}) {
115
111
  };
116
112
  const context = new Context(contextData);
117
113
  if (http.headers) {
118
- for (const name in http.headers)
119
- res.set(name, http.headers[name]);
114
+ for (const name in http.headers) res.set(name, http.headers[name]);
120
115
  }
121
116
  await context.run({
122
117
  globalGuards,
@@ -124,15 +119,11 @@ function bind(router, data, opts = {}) {
124
119
  globalFilter,
125
120
  globalPipe
126
121
  }, (returnData) => {
127
- if (res.writableEnded)
128
- return;
129
- if (typeof returnData === "string")
130
- res.send(returnData);
131
- else
132
- res.json(returnData);
122
+ if (res.writableEnded) return;
123
+ if (typeof returnData === "string") res.send(returnData);
124
+ else res.json(returnData);
133
125
  }, (err) => {
134
- if (res.writableEnded)
135
- return;
126
+ if (res.writableEnded) return;
136
127
  res.status(err.status).json(err);
137
128
  });
138
129
  });
@@ -0,0 +1,20 @@
1
+ import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
2
+ import { a as HttpContext, H as HttpOptions } from '../../types-ByP1fKMe.mjs';
3
+ import { F as Factory } from '../../core-BIm7dkko.mjs';
4
+ import 'node:http';
5
+ import '../../types-CdQey96H.mjs';
6
+ import 'phecda-core';
7
+
8
+ interface FastifyCtx extends HttpContext {
9
+ type: 'fastify';
10
+ request: FastifyRequest;
11
+ response: FastifyReply;
12
+ app: FastifyInstance;
13
+ }
14
+ type Plugin = FastifyPluginCallback;
15
+ declare function bind(fastify: FastifyInstance, data: Awaited<ReturnType<typeof Factory>>, opts?: HttpOptions & {
16
+ fastifyOpts?: FastifyRegisterOptions<FastifyPluginOptions>;
17
+ }): void;
18
+ declare function Fastify(opts: RouteShorthandOptions): any;
19
+
20
+ export { Fastify, type FastifyCtx, type Plugin, bind };
@@ -1,8 +1,8 @@
1
1
  import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback, FastifyRegisterOptions, FastifyPluginOptions, RouteShorthandOptions } from 'fastify';
2
- import { a as HttpContext, H as HttpOptions } from '../../types-68f2ec2a.js';
3
- import { F as Factory } from '../../core-7f6d2be6.js';
2
+ import { a as HttpContext, H as HttpOptions } from '../../types-C5sdDiDQ.js';
3
+ import { F as Factory } from '../../core-C3cON4Um.js';
4
4
  import 'node:http';
5
- import '../../types-81be0ba3.js';
5
+ import '../../types-CdQey96H.js';
6
6
  import 'phecda-core';
7
7
 
8
8
  interface FastifyCtx extends HttpContext {
@@ -17,4 +17,4 @@ declare function bind(fastify: FastifyInstance, data: Awaited<ReturnType<typeof
17
17
  }): void;
18
18
  declare function Fastify(opts: RouteShorthandOptions): any;
19
19
 
20
- export { Fastify, FastifyCtx, Plugin, bind };
20
+ export { Fastify, type FastifyCtx, type Plugin, bind };
@@ -1,16 +1,16 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkAWY6FTH4js = require('../../chunk-AWY6FTH4.js');
3
+ var _chunk6QLTBEXPjs = require('../../chunk-6QLTBEXP.js');
4
4
 
5
5
 
6
6
 
7
7
 
8
8
 
9
9
 
10
- var _chunkH6NYBVBVjs = require('../../chunk-H6NYBVBV.js');
10
+ var _chunk6T4UZ4LVjs = require('../../chunk-6T4UZ4LV.js');
11
11
 
12
12
 
13
- var _chunkFNJWO324js = require('../../chunk-FNJWO324.js');
13
+ var _chunkH2FWLKXNjs = require('../../chunk-H2FWLKXN.js');
14
14
 
15
15
  // src/server/fastify/bind.ts
16
16
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
@@ -18,14 +18,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/fastify");
18
18
  function bind(fastify, data, opts = {}) {
19
19
  const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe, fastifyOpts } = opts;
20
20
  const { moduleMap, meta } = data;
21
- const metaMap = _chunkH6NYBVBVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
+ const metaMap = _chunk6T4UZ4LVjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
22
  const { controller, http, func, tag } = meta2.data;
23
23
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _2 => _2.type])) {
24
24
  debug(`register method "${func}" in module "${tag}"`);
25
25
  return true;
26
26
  }
27
27
  });
28
- _chunkH6NYBVBVjs.detectAopDep.call(void 0, meta, {
28
+ _chunk6T4UZ4LVjs.detectAopDep.call(void 0, meta, {
29
29
  plugins: [
30
30
  ...globalPlugins,
31
31
  ...parallelPlugins
@@ -34,12 +34,12 @@ function bind(fastify, data, opts = {}) {
34
34
  interceptors: globalInterceptors
35
35
  });
36
36
  fastify.register((fastify2, _, done) => {
37
- _chunkH6NYBVBVjs.Context.usePlugin(globalPlugins, "fastify").forEach((p) => {
37
+ _chunk6T4UZ4LVjs.Context.usePlugin(globalPlugins, "fastify").forEach((p) => {
38
38
  p[Symbol.for("skip-override")] = true;
39
39
  fastify2.register(p);
40
40
  });
41
41
  fastify2.register((fastify3, _opts, done2) => {
42
- _chunkH6NYBVBVjs.Context.usePlugin(parallelPlugins, "fastify").forEach((p) => {
42
+ _chunk6T4UZ4LVjs.Context.usePlugin(parallelPlugins, "fastify").forEach((p) => {
43
43
  p[Symbol.for("skip-override")] = true;
44
44
  fastify3.register(p);
45
45
  });
@@ -47,22 +47,19 @@ function bind(fastify, data, opts = {}) {
47
47
  fastify3.post(parallelRoute, async (req, res) => {
48
48
  const { body } = req;
49
49
  async function errorHandler(e) {
50
- const error = await _chunkH6NYBVBVjs.Context.filterRecord.default(e);
50
+ const error = await _chunk6T4UZ4LVjs.Context.filterRecord.default(e);
51
51
  return res.status(error.status).send(error);
52
52
  }
53
- _chunkFNJWO324js.__name.call(void 0, errorHandler, "errorHandler");
54
- if (!Array.isArray(body))
55
- return errorHandler(new (0, _chunkH6NYBVBVjs.BadRequestException)("data format should be an array"));
53
+ _chunkH2FWLKXNjs.__name.call(void 0, errorHandler, "errorHandler");
54
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunk6T4UZ4LVjs.BadRequestException)("data format should be an array"));
56
55
  try {
57
56
  return Promise.all(body.map((item, i) => {
58
57
  return new Promise(async (resolve) => {
59
58
  const { tag, func } = item;
60
59
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
61
- if (!metaMap.has(tag))
62
- return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
60
+ if (!metaMap.has(tag)) return resolve(await _chunk6T4UZ4LVjs.Context.filterRecord.default(new (0, _chunk6T4UZ4LVjs.BadRequestException)(`module "${tag}" doesn't exist`)));
63
61
  const meta2 = metaMap.get(tag)[func];
64
- if (!meta2)
65
- return resolve(await _chunkH6NYBVBVjs.Context.filterRecord.default(new (0, _chunkH6NYBVBVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
62
+ if (!meta2) return resolve(await _chunk6T4UZ4LVjs.Context.filterRecord.default(new (0, _chunk6T4UZ4LVjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
66
63
  const { data: { params } } = meta2;
67
64
  const contextData = {
68
65
  type: "fastify",
@@ -75,9 +72,9 @@ function bind(fastify, data, opts = {}) {
75
72
  tag,
76
73
  func,
77
74
  app: fastify3,
78
- ..._chunkH6NYBVBVjs.argToReq.call(void 0, params, item.args, req.headers)
75
+ ..._chunk6T4UZ4LVjs.argToReq.call(void 0, params, item.args, req.headers)
79
76
  };
80
- const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
77
+ const context = new (0, _chunk6T4UZ4LVjs.Context)(contextData);
81
78
  context.run({
82
79
  globalGuards,
83
80
  globalInterceptors,
@@ -99,10 +96,9 @@ function bind(fastify, data, opts = {}) {
99
96
  for (const func in record) {
100
97
  const meta2 = metaMap.get(tag)[func];
101
98
  const { data: { plugins, define, http } } = meta2;
102
- if (!_optionalChain([http, 'optionalAccess', _3 => _3.type]))
103
- continue;
99
+ if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
104
100
  fastify2.register((fastify3, _opts, done2) => {
105
- _chunkH6NYBVBVjs.Context.usePlugin(plugins, "fastify").forEach((p) => {
101
+ _chunk6T4UZ4LVjs.Context.usePlugin(plugins, "fastify").forEach((p) => {
106
102
  p[Symbol.for("skip-override")] = true;
107
103
  fastify3.register(p);
108
104
  });
@@ -122,10 +118,9 @@ function bind(fastify, data, opts = {}) {
122
118
  headers: req.headers,
123
119
  app: fastify3
124
120
  };
125
- const context = new (0, _chunkH6NYBVBVjs.Context)(contextData);
121
+ const context = new (0, _chunk6T4UZ4LVjs.Context)(contextData);
126
122
  if (http.headers) {
127
- for (const name in http.headers)
128
- res.header(name, http.headers[name]);
123
+ for (const name in http.headers) res.header(name, http.headers[name]);
129
124
  }
130
125
  return context.run({
131
126
  globalGuards,
@@ -133,12 +128,10 @@ function bind(fastify, data, opts = {}) {
133
128
  globalFilter,
134
129
  globalPipe
135
130
  }, (returnData) => {
136
- if (res.sent)
137
- return;
131
+ if (res.sent) return;
138
132
  return returnData;
139
133
  }, (err) => {
140
- if (res.sent)
141
- return;
134
+ if (res.sent) return;
142
135
  res.status(err.status).send(err);
143
136
  });
144
137
  });
@@ -149,11 +142,11 @@ function bind(fastify, data, opts = {}) {
149
142
  done();
150
143
  }, fastifyOpts);
151
144
  }
152
- _chunkFNJWO324js.__name.call(void 0, bind, "bind");
145
+ _chunkH2FWLKXNjs.__name.call(void 0, bind, "bind");
153
146
  function Fastify(opts) {
154
- return _chunkAWY6FTH4js.Define.call(void 0, "fastify", opts);
147
+ return _chunk6QLTBEXPjs.Define.call(void 0, "fastify", opts);
155
148
  }
156
- _chunkFNJWO324js.__name.call(void 0, Fastify, "Fastify");
149
+ _chunkH2FWLKXNjs.__name.call(void 0, Fastify, "Fastify");
157
150
 
158
151
 
159
152