phecda-server 8.0.1 → 8.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.
@@ -202,6 +202,9 @@ var WorkerException = class extends Exception {
202
202
 
203
203
  // src/pipe.ts
204
204
  var defaultPipe = /* @__PURE__ */ __name(async ({ arg, reflect, meta, index, type }, { method }) => {
205
+ if (meta.const) {
206
+ if (arg !== meta.const) throw new ValidateException(`param ${index + 1} must be ${meta.const}`);
207
+ }
205
208
  if (arg === void 0) {
206
209
  if (meta.required === false) return arg;
207
210
  else throw new ValidateException(`param ${index + 1} is required`);
@@ -228,8 +231,8 @@ var defaultPipe = /* @__PURE__ */ __name(async ({ arg, reflect, meta, index, typ
228
231
  }
229
232
  if (meta.oneOf) {
230
233
  let isCorrect = false;
231
- for (const modelOrRule of meta.oneOf) {
232
- switch (modelOrRule) {
234
+ for (const item of meta.oneOf) {
235
+ switch (item) {
233
236
  case String:
234
237
  if (typeof arg === "string") isCorrect = true;
235
238
  break;
@@ -240,18 +243,23 @@ var defaultPipe = /* @__PURE__ */ __name(async ({ arg, reflect, meta, index, typ
240
243
  if (typeof arg === "boolean") isCorrect = true;
241
244
  break;
242
245
  default:
243
- if (isPhecda(modelOrRule)) {
244
- const errs = await validate(modelOrRule, arg);
246
+ if (isPhecda(item)) {
247
+ const errs = await validate(item, arg);
245
248
  if (!errs.length) {
246
249
  isCorrect = true;
247
250
  break;
248
251
  }
249
- } else if (typeof modelOrRule === "function") {
250
- const ret = await modelOrRule(arg);
252
+ } else if (typeof item === "function") {
253
+ const ret = await item(arg);
251
254
  if (ret) {
252
255
  isCorrect = true;
253
256
  break;
254
257
  }
258
+ } else {
259
+ if (arg === item) {
260
+ isCorrect = true;
261
+ break;
262
+ }
255
263
  }
256
264
  }
257
265
  }
@@ -202,6 +202,9 @@ var WorkerException = class extends Exception {
202
202
 
203
203
  // src/pipe.ts
204
204
  var defaultPipe = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, async ({ arg, reflect, meta, index, type }, { method }) => {
205
+ if (meta.const) {
206
+ if (arg !== meta.const) throw new ValidateException(`param ${index + 1} must be ${meta.const}`);
207
+ }
205
208
  if (arg === void 0) {
206
209
  if (meta.required === false) return arg;
207
210
  else throw new ValidateException(`param ${index + 1} is required`);
@@ -228,8 +231,8 @@ var defaultPipe = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, async ({
228
231
  }
229
232
  if (meta.oneOf) {
230
233
  let isCorrect = false;
231
- for (const modelOrRule of meta.oneOf) {
232
- switch (modelOrRule) {
234
+ for (const item of meta.oneOf) {
235
+ switch (item) {
233
236
  case String:
234
237
  if (typeof arg === "string") isCorrect = true;
235
238
  break;
@@ -240,18 +243,23 @@ var defaultPipe = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, async ({
240
243
  if (typeof arg === "boolean") isCorrect = true;
241
244
  break;
242
245
  default:
243
- if (_phecdacore.isPhecda.call(void 0, modelOrRule)) {
244
- const errs = await _phecdacore.validate.call(void 0, modelOrRule, arg);
246
+ if (_phecdacore.isPhecda.call(void 0, item)) {
247
+ const errs = await _phecdacore.validate.call(void 0, item, arg);
245
248
  if (!errs.length) {
246
249
  isCorrect = true;
247
250
  break;
248
251
  }
249
- } else if (typeof modelOrRule === "function") {
250
- const ret = await modelOrRule(arg);
252
+ } else if (typeof item === "function") {
253
+ const ret = await item(arg);
251
254
  if (ret) {
252
255
  isCorrect = true;
253
256
  break;
254
257
  }
258
+ } else {
259
+ if (arg === item) {
260
+ isCorrect = true;
261
+ break;
262
+ }
255
263
  }
256
264
  }
257
265
  }
package/dist/helper.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkLD7YMHIEjs = require('./chunk-LD7YMHIE.js');
8
+ var _chunkHKN3AAB2js = require('./chunk-HKN3AAB2.js');
9
9
 
10
10
 
11
11
 
@@ -21,4 +21,4 @@ var _chunk4LLLQOMFjs = require('./chunk-4LLLQOMF.js');
21
21
 
22
22
 
23
23
 
24
- exports.HMR = _chunk4LLLQOMFjs.HMR; exports.RELAUNCH = _chunk4LLLQOMFjs.RELAUNCH; exports.RELOAD = _chunk4LLLQOMFjs.RELOAD; exports.createControllerMetaMap = _chunkLD7YMHIEjs.createControllerMetaMap; exports.detectAopDep = _chunkLD7YMHIEjs.detectAopDep; exports.joinUrl = _chunkLD7YMHIEjs.joinUrl; exports.mergeObject = _chunkLD7YMHIEjs.mergeObject; exports.resolveDep = _chunkLD7YMHIEjs.resolveDep; exports.shallowClone = _chunkLD7YMHIEjs.shallowClone;
24
+ exports.HMR = _chunk4LLLQOMFjs.HMR; exports.RELAUNCH = _chunk4LLLQOMFjs.RELAUNCH; exports.RELOAD = _chunk4LLLQOMFjs.RELOAD; exports.createControllerMetaMap = _chunkHKN3AAB2js.createControllerMetaMap; exports.detectAopDep = _chunkHKN3AAB2js.detectAopDep; exports.joinUrl = _chunkHKN3AAB2js.joinUrl; exports.mergeObject = _chunkHKN3AAB2js.mergeObject; exports.resolveDep = _chunkHKN3AAB2js.resolveDep; exports.shallowClone = _chunkHKN3AAB2js.shallowClone;
package/dist/helper.mjs CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  mergeObject,
6
6
  resolveDep,
7
7
  shallowClone
8
- } from "./chunk-G5IH3TP7.mjs";
8
+ } from "./chunk-BLLRB5DQ.mjs";
9
9
  import {
10
10
  HMR,
11
11
  RELAUNCH,
@@ -7,7 +7,7 @@ var _chunkUYZSUBX4js = require('../../chunk-UYZSUBX4.js');
7
7
 
8
8
 
9
9
 
10
- var _chunkLD7YMHIEjs = require('../../chunk-LD7YMHIE.js');
10
+ var _chunkHKN3AAB2js = require('../../chunk-HKN3AAB2.js');
11
11
 
12
12
 
13
13
  var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
@@ -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, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
21
21
  const { moduleMap, meta } = data;
22
- const metaMap = _chunkLD7YMHIEjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
+ const metaMap = _chunkHKN3AAB2js.createControllerMetaMap.call(void 0, meta, (meta2) => {
23
23
  const { controller, http, method, tag } = meta2.data;
24
24
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
25
25
  debug(`register method "${method}" in module "${tag}"`);
26
26
  return true;
27
27
  }
28
28
  });
29
- _chunkLD7YMHIEjs.detectAopDep.call(void 0, meta, {
29
+ _chunkHKN3AAB2js.detectAopDep.call(void 0, meta, {
30
30
  addons: [
31
31
  ...globalAddons,
32
32
  ...parallelAddons
@@ -35,29 +35,29 @@ function bind(app, data, opts = {}) {
35
35
  });
36
36
  registerRoute();
37
37
  function registerRoute() {
38
- _chunkLD7YMHIEjs.Context.applyAddons(globalAddons, app, "elysia");
38
+ _chunkHKN3AAB2js.Context.applyAddons(globalAddons, app, "elysia");
39
39
  if (parallelRoute) {
40
40
  const parallelRouter = new (0, _elysia.Elysia)();
41
- _chunkLD7YMHIEjs.Context.applyAddons(parallelAddons, app, "elysia");
41
+ _chunkHKN3AAB2js.Context.applyAddons(parallelAddons, app, "elysia");
42
42
  parallelRouter.post(parallelRoute, async (c) => {
43
43
  const { body } = c;
44
44
  async function errorHandler(e) {
45
- const error = await _chunkLD7YMHIEjs.Context.filterRecord.default(e);
45
+ const error = await _chunkHKN3AAB2js.Context.filterRecord.default(e);
46
46
  c.set.status = error.status;
47
47
  return error;
48
48
  }
49
49
  _chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
50
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkLD7YMHIEjs.BadRequestException)("data format should be an array"));
50
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkHKN3AAB2js.BadRequestException)("data format should be an array"));
51
51
  try {
52
52
  return Promise.all(body.map((item, i) => {
53
53
  return new Promise(async (resolve) => {
54
54
  if (!item) return resolve(null);
55
55
  const { tag, method } = item;
56
56
  debug(`(parallel)invoke method "${method}" in module "${tag}"`);
57
- if (!metaMap.has(tag)) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`module "${tag}" doesn't exist`)));
57
+ if (!metaMap.has(tag)) return resolve(await _chunkHKN3AAB2js.Context.filterRecord.default(new (0, _chunkHKN3AAB2js.BadRequestException)(`module "${tag}" doesn't exist`)));
58
58
  const meta2 = metaMap.get(tag)[method];
59
- if (!meta2) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
60
- const aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
59
+ if (!meta2) return resolve(await _chunkHKN3AAB2js.Context.filterRecord.default(new (0, _chunkHKN3AAB2js.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
60
+ const aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
61
61
  globalGuards,
62
62
  globalFilter,
63
63
  globalPipe
@@ -88,7 +88,7 @@ function bind(app, data, opts = {}) {
88
88
  throw new Error("elysia can't support getResponse");
89
89
  }, "getResponse")
90
90
  };
91
- const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
91
+ const context = new (0, _chunkHKN3AAB2js.Context)(contextData);
92
92
  context.run(aop, resolve, resolve);
93
93
  });
94
94
  })).then((ret) => {
@@ -110,14 +110,14 @@ function bind(app, data, opts = {}) {
110
110
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.method])) continue;
111
111
  let aop;
112
112
  if (!dynamic) {
113
- aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
113
+ aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
114
114
  globalFilter,
115
115
  globalGuards,
116
116
  globalPipe
117
117
  });
118
118
  }
119
- _chunkLD7YMHIEjs.Context.applyAddons(addons, subApp, "elysia");
120
- subApp[http.method](_chunkLD7YMHIEjs.joinUrl.call(void 0, http.prefix, http.route), async (c) => {
119
+ _chunkHKN3AAB2js.Context.applyAddons(addons, subApp, "elysia");
120
+ subApp[http.method](_chunkHKN3AAB2js.joinUrl.call(void 0, http.prefix, http.route), async (c) => {
121
121
  debug(`invoke method "${method}" in module "${tag}"`);
122
122
  const contextData = {
123
123
  type: "elysia",
@@ -149,16 +149,16 @@ function bind(app, data, opts = {}) {
149
149
  }, "getResponse")
150
150
  };
151
151
  if (dynamic) {
152
- aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
152
+ aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
153
153
  globalFilter,
154
154
  globalGuards,
155
155
  globalPipe
156
156
  });
157
157
  }
158
- const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
158
+ const context = new (0, _chunkHKN3AAB2js.Context)(contextData);
159
159
  if (http.headers) c.set.headers = http.headers;
160
160
  if (dynamic) {
161
- aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
161
+ aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
162
162
  globalFilter,
163
163
  globalGuards,
164
164
  globalPipe
@@ -7,7 +7,7 @@ import {
7
7
  createControllerMetaMap,
8
8
  detectAopDep,
9
9
  joinUrl
10
- } from "../../chunk-G5IH3TP7.mjs";
10
+ } from "../../chunk-BLLRB5DQ.mjs";
11
11
  import {
12
12
  __name
13
13
  } from "../../chunk-NQ55PA2X.mjs";
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkLD7YMHIEjs = require('../../chunk-LD7YMHIE.js');
7
+ var _chunkHKN3AAB2js = require('../../chunk-HKN3AAB2.js');
8
8
 
9
9
 
10
10
 
@@ -18,14 +18,14 @@ function bind(router, data, opts = {}) {
18
18
  const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
19
19
  const { moduleMap, meta } = data;
20
20
  const originStack = router.stack.slice(0, router.stack.length);
21
- const metaMap = _chunkLD7YMHIEjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
+ const metaMap = _chunkHKN3AAB2js.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
22
  const { controller, http, method, tag } = meta2.data;
23
23
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
24
24
  debug(`register method "${method}" in module "${tag}"`);
25
25
  return true;
26
26
  }
27
27
  });
28
- _chunkLD7YMHIEjs.detectAopDep.call(void 0, meta, {
28
+ _chunkHKN3AAB2js.detectAopDep.call(void 0, meta, {
29
29
  addons: [
30
30
  ...globalAddons,
31
31
  ...parallelAddons
@@ -38,28 +38,28 @@ function bind(router, data, opts = {}) {
38
38
  registerRoute();
39
39
  });
40
40
  function registerRoute() {
41
- _chunkLD7YMHIEjs.Context.applyAddons(globalAddons, router, "express");
41
+ _chunkHKN3AAB2js.Context.applyAddons(globalAddons, router, "express");
42
42
  if (parallelRoute) {
43
43
  const subRouter = _express.Router.call(void 0, );
44
- _chunkLD7YMHIEjs.Context.applyAddons(parallelAddons, subRouter, "express");
44
+ _chunkHKN3AAB2js.Context.applyAddons(parallelAddons, subRouter, "express");
45
45
  subRouter.use(async (req, res, next) => {
46
46
  const { body } = req;
47
47
  async function errorHandler(e) {
48
- const error = await _chunkLD7YMHIEjs.Context.filterRecord.default(e);
48
+ const error = await _chunkHKN3AAB2js.Context.filterRecord.default(e);
49
49
  return res.status(error.status).json(error);
50
50
  }
51
51
  _chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
52
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkLD7YMHIEjs.BadRequestException)("data format should be an array"));
52
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkHKN3AAB2js.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
  if (!item) return resolve(null);
57
57
  const { tag, method } = item;
58
58
  debug(`(parallel)invoke method "${method}" in module "${tag}"`);
59
- if (!metaMap.has(tag)) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`module "${tag}" doesn't exist`)));
59
+ if (!metaMap.has(tag)) return resolve(await _chunkHKN3AAB2js.Context.filterRecord.default(new (0, _chunkHKN3AAB2js.BadRequestException)(`module "${tag}" doesn't exist`)));
60
60
  const meta2 = metaMap.get(tag)[method];
61
- if (!meta2) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
62
- const aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
61
+ if (!meta2) return resolve(await _chunkHKN3AAB2js.Context.filterRecord.default(new (0, _chunkHKN3AAB2js.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
62
+ const aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
63
63
  globalFilter,
64
64
  globalGuards,
65
65
  globalPipe
@@ -87,7 +87,7 @@ function bind(router, data, opts = {}) {
87
87
  getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req, "getRequest"),
88
88
  getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res, "getResponse")
89
89
  };
90
- const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
90
+ const context = new (0, _chunkHKN3AAB2js.Context)(contextData);
91
91
  context.run(aop, resolve, resolve);
92
92
  });
93
93
  })).then((ret) => {
@@ -106,15 +106,15 @@ function bind(router, data, opts = {}) {
106
106
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.method])) continue;
107
107
  let aop;
108
108
  if (!dynamic) {
109
- aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
109
+ aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
110
110
  globalFilter,
111
111
  globalGuards,
112
112
  globalPipe
113
113
  });
114
114
  }
115
115
  const subRouter = _express.Router.call(void 0, );
116
- _chunkLD7YMHIEjs.Context.applyAddons(addons, subRouter, "express");
117
- subRouter[http.method](_chunkLD7YMHIEjs.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
116
+ _chunkHKN3AAB2js.Context.applyAddons(addons, subRouter, "express");
117
+ subRouter[http.method](_chunkHKN3AAB2js.joinUrl.call(void 0, http.prefix, http.route), async (req, res, next) => {
118
118
  debug(`invoke method "${method}" in module "${tag}"`);
119
119
  const contextData = {
120
120
  type: "express",
@@ -142,10 +142,10 @@ function bind(router, data, opts = {}) {
142
142
  getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req, "getRequest"),
143
143
  getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res, "getResponse")
144
144
  };
145
- const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
145
+ const context = new (0, _chunkHKN3AAB2js.Context)(contextData);
146
146
  if (http.headers) res.set(http.headers);
147
147
  if (dynamic) {
148
- aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
148
+ aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
149
149
  globalFilter,
150
150
  globalGuards,
151
151
  globalPipe
@@ -4,7 +4,7 @@ import {
4
4
  createControllerMetaMap,
5
5
  detectAopDep,
6
6
  joinUrl
7
- } from "../../chunk-G5IH3TP7.mjs";
7
+ } from "../../chunk-BLLRB5DQ.mjs";
8
8
  import {
9
9
  HMR,
10
10
  __name
@@ -7,7 +7,7 @@ var _chunkUYZSUBX4js = require('../../chunk-UYZSUBX4.js');
7
7
 
8
8
 
9
9
 
10
- var _chunkLD7YMHIEjs = require('../../chunk-LD7YMHIE.js');
10
+ var _chunkHKN3AAB2js = require('../../chunk-HKN3AAB2.js');
11
11
 
12
12
 
13
13
  var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
@@ -18,14 +18,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/fastify");
18
18
  function bind(fastify, data, opts = {}) {
19
19
  const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, fastifyOpts, dynamic = false } = opts;
20
20
  const { moduleMap, meta } = data;
21
- const metaMap = _chunkLD7YMHIEjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
+ const metaMap = _chunkHKN3AAB2js.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
22
  const { controller, http, method, tag } = meta2.data;
23
23
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _2 => _2.method])) {
24
24
  debug(`register method "${method}" in module "${tag}"`);
25
25
  return true;
26
26
  }
27
27
  });
28
- _chunkLD7YMHIEjs.detectAopDep.call(void 0, meta, {
28
+ _chunkHKN3AAB2js.detectAopDep.call(void 0, meta, {
29
29
  addons: [
30
30
  ...globalAddons,
31
31
  ...parallelAddons
@@ -33,28 +33,28 @@ function bind(fastify, data, opts = {}) {
33
33
  guards: globalGuards
34
34
  });
35
35
  fastify.register(async (fastify2, _, done) => {
36
- _chunkLD7YMHIEjs.Context.applyAddons(globalAddons, fastify2, "fastify");
36
+ _chunkHKN3AAB2js.Context.applyAddons(globalAddons, fastify2, "fastify");
37
37
  if (parallelRoute) {
38
38
  fastify2.register(async (fastify3, _opts, done2) => {
39
- _chunkLD7YMHIEjs.Context.applyAddons(parallelAddons, fastify3, "fastify");
39
+ _chunkHKN3AAB2js.Context.applyAddons(parallelAddons, fastify3, "fastify");
40
40
  fastify3.post(parallelRoute, async (req, res) => {
41
41
  const { body } = req;
42
42
  async function errorHandler(e) {
43
- const error = await _chunkLD7YMHIEjs.Context.filterRecord.default(e);
43
+ const error = await _chunkHKN3AAB2js.Context.filterRecord.default(e);
44
44
  return res.status(error.status).send(error);
45
45
  }
46
46
  _chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
47
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkLD7YMHIEjs.BadRequestException)("data format should be an array"));
47
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkHKN3AAB2js.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
  if (!item) return resolve(null);
52
52
  const { tag, method } = item;
53
53
  debug(`(parallel)invoke method "${method}" in module "${tag}"`);
54
- if (!metaMap.has(tag)) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`module "${tag}" doesn't exist`)));
54
+ if (!metaMap.has(tag)) return resolve(await _chunkHKN3AAB2js.Context.filterRecord.default(new (0, _chunkHKN3AAB2js.BadRequestException)(`module "${tag}" doesn't exist`)));
55
55
  const meta2 = metaMap.get(tag)[method];
56
- if (!meta2) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
57
- const aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
56
+ if (!meta2) return resolve(await _chunkHKN3AAB2js.Context.filterRecord.default(new (0, _chunkHKN3AAB2js.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
57
+ const aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
58
58
  globalFilter,
59
59
  globalGuards,
60
60
  globalPipe
@@ -82,7 +82,7 @@ function bind(fastify, data, opts = {}) {
82
82
  getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req.raw, "getRequest"),
83
83
  getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res.raw, "getResponse")
84
84
  };
85
- const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
85
+ const context = new (0, _chunkHKN3AAB2js.Context)(contextData);
86
86
  context.run(aop, resolve, resolve);
87
87
  });
88
88
  })).then((ret) => {
@@ -101,16 +101,16 @@ function bind(fastify, data, opts = {}) {
101
101
  const { data: { addons, define, http } } = meta2;
102
102
  if (!_optionalChain([http, 'optionalAccess', _3 => _3.method])) continue;
103
103
  fastify2.register(async (fastify3, _opts, done2) => {
104
- _chunkLD7YMHIEjs.Context.applyAddons(addons, fastify3, "fastify");
104
+ _chunkHKN3AAB2js.Context.applyAddons(addons, fastify3, "fastify");
105
105
  let aop;
106
106
  if (!dynamic) {
107
- aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
107
+ aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
108
108
  globalFilter,
109
109
  globalGuards,
110
110
  globalPipe
111
111
  });
112
112
  }
113
- fastify3[http.method](_chunkLD7YMHIEjs.joinUrl.call(void 0, http.prefix, http.route), _optionalChain([define, 'optionalAccess', _4 => _4.fastify]) || {}, async (req, res) => {
113
+ fastify3[http.method](_chunkHKN3AAB2js.joinUrl.call(void 0, http.prefix, http.route), _optionalChain([define, 'optionalAccess', _4 => _4.fastify]) || {}, async (req, res) => {
114
114
  debug(`invoke method "${method}" in module "${tag}"`);
115
115
  const contextData = {
116
116
  type: "fastify",
@@ -140,10 +140,10 @@ function bind(fastify, data, opts = {}) {
140
140
  getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => req.raw, "getRequest"),
141
141
  getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => res.raw, "getResponse")
142
142
  };
143
- const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
143
+ const context = new (0, _chunkHKN3AAB2js.Context)(contextData);
144
144
  if (http.headers) res.headers(http.headers);
145
145
  if (dynamic) {
146
- aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
146
+ aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
147
147
  globalFilter,
148
148
  globalGuards,
149
149
  globalPipe
@@ -7,7 +7,7 @@ import {
7
7
  createControllerMetaMap,
8
8
  detectAopDep,
9
9
  joinUrl
10
- } from "../../chunk-G5IH3TP7.mjs";
10
+ } from "../../chunk-BLLRB5DQ.mjs";
11
11
  import {
12
12
  __name
13
13
  } from "../../chunk-NQ55PA2X.mjs";
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkLD7YMHIEjs = require('../../chunk-LD7YMHIE.js');
7
+ var _chunkHKN3AAB2js = require('../../chunk-HKN3AAB2.js');
8
8
 
9
9
 
10
10
  var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
@@ -16,14 +16,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/h3");
16
16
  function bind(router, data, opts = {}) {
17
17
  const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
18
18
  const { moduleMap, meta } = data;
19
- const metaMap = _chunkLD7YMHIEjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
19
+ const metaMap = _chunkHKN3AAB2js.createControllerMetaMap.call(void 0, meta, (meta2) => {
20
20
  const { controller, http, method, tag } = meta2.data;
21
21
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.method])) {
22
22
  debug(`register method "${method}" in module "${tag}"`);
23
23
  return true;
24
24
  }
25
25
  });
26
- _chunkLD7YMHIEjs.detectAopDep.call(void 0, meta, {
26
+ _chunkHKN3AAB2js.detectAopDep.call(void 0, meta, {
27
27
  addons: [
28
28
  ...globalAddons,
29
29
  ...parallelAddons
@@ -32,32 +32,32 @@ function bind(router, data, opts = {}) {
32
32
  });
33
33
  registerRoute();
34
34
  function registerRoute() {
35
- _chunkLD7YMHIEjs.Context.applyAddons(globalAddons, router, "h3");
35
+ _chunkHKN3AAB2js.Context.applyAddons(globalAddons, router, "h3");
36
36
  if (parallelRoute) {
37
37
  const subRouter = _h3.createRouter.call(void 0, );
38
- _chunkLD7YMHIEjs.Context.applyAddons(parallelAddons, subRouter, "h3");
38
+ _chunkHKN3AAB2js.Context.applyAddons(parallelAddons, subRouter, "h3");
39
39
  subRouter.post(parallelRoute, _h3.eventHandler.call(void 0, {
40
40
  handler: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, async (event) => {
41
41
  const body = await _h3.readBody.call(void 0, event, {
42
42
  strict: true
43
43
  });
44
44
  async function errorHandler(e) {
45
- const error = await _chunkLD7YMHIEjs.Context.filterRecord.default(e);
45
+ const error = await _chunkHKN3AAB2js.Context.filterRecord.default(e);
46
46
  _h3.setResponseStatus.call(void 0, event, error.status);
47
47
  return error;
48
48
  }
49
49
  _chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
50
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkLD7YMHIEjs.BadRequestException)("data format should be an array"));
50
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkHKN3AAB2js.BadRequestException)("data format should be an array"));
51
51
  try {
52
52
  return Promise.all(body.map((item, i) => {
53
53
  return new Promise(async (resolve) => {
54
54
  if (!item) return resolve(null);
55
55
  const { tag, method } = item;
56
56
  debug(`(parallel)invoke method "${method}" in module "${tag}"`);
57
- if (!metaMap.has(tag)) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`module "${tag}" doesn't exist`)));
57
+ if (!metaMap.has(tag)) return resolve(await _chunkHKN3AAB2js.Context.filterRecord.default(new (0, _chunkHKN3AAB2js.BadRequestException)(`module "${tag}" doesn't exist`)));
58
58
  const meta2 = metaMap.get(tag)[method];
59
- if (!meta2) return resolve(await _chunkLD7YMHIEjs.Context.filterRecord.default(new (0, _chunkLD7YMHIEjs.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
60
- const aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
59
+ if (!meta2) return resolve(await _chunkHKN3AAB2js.Context.filterRecord.default(new (0, _chunkHKN3AAB2js.BadRequestException)(`"${method}" in "${tag}" doesn't exist`)));
60
+ const aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
61
61
  globalFilter,
62
62
  globalGuards,
63
63
  globalPipe
@@ -81,7 +81,7 @@ function bind(router, data, opts = {}) {
81
81
  getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.req, "getRequest"),
82
82
  getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.res, "getResponse")
83
83
  };
84
- const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
84
+ const context = new (0, _chunkHKN3AAB2js.Context)(contextData);
85
85
  context.run(aop, resolve, resolve);
86
86
  });
87
87
  }));
@@ -100,15 +100,15 @@ function bind(router, data, opts = {}) {
100
100
  const needBody = params.some((item) => item.type === "body");
101
101
  let aop;
102
102
  if (!dynamic) {
103
- aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
103
+ aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
104
104
  globalFilter,
105
105
  globalGuards,
106
106
  globalPipe
107
107
  });
108
108
  }
109
109
  const subRouter = _h3.createRouter.call(void 0, );
110
- _chunkLD7YMHIEjs.Context.applyAddons(addons, subRouter, "h3");
111
- subRouter[http.method](_chunkLD7YMHIEjs.joinUrl.call(void 0, http.prefix, http.route), _h3.defineEventHandler.call(void 0, async (event) => {
110
+ _chunkHKN3AAB2js.Context.applyAddons(addons, subRouter, "h3");
111
+ subRouter[http.method](_chunkHKN3AAB2js.joinUrl.call(void 0, http.prefix, http.route), _h3.defineEventHandler.call(void 0, async (event) => {
112
112
  debug(`invoke method "${method}" in module "${tag}"`);
113
113
  const contextData = {
114
114
  type: "h3",
@@ -134,10 +134,10 @@ function bind(router, data, opts = {}) {
134
134
  getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.req, "getRequest"),
135
135
  getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => event.node.res, "getResponse")
136
136
  };
137
- const context = new (0, _chunkLD7YMHIEjs.Context)(contextData);
137
+ const context = new (0, _chunkHKN3AAB2js.Context)(contextData);
138
138
  _h3.setHeaders.call(void 0, event, http.headers || {});
139
139
  if (dynamic) {
140
- aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
140
+ aop = _chunkHKN3AAB2js.Context.getAop(meta2, {
141
141
  globalFilter,
142
142
  globalGuards,
143
143
  globalPipe
@@ -148,7 +148,7 @@ function bind(router, data, opts = {}) {
148
148
  return err;
149
149
  });
150
150
  }));
151
- router.use(_chunkLD7YMHIEjs.joinUrl.call(void 0, http.prefix, http.route), _h3.useBase.call(void 0, "", subRouter.handler));
151
+ router.use(_chunkHKN3AAB2js.joinUrl.call(void 0, http.prefix, http.route), _h3.useBase.call(void 0, "", subRouter.handler));
152
152
  }
153
153
  }
154
154
  }
@@ -4,7 +4,7 @@ import {
4
4
  createControllerMetaMap,
5
5
  detectAopDep,
6
6
  joinUrl
7
- } from "../../chunk-G5IH3TP7.mjs";
7
+ } from "../../chunk-BLLRB5DQ.mjs";
8
8
  import {
9
9
  __name
10
10
  } from "../../chunk-NQ55PA2X.mjs";