@moostjs/event-http 0.6.8 → 0.6.10

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.
package/dist/index.cjs CHANGED
@@ -1,33 +1,11 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- const __wooksjs_event_core = __toESM(require("@wooksjs/event-core"));
25
- const __wooksjs_event_http = __toESM(require("@wooksjs/event-http"));
26
- const moost = __toESM(require("moost"));
27
- const __wooksjs_http_body = __toESM(require("@wooksjs/http-body"));
28
- const __prostojs_infact = __toESM(require("@prostojs/infact"));
29
- const http = __toESM(require("http"));
30
- const https = __toESM(require("https"));
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _wooksjs_event_core = require("@wooksjs/event-core");
3
+ let _wooksjs_event_http = require("@wooksjs/event-http");
4
+ let moost = require("moost");
5
+ let _wooksjs_http_body = require("@wooksjs/http-body");
6
+ let _prostojs_infact = require("@prostojs/infact");
7
+ let http = require("http");
8
+ let https = require("https");
31
9
 
32
10
  //#region packages/event-http/src/auth-guard.ts
33
11
  function _define_property$1(obj, key, value) {
@@ -55,25 +33,25 @@ function _ts_param(paramIndex, decorator) {
55
33
  };
56
34
  }
57
35
  /** Extracts auth credentials from the current request based on transport declarations. Throws 401 if none found. */ function extractTransports(declaration) {
58
- const ctx = (0, __wooksjs_event_core.current)();
36
+ const ctx = (0, _wooksjs_event_core.current)();
59
37
  const result = {};
60
38
  let found = false;
61
39
  if (declaration.bearer) {
62
- const auth = (0, __wooksjs_event_http.useAuthorization)(ctx);
40
+ const auth = (0, _wooksjs_event_http.useAuthorization)(ctx);
63
41
  if (auth.is("bearer")) {
64
42
  result.bearer = auth.credentials();
65
43
  found = true;
66
44
  }
67
45
  }
68
46
  if (declaration.basic) {
69
- const auth = (0, __wooksjs_event_http.useAuthorization)(ctx);
47
+ const auth = (0, _wooksjs_event_http.useAuthorization)(ctx);
70
48
  if (auth.is("basic")) {
71
49
  result.basic = auth.basicCredentials();
72
50
  found = true;
73
51
  }
74
52
  }
75
53
  if (declaration.cookie) {
76
- const { getCookie } = (0, __wooksjs_event_http.useCookies)(ctx);
54
+ const { getCookie } = (0, _wooksjs_event_http.useCookies)(ctx);
77
55
  const val = getCookie(declaration.cookie.name);
78
56
  if (val) {
79
57
  result.cookie = val;
@@ -83,20 +61,20 @@ function _ts_param(paramIndex, decorator) {
83
61
  if (declaration.apiKey) {
84
62
  const { name, in: location } = declaration.apiKey;
85
63
  if (location === "header") {
86
- const headers = (0, __wooksjs_event_http.useHeaders)(ctx);
64
+ const headers = (0, _wooksjs_event_http.useHeaders)(ctx);
87
65
  if (headers[name.toLowerCase()]) {
88
66
  result.apiKey = headers[name.toLowerCase()];
89
67
  found = true;
90
68
  }
91
69
  } else if (location === "query") {
92
- const { params } = (0, __wooksjs_event_http.useUrlParams)(ctx);
70
+ const { params } = (0, _wooksjs_event_http.useUrlParams)(ctx);
93
71
  const val = params().get(name);
94
72
  if (val) {
95
73
  result.apiKey = String(val);
96
74
  found = true;
97
75
  }
98
76
  } else if (location === "cookie") {
99
- const { getCookie } = (0, __wooksjs_event_http.useCookies)(ctx);
77
+ const { getCookie } = (0, _wooksjs_event_http.useCookies)(ctx);
100
78
  const val = getCookie(name);
101
79
  if (val) {
102
80
  result.apiKey = val;
@@ -104,7 +82,7 @@ function _ts_param(paramIndex, decorator) {
104
82
  }
105
83
  }
106
84
  }
107
- if (!found) throw new __wooksjs_event_http.HttpError(401, "No authentication credentials provided");
85
+ if (!found) throw new _wooksjs_event_http.HttpError(401, "No authentication credentials provided");
108
86
  return result;
109
87
  }
110
88
  /**
@@ -113,11 +91,9 @@ function _ts_param(paramIndex, decorator) {
113
91
  * Return a value from the handler to short-circuit with that response.
114
92
  */ function defineAuthGuard(transports, handler) {
115
93
  const def = (0, moost.defineBeforeInterceptor)((reply) => {
116
- const extracted = extractTransports(transports);
117
- const result = handler(extracted);
94
+ const result = handler(extractTransports(transports));
118
95
  if (result !== null && result !== void 0 && typeof result.then === "function") return result.then((r) => {
119
96
  if (r !== void 0) reply(r);
120
- return void 0;
121
97
  });
122
98
  if (result !== void 0) reply(result);
123
99
  }, moost.TInterceptorPriority.GUARD);
@@ -130,7 +106,6 @@ var AuthGuard = class {
130
106
  const result = this.handle(extracted);
131
107
  if (result !== null && result !== void 0 && typeof result.then === "function") return result.then((r) => {
132
108
  if (r !== void 0) reply(r);
133
- return void 0;
134
109
  });
135
110
  if (result !== void 0) reply(result);
136
111
  }
@@ -207,7 +182,7 @@ function createRef(getter, setter) {
207
182
  * @decorator
208
183
  * @paramType TStatusRef
209
184
  */ const StatusRef = () => (0, moost.Resolve)((metas, level) => {
210
- const response = (0, __wooksjs_event_http.useResponse)();
185
+ const response = (0, _wooksjs_event_http.useResponse)();
211
186
  if (level === "PARAM") return createRef(() => response.status, (v) => {
212
187
  response.status = v;
213
188
  });
@@ -229,7 +204,7 @@ function createRef(getter, setter) {
229
204
  * @param name - header name
230
205
  * @paramType THeaderRef
231
206
  */ const HeaderRef = (name) => (0, moost.Resolve)((metas, level) => {
232
- const response = (0, __wooksjs_event_http.useResponse)();
207
+ const response = (0, _wooksjs_event_http.useResponse)();
233
208
  if (level === "PARAM") return createRef(() => response.getHeader(name), (v) => response.setHeader(name, v));
234
209
  if (level === "PROP" && metas.instance && metas.key) {
235
210
  const initialValue = metas.instance[metas.key];
@@ -247,7 +222,7 @@ function createRef(getter, setter) {
247
222
  * @param name - cookie name
248
223
  * @paramType TCookieRef
249
224
  */ const CookieRef = (name) => (0, moost.Resolve)((metas, level) => {
250
- const response = (0, __wooksjs_event_http.useResponse)();
225
+ const response = (0, _wooksjs_event_http.useResponse)();
251
226
  if (level === "PARAM") return createRef(() => response.getCookie(name)?.value, (v) => response.setCookie(name, v ?? ""));
252
227
  if (level === "PROP" && metas.instance && metas.key) {
253
228
  const initialValue = metas.instance[metas.key];
@@ -265,7 +240,7 @@ function createRef(getter, setter) {
265
240
  * @param name - cookie name
266
241
  * @paramType TCookieAttributes
267
242
  */ const CookieAttrsRef = (name) => (0, moost.Resolve)((metas, level) => {
268
- const response = (0, __wooksjs_event_http.useResponse)();
243
+ const response = (0, _wooksjs_event_http.useResponse)();
269
244
  const getAttrs = () => response.getCookie(name)?.attrs ?? {};
270
245
  const setAttrs = (v) => {
271
246
  const existing = response.getCookie(name);
@@ -289,14 +264,14 @@ function createRef(getter, setter) {
289
264
  * @paramType string
290
265
  */ function Authorization(name) {
291
266
  return (0, moost.Resolve)(() => {
292
- const auth = (0, __wooksjs_event_http.useAuthorization)();
267
+ const auth = (0, _wooksjs_event_http.useAuthorization)();
293
268
  switch (name) {
294
269
  case "username": return auth.is("basic") ? auth.basicCredentials()?.username : void 0;
295
270
  case "password": return auth.is("basic") ? auth.basicCredentials()?.password : void 0;
296
271
  case "bearer": return auth.is("bearer") ? auth.authorization : void 0;
297
272
  case "raw": return auth.credentials();
298
273
  case "type": return auth.type();
299
- default: return void 0;
274
+ default: return;
300
275
  }
301
276
  }, "authorization");
302
277
  }
@@ -307,8 +282,7 @@ function createRef(getter, setter) {
307
282
  * @paramType string
308
283
  */ function Header(name) {
309
284
  return (0, moost.Resolve)(() => {
310
- const headers = (0, __wooksjs_event_http.useHeaders)();
311
- return headers[name];
285
+ return (0, _wooksjs_event_http.useHeaders)()[name];
312
286
  }, `header: ${name}`);
313
287
  }
314
288
  /**
@@ -317,7 +291,7 @@ function createRef(getter, setter) {
317
291
  * @param name - cookie name
318
292
  * @paramType string
319
293
  */ function Cookie(name) {
320
- return (0, moost.Resolve)(() => (0, __wooksjs_event_http.useCookies)().getCookie(name), `cookie: ${name}`);
294
+ return (0, moost.Resolve)(() => (0, _wooksjs_event_http.useCookies)().getCookie(name), `cookie: ${name}`);
321
295
  }
322
296
  /**
323
297
  * Get Query Item value or the whole parsed Query as an object
@@ -328,10 +302,9 @@ function createRef(getter, setter) {
328
302
  const isItem = !!name;
329
303
  const _name = isItem ? name : "Query";
330
304
  return (0, moost.getMoostMate)().apply((0, moost.getMoostMate)().decorate("paramSource", isItem ? "QUERY_ITEM" : "QUERY"), (0, moost.getMoostMate)().decorate("paramName", _name), (0, moost.Resolve)(() => {
331
- const { toJson, params } = (0, __wooksjs_event_http.useUrlParams)();
305
+ const { toJson, params } = (0, _wooksjs_event_http.useUrlParams)();
332
306
  if (isItem) {
333
- const p = params();
334
- const value = p.get(name);
307
+ const value = params().get(name);
335
308
  return value === null ? void 0 : value;
336
309
  }
337
310
  const json = toJson();
@@ -343,21 +316,21 @@ function createRef(getter, setter) {
343
316
  * @decorator
344
317
  * @paramType string
345
318
  */ function Url() {
346
- return (0, moost.Resolve)(() => (0, __wooksjs_event_http.useRequest)().url || "", "url");
319
+ return (0, moost.Resolve)(() => (0, _wooksjs_event_http.useRequest)().url || "", "url");
347
320
  }
348
321
  /**
349
322
  * Get Requested HTTP Method
350
323
  * @decorator
351
324
  * @paramType string
352
325
  */ function Method() {
353
- return (0, moost.Resolve)(() => (0, __wooksjs_event_http.useRequest)().method, "http_method");
326
+ return (0, moost.Resolve)(() => (0, _wooksjs_event_http.useRequest)().method, "http_method");
354
327
  }
355
328
  /**
356
329
  * Get Raw Request Instance
357
330
  * @decorator
358
331
  * @paramType IncomingMessage
359
332
  */ function Req() {
360
- return (0, moost.Resolve)(() => (0, __wooksjs_event_http.useRequest)().raw, "request");
333
+ return (0, moost.Resolve)(() => (0, _wooksjs_event_http.useRequest)().raw, "request");
361
334
  }
362
335
  /**
363
336
  * Get Raw Response Instance
@@ -365,49 +338,49 @@ function createRef(getter, setter) {
365
338
  * @param opts (optional) { passthrough: boolean }
366
339
  * @paramType ServerResponse
367
340
  */ function Res(opts) {
368
- return (0, moost.Resolve)(() => (0, __wooksjs_event_http.useResponse)().getRawRes(opts?.passthrough), "response");
341
+ return (0, moost.Resolve)(() => (0, _wooksjs_event_http.useResponse)().getRawRes(opts?.passthrough), "response");
369
342
  }
370
343
  /**
371
344
  * Get Request Unique Identificator (UUID)
372
345
  * @decorator
373
346
  * @paramType string
374
347
  */ function ReqId() {
375
- return (0, moost.Resolve)(() => (0, __wooksjs_event_http.useRequest)().reqId(), "reqId");
348
+ return (0, moost.Resolve)(() => (0, _wooksjs_event_http.useRequest)().reqId(), "reqId");
376
349
  }
377
350
  /**
378
351
  * Get Request IP Address
379
352
  * @decorator
380
353
  * @paramType string
381
354
  */ function Ip(opts) {
382
- return (0, moost.Resolve)(() => (0, __wooksjs_event_http.useRequest)().getIp(opts), "ip");
355
+ return (0, moost.Resolve)(() => (0, _wooksjs_event_http.useRequest)().getIp(opts), "ip");
383
356
  }
384
357
  /**
385
358
  * Get Request IP Address list
386
359
  * @decorator
387
360
  * @paramType string[]
388
361
  */ function IpList() {
389
- return (0, moost.Resolve)(() => (0, __wooksjs_event_http.useRequest)().getIpList(), "ipList");
362
+ return (0, moost.Resolve)(() => (0, _wooksjs_event_http.useRequest)().getIpList(), "ipList");
390
363
  }
391
364
  /**
392
365
  * Get Parsed Request Body
393
366
  * @decorator
394
367
  * @paramType object | string | unknown
395
368
  */ function Body() {
396
- return (0, moost.getMoostMate)().apply((0, moost.getMoostMate)().decorate("paramSource", "BODY"), (0, moost.Resolve)(() => (0, __wooksjs_http_body.useBody)().parseBody(), "body"));
369
+ return (0, moost.getMoostMate)().apply((0, moost.getMoostMate)().decorate("paramSource", "BODY"), (0, moost.Resolve)(() => (0, _wooksjs_http_body.useBody)().parseBody(), "body"));
397
370
  }
398
371
  /**
399
372
  * Get Raw Request Body Buffer
400
373
  * @decorator
401
374
  * @paramType Promise<Buffer>
402
375
  */ function RawBody() {
403
- return (0, moost.Resolve)(() => (0, __wooksjs_http_body.useBody)().rawBody(), "body");
376
+ return (0, moost.Resolve)(() => (0, _wooksjs_http_body.useBody)().rawBody(), "body");
404
377
  }
405
378
 
406
379
  //#endregion
407
380
  //#region packages/event-http/src/decorators/set.decorator.ts
408
381
  const setHeaderInterceptor = (name, value, opts) => {
409
382
  const cb = () => {
410
- const response = (0, __wooksjs_event_http.useResponse)();
383
+ const response = (0, _wooksjs_event_http.useResponse)();
411
384
  if ((!response.getHeader(name) || opts?.force) && (!opts?.status || opts.status === response.status)) response.setHeader(name, value);
412
385
  };
413
386
  const def = { priority: moost.TInterceptorPriority.AFTER_ALL };
@@ -456,7 +429,7 @@ const setHeaderInterceptor = (name, value, opts) => {
456
429
  }
457
430
  const setCookieInterceptor = (name, value, attrs) => ({
458
431
  after() {
459
- const response = (0, __wooksjs_event_http.useResponse)();
432
+ const response = (0, _wooksjs_event_http.useResponse)();
460
433
  if (!response.getCookie(name)) response.setCookie(name, value, attrs);
461
434
  },
462
435
  priority: moost.TInterceptorPriority.AFTER_ALL
@@ -486,7 +459,7 @@ const setCookieInterceptor = (name, value, attrs) => ({
486
459
  }
487
460
  const setStatusInterceptor = (code, opts) => ({
488
461
  after() {
489
- const response = (0, __wooksjs_event_http.useResponse)();
462
+ const response = (0, _wooksjs_event_http.useResponse)();
490
463
  if (!response.status || opts?.force) response.status = code;
491
464
  },
492
465
  priority: moost.TInterceptorPriority.AFTER_ALL
@@ -521,7 +494,7 @@ const setStatusInterceptor = (code, opts) => ({
521
494
  * @param n - Maximum body size in bytes after decompression.
522
495
  * @returns Interceptor def to enforce the limit.
523
496
  */ const globalBodySizeLimit = (n) => (0, moost.defineBeforeInterceptor)(() => {
524
- (0, __wooksjs_event_http.useRequest)().setMaxInflated(n);
497
+ (0, _wooksjs_event_http.useRequest)().setMaxInflated(n);
525
498
  }, moost.TInterceptorPriority.BEFORE_ALL);
526
499
  /**
527
500
  * Creates an interceptor that sets the maximum allowed compressed body size in bytes.
@@ -529,7 +502,7 @@ const setStatusInterceptor = (code, opts) => ({
529
502
  * @param n - Maximum body size in bytes before decompression.
530
503
  * @returns Interceptor def to enforce the limit.
531
504
  */ const globalCompressedBodySizeLimit = (n) => (0, moost.defineBeforeInterceptor)(() => {
532
- (0, __wooksjs_event_http.useRequest)().setMaxCompressed(n);
505
+ (0, _wooksjs_event_http.useRequest)().setMaxCompressed(n);
533
506
  }, moost.TInterceptorPriority.BEFORE_ALL);
534
507
  /**
535
508
  * Creates an interceptor that sets the timeout for reading the request body.
@@ -537,7 +510,7 @@ const setStatusInterceptor = (code, opts) => ({
537
510
  * @param n - Timeout in milliseconds.
538
511
  * @returns Interceptor def to enforce the timeout.
539
512
  */ const globalBodyReadTimeoutMs = (n) => (0, moost.defineBeforeInterceptor)(() => {
540
- (0, __wooksjs_event_http.useRequest)().setReadTimeoutMs(n);
513
+ (0, _wooksjs_event_http.useRequest)().setReadTimeoutMs(n);
541
514
  }, moost.TInterceptorPriority.BEFORE_ALL);
542
515
  /**
543
516
  * Decorator to limit the maximum inflated body size for the request. Default: 10 MB
@@ -627,7 +600,7 @@ const CONTEXT_TYPE = "HTTP";
627
600
  loggerTitle: LOGGER_TITLE,
628
601
  getIterceptorHandler: () => this.moost?.getGlobalInterceptorHandler(),
629
602
  getControllerInstance: () => this.moost,
630
- callControllerMethod: () => new __wooksjs_event_http.HttpError(404, "Resource Not Found"),
603
+ callControllerMethod: () => new _wooksjs_event_http.HttpError(404, "Resource Not Found"),
631
604
  targetPath: "",
632
605
  handlerType: "__SYSTEM__"
633
606
  })();
@@ -636,7 +609,7 @@ const CONTEXT_TYPE = "HTTP";
636
609
  this.moost = moost$1;
637
610
  }
638
611
  getProvideRegistry() {
639
- return (0, __prostojs_infact.createProvideRegistry)([__wooksjs_event_http.WooksHttp, () => this.getHttpApp()], ["WooksHttp", () => this.getHttpApp()], [http.Server, () => this.getHttpApp().getServer()], [https.Server, () => this.getHttpApp().getServer()]);
612
+ return (0, _prostojs_infact.createProvideRegistry)([_wooksjs_event_http.WooksHttp, () => this.getHttpApp()], ["WooksHttp", () => this.getHttpApp()], [http.Server, () => this.getHttpApp().getServer()], [https.Server, () => this.getHttpApp().getServer()]);
640
613
  }
641
614
  getLogger() {
642
615
  return this.getHttpApp().getLogger("[moost-http]");
@@ -658,7 +631,7 @@ const CONTEXT_TYPE = "HTTP";
658
631
  resolveArgs: opts.resolveArgs,
659
632
  manualUnscope: true,
660
633
  hooks: { init: ({ unscope }) => {
661
- const { raw } = (0, __wooksjs_event_http.useRequest)();
634
+ const { raw } = (0, _wooksjs_event_http.useRequest)();
662
635
  raw.on("end", unscope);
663
636
  } },
664
637
  targetPath,
@@ -667,8 +640,7 @@ const CONTEXT_TYPE = "HTTP";
667
640
  });
668
641
  const routerBinding = handler.method === "UPGRADE" ? this.httpApp.upgrade(targetPath, fn) : this.httpApp.on(handler.method, targetPath, fn);
669
642
  const { getPath: pathBuilder } = routerBinding;
670
- const methodMeta = (0, moost.getMoostMate)().read(opts.fakeInstance, opts.method) || {};
671
- const id = methodMeta.id || opts.method;
643
+ const id = ((0, moost.getMoostMate)().read(opts.fakeInstance, opts.method) || {}).id || opts.method;
672
644
  if (id) {
673
645
  const methods = this.pathBuilders[id] = this.pathBuilders[id] || {};
674
646
  if (handler.method === "*") {
@@ -691,18 +663,18 @@ const CONTEXT_TYPE = "HTTP";
691
663
  _define_property(this, "httpApp", void 0);
692
664
  _define_property(this, "pathBuilders", {});
693
665
  _define_property(this, "moost", void 0);
694
- __wooksjs_event_http.WooksHttpResponse.registerFramework({
666
+ _wooksjs_event_http.WooksHttpResponse.registerFramework({
695
667
  image: "https://moost.org/moost-full-logo.svg",
696
668
  link: "https://moost.org/",
697
669
  poweredBy: "moostjs",
698
- version: "0.6.7"
670
+ version: "0.6.10"
699
671
  });
700
- if (httpApp && httpApp instanceof __wooksjs_event_http.WooksHttp) this.httpApp = httpApp;
701
- else if (httpApp) this.httpApp = (0, __wooksjs_event_http.createHttpApp)({
672
+ if (httpApp && httpApp instanceof _wooksjs_event_http.WooksHttp) this.httpApp = httpApp;
673
+ else if (httpApp) this.httpApp = (0, _wooksjs_event_http.createHttpApp)({
702
674
  ...httpApp,
703
675
  onNotFound: this.onNotFound.bind(this)
704
676
  });
705
- else this.httpApp = (0, __wooksjs_event_http.createHttpApp)({ onNotFound: this.onNotFound.bind(this) });
677
+ else this.httpApp = (0, _wooksjs_event_http.createHttpApp)({ onNotFound: this.onNotFound.bind(this) });
706
678
  }
707
679
  };
708
680
 
@@ -717,25 +689,22 @@ const CONTEXT_TYPE = "HTTP";
717
689
  * without the overhead of a TCP round-trip.
718
690
  *
719
691
  * @returns A teardown function that restores the original `globalThis.fetch`.
720
- */ function enableLocalFetch(http$1) {
692
+ */ function enableLocalFetch(http) {
721
693
  const originalFetch = globalThis.fetch;
722
694
  globalThis.fetch = async (input, init) => {
723
695
  if (typeof input === "string") {
724
696
  if (input.startsWith("/")) {
725
- const response = await http$1.request(input, init);
697
+ const response = await http.request(input, init);
726
698
  if (response) return response;
727
699
  }
728
700
  } else if (input instanceof URL) {
729
701
  if (isLocalOrigin(input)) {
730
- const response = await http$1.request(input, init);
731
- if (response) return response;
732
- }
733
- } else {
734
- const url = new URL(input.url);
735
- if (isLocalOrigin(url)) {
736
- const response = await http$1.fetch(input);
702
+ const response = await http.request(input, init);
737
703
  if (response) return response;
738
704
  }
705
+ } else if (isLocalOrigin(new URL(input.url))) {
706
+ const response = await http.fetch(input);
707
+ if (response) return response;
739
708
  }
740
709
  return originalFetch(input, init);
741
710
  };
@@ -771,7 +740,7 @@ exports.HeaderRef = HeaderRef;
771
740
  Object.defineProperty(exports, 'HttpError', {
772
741
  enumerable: true,
773
742
  get: function () {
774
- return __wooksjs_event_http.HttpError;
743
+ return _wooksjs_event_http.HttpError;
775
744
  }
776
745
  });
777
746
  exports.HttpMethod = HttpMethod;
@@ -802,12 +771,12 @@ exports.globalCompressedBodySizeLimit = globalCompressedBodySizeLimit;
802
771
  Object.defineProperty(exports, 'httpKind', {
803
772
  enumerable: true,
804
773
  get: function () {
805
- return __wooksjs_event_http.httpKind;
774
+ return _wooksjs_event_http.httpKind;
806
775
  }
807
776
  });
808
777
  Object.defineProperty(exports, 'useHttpContext', {
809
778
  enumerable: true,
810
779
  get: function () {
811
- return __wooksjs_event_http.useHttpContext;
780
+ return _wooksjs_event_http.useHttpContext;
812
781
  }
813
782
  });
package/dist/index.mjs CHANGED
@@ -90,11 +90,9 @@ function _ts_param(paramIndex, decorator) {
90
90
  * Return a value from the handler to short-circuit with that response.
91
91
  */ function defineAuthGuard(transports, handler) {
92
92
  const def = defineBeforeInterceptor((reply) => {
93
- const extracted = extractTransports(transports);
94
- const result = handler(extracted);
93
+ const result = handler(extractTransports(transports));
95
94
  if (result !== null && result !== void 0 && typeof result.then === "function") return result.then((r) => {
96
95
  if (r !== void 0) reply(r);
97
- return void 0;
98
96
  });
99
97
  if (result !== void 0) reply(result);
100
98
  }, TInterceptorPriority.GUARD);
@@ -107,7 +105,6 @@ var AuthGuard = class {
107
105
  const result = this.handle(extracted);
108
106
  if (result !== null && result !== void 0 && typeof result.then === "function") return result.then((r) => {
109
107
  if (r !== void 0) reply(r);
110
- return void 0;
111
108
  });
112
109
  if (result !== void 0) reply(result);
113
110
  }
@@ -273,7 +270,7 @@ function createRef(getter, setter) {
273
270
  case "bearer": return auth.is("bearer") ? auth.authorization : void 0;
274
271
  case "raw": return auth.credentials();
275
272
  case "type": return auth.type();
276
- default: return void 0;
273
+ default: return;
277
274
  }
278
275
  }, "authorization");
279
276
  }
@@ -284,8 +281,7 @@ function createRef(getter, setter) {
284
281
  * @paramType string
285
282
  */ function Header(name) {
286
283
  return Resolve(() => {
287
- const headers = useHeaders();
288
- return headers[name];
284
+ return useHeaders()[name];
289
285
  }, `header: ${name}`);
290
286
  }
291
287
  /**
@@ -307,8 +303,7 @@ function createRef(getter, setter) {
307
303
  return getMoostMate().apply(getMoostMate().decorate("paramSource", isItem ? "QUERY_ITEM" : "QUERY"), getMoostMate().decorate("paramName", _name), Resolve(() => {
308
304
  const { toJson, params } = useUrlParams();
309
305
  if (isItem) {
310
- const p = params();
311
- const value = p.get(name);
306
+ const value = params().get(name);
312
307
  return value === null ? void 0 : value;
313
308
  }
314
309
  const json = toJson();
@@ -644,8 +639,7 @@ const CONTEXT_TYPE = "HTTP";
644
639
  });
645
640
  const routerBinding = handler.method === "UPGRADE" ? this.httpApp.upgrade(targetPath, fn) : this.httpApp.on(handler.method, targetPath, fn);
646
641
  const { getPath: pathBuilder } = routerBinding;
647
- const methodMeta = getMoostMate().read(opts.fakeInstance, opts.method) || {};
648
- const id = methodMeta.id || opts.method;
642
+ const id = (getMoostMate().read(opts.fakeInstance, opts.method) || {}).id || opts.method;
649
643
  if (id) {
650
644
  const methods = this.pathBuilders[id] = this.pathBuilders[id] || {};
651
645
  if (handler.method === "*") {
@@ -672,7 +666,7 @@ const CONTEXT_TYPE = "HTTP";
672
666
  image: "https://moost.org/moost-full-logo.svg",
673
667
  link: "https://moost.org/",
674
668
  poweredBy: "moostjs",
675
- version: "0.6.7"
669
+ version: "0.6.10"
676
670
  });
677
671
  if (httpApp && httpApp instanceof WooksHttp) this.httpApp = httpApp;
678
672
  else if (httpApp) this.httpApp = createHttpApp({
@@ -707,12 +701,9 @@ const CONTEXT_TYPE = "HTTP";
707
701
  const response = await http.request(input, init);
708
702
  if (response) return response;
709
703
  }
710
- } else {
711
- const url = new URL(input.url);
712
- if (isLocalOrigin(url)) {
713
- const response = await http.fetch(input);
714
- if (response) return response;
715
- }
704
+ } else if (isLocalOrigin(new URL(input.url))) {
705
+ const response = await http.fetch(input);
706
+ if (response) return response;
716
707
  }
717
708
  return originalFetch(input, init);
718
709
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moostjs/event-http",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "description": "@moostjs/event-http",
5
5
  "keywords": [
6
6
  "composables",
@@ -38,16 +38,16 @@
38
38
  }
39
39
  },
40
40
  "dependencies": {
41
- "@wooksjs/event-http": "^0.7.10",
42
- "@wooksjs/http-body": "^0.7.10"
41
+ "@wooksjs/event-http": "^0.7.12",
42
+ "@wooksjs/http-body": "^0.7.12"
43
43
  },
44
44
  "devDependencies": {
45
45
  "vitest": "3.2.4"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@prostojs/infact": "^0.4.1",
49
- "@wooksjs/event-core": "^0.7.10",
50
- "moost": "^0.6.8"
49
+ "@wooksjs/event-core": "^0.7.12",
50
+ "moost": "^0.6.10"
51
51
  },
52
52
  "scripts": {
53
53
  "pub": "pnpm publish --access public",