@moostjs/event-http 0.6.48 → 0.6.50

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
@@ -376,13 +376,27 @@ function createRef(getter, setter) {
376
376
  return (0, moost.Resolve)(() => (0, _wooksjs_http_body.useBody)().rawBody(), "body");
377
377
  }
378
378
 
379
+ //#endregion
380
+ //#region packages/event-http/src/decorators/http-only.ts
381
+ /**
382
+ * Wraps the callback of an HTTP-only interceptor so it runs for HTTP events only (an in-process
383
+ * `MoostHttp.invoke()` included). Any other event of a mixed controller — a CLI command, a
384
+ * workflow step, a WebSocket message — skips it, also when it runs as a child of an HTTP request:
385
+ * the parent's request and response are not its own.
386
+ */ function forHttpEvents(fn) {
387
+ return () => {
388
+ const ctx = (0, _wooksjs_event_core.current)();
389
+ if (ctx.has(_wooksjs_event_core.eventTypeKey) && ctx.get(_wooksjs_event_core.eventTypeKey) === _wooksjs_event_http.httpKind.name) fn(ctx);
390
+ };
391
+ }
392
+
379
393
  //#endregion
380
394
  //#region packages/event-http/src/decorators/set.decorator.ts
381
395
  const setHeaderInterceptor = (name, value, opts) => {
382
- const cb = () => {
383
- const response = (0, _wooksjs_event_http.useResponse)();
396
+ const cb = forHttpEvents((ctx) => {
397
+ const response = (0, _wooksjs_event_http.useResponse)(ctx);
384
398
  if ((!response.getHeader(name) || opts?.force) && (!opts?.status || opts.status === response.status)) response.setHeader(name, value);
385
- };
399
+ });
386
400
  const def = { priority: moost.TInterceptorPriority.AFTER_ALL };
387
401
  if (opts?.when !== "error") def.after = cb;
388
402
  if (opts?.when === "always" || opts?.when === "error") def.error = cb;
@@ -428,10 +442,10 @@ const setHeaderInterceptor = (name, value, opts) => {
428
442
  return (0, moost.Intercept)(setHeaderInterceptor(...args));
429
443
  }
430
444
  const setCookieInterceptor = (name, value, attrs) => ({
431
- after() {
432
- const response = (0, _wooksjs_event_http.useResponse)();
445
+ after: forHttpEvents((ctx) => {
446
+ const response = (0, _wooksjs_event_http.useResponse)(ctx);
433
447
  if (!response.getCookie(name)) response.setCookie(name, value, attrs);
434
- },
448
+ }),
435
449
  priority: moost.TInterceptorPriority.AFTER_ALL
436
450
  });
437
451
  /**
@@ -458,10 +472,10 @@ const setCookieInterceptor = (name, value, attrs) => ({
458
472
  return (0, moost.Intercept)(setCookieInterceptor(...args));
459
473
  }
460
474
  const setStatusInterceptor = (code, opts) => ({
461
- after() {
462
- const response = (0, _wooksjs_event_http.useResponse)();
475
+ after: forHttpEvents((ctx) => {
476
+ const response = (0, _wooksjs_event_http.useResponse)(ctx);
463
477
  if (!response.status || opts?.force) response.status = code;
464
- },
478
+ }),
465
479
  priority: moost.TInterceptorPriority.AFTER_ALL
466
480
  });
467
481
  /**
@@ -490,28 +504,31 @@ const setStatusInterceptor = (code, opts) => ({
490
504
  //#region packages/event-http/src/decorators/limits.decorator.ts
491
505
  /**
492
506
  * Creates an interceptor that sets the maximum allowed inflated body size in bytes.
507
+ * Non-HTTP events are left alone.
493
508
  *
494
509
  * @param n - Maximum body size in bytes after decompression.
495
510
  * @returns Interceptor def to enforce the limit.
496
- */ const globalBodySizeLimit = (n) => (0, moost.defineBeforeInterceptor)(() => {
497
- (0, _wooksjs_event_http.useRequest)().setMaxInflated(n);
498
- }, moost.TInterceptorPriority.BEFORE_ALL);
511
+ */ const globalBodySizeLimit = (n) => (0, moost.defineBeforeInterceptor)(forHttpEvents((ctx) => {
512
+ (0, _wooksjs_event_http.useRequest)(ctx).setMaxInflated(n);
513
+ }), moost.TInterceptorPriority.BEFORE_ALL);
499
514
  /**
500
515
  * Creates an interceptor that sets the maximum allowed compressed body size in bytes.
516
+ * Non-HTTP events are left alone.
501
517
  *
502
518
  * @param n - Maximum body size in bytes before decompression.
503
519
  * @returns Interceptor def to enforce the limit.
504
- */ const globalCompressedBodySizeLimit = (n) => (0, moost.defineBeforeInterceptor)(() => {
505
- (0, _wooksjs_event_http.useRequest)().setMaxCompressed(n);
506
- }, moost.TInterceptorPriority.BEFORE_ALL);
520
+ */ const globalCompressedBodySizeLimit = (n) => (0, moost.defineBeforeInterceptor)(forHttpEvents((ctx) => {
521
+ (0, _wooksjs_event_http.useRequest)(ctx).setMaxCompressed(n);
522
+ }), moost.TInterceptorPriority.BEFORE_ALL);
507
523
  /**
508
524
  * Creates an interceptor that sets the timeout for reading the request body.
525
+ * Non-HTTP events are left alone.
509
526
  *
510
527
  * @param n - Timeout in milliseconds.
511
528
  * @returns Interceptor def to enforce the timeout.
512
- */ const globalBodyReadTimeoutMs = (n) => (0, moost.defineBeforeInterceptor)(() => {
513
- (0, _wooksjs_event_http.useRequest)().setReadTimeoutMs(n);
514
- }, moost.TInterceptorPriority.BEFORE_ALL);
529
+ */ const globalBodyReadTimeoutMs = (n) => (0, moost.defineBeforeInterceptor)(forHttpEvents((ctx) => {
530
+ (0, _wooksjs_event_http.useRequest)(ctx).setReadTimeoutMs(n);
531
+ }), moost.TInterceptorPriority.BEFORE_ALL);
515
532
  /**
516
533
  * Decorator to limit the maximum inflated body size for the request. Default: 10 MB
517
534
  *
@@ -528,6 +545,51 @@ const setStatusInterceptor = (code, opts) => ({
528
545
  * @param n - Timeout duration in milliseconds.
529
546
  */ const BodyReadTimeoutMs = (n) => (0, moost.Intercept)(globalBodyReadTimeoutMs(n));
530
547
 
548
+ //#endregion
549
+ //#region packages/event-http/src/decorators/compress.decorator.ts
550
+ /** Compression settings of the response before the first `@Compress` of the event ran. */ const compressionBase = (0, _wooksjs_event_core.key)("moost.http.compressionBase");
551
+ /**
552
+ * Overrides response compression for a handler or a whole controller.
553
+ *
554
+ * Calls `useResponse().setCompression(value)` before guards, argument resolution and the
555
+ * handler run, so the override also applies to error responses (401, 400, …).
556
+ * A method-level `@Compress` replaces a class-level one: it starts from the app settings
557
+ * rather than layering over the class value. Non-HTTP events of a controller are left alone.
558
+ *
559
+ * - `true` (default) — compress with the app settings (`new MoostHttp({ compression })`),
560
+ * or the defaults when the app has compression off.
561
+ * - `false` — never compress this response (e.g. a body that mixes a secret with
562
+ * reflected input — see BREACH).
563
+ * - options object — compress with these settings layered over the app settings.
564
+ *
565
+ * ```ts
566
+ * import { Compress, Get } from '@moostjs/event-http'
567
+ * import { Controller } from 'moost'
568
+ *
569
+ * @Controller()
570
+ * export class ReportsController {
571
+ * @Get('report')
572
+ * @Compress({ brotliQuality: 6 })
573
+ * report() {
574
+ * return buildReport()
575
+ * }
576
+ *
577
+ * @Get('session')
578
+ * @Compress(false)
579
+ * session() {
580
+ * return { token, echo: query }
581
+ * }
582
+ * }
583
+ * ```
584
+ *
585
+ * @param value compression override, defaults to `true`
586
+ */ const Compress = (value = true) => (0, moost.Intercept)((0, moost.defineBeforeInterceptor)(forHttpEvents((ctx) => {
587
+ const response = (0, _wooksjs_event_http.useResponse)(ctx);
588
+ if (ctx.hasOwn(compressionBase)) response.setCompression(ctx.getOwn(compressionBase));
589
+ else ctx.setOwn(compressionBase, response.compression);
590
+ response.setCompression(value);
591
+ }), moost.TInterceptorPriority.BEFORE_ALL));
592
+
531
593
  //#endregion
532
594
  //#region packages/event-http/src/event-http.ts
533
595
  function _define_property(obj, key, value) {
@@ -754,7 +816,7 @@ const LOGGER_TITLE = "moost-http";
754
816
  image: "https://moost.org/moost-full-logo.svg",
755
817
  link: "https://moost.org/",
756
818
  poweredBy: "moostjs",
757
- version: "0.6.48"
819
+ version: "0.6.50"
758
820
  });
759
821
  if (httpApp && httpApp instanceof _wooksjs_event_http.WooksHttp) this.httpApp = httpApp;
760
822
  else if (httpApp) this.httpApp = (0, _wooksjs_event_http.createHttpApp)({
@@ -817,6 +879,7 @@ exports.Authorization = Authorization;
817
879
  exports.Body = Body;
818
880
  exports.BodyReadTimeoutMs = BodyReadTimeoutMs;
819
881
  exports.BodySizeLimit = BodySizeLimit;
882
+ exports.Compress = Compress;
820
883
  exports.CompressedBodySizeLimit = CompressedBodySizeLimit;
821
884
  exports.Cookie = Cookie;
822
885
  exports.CookieAttrsRef = CookieAttrsRef;
@@ -862,6 +925,12 @@ Object.defineProperty(exports, 'httpKind', {
862
925
  return _wooksjs_event_http.httpKind;
863
926
  }
864
927
  });
928
+ Object.defineProperty(exports, 'isCompressibleType', {
929
+ enumerable: true,
930
+ get: function () {
931
+ return _wooksjs_event_http.isCompressibleType;
932
+ }
933
+ });
865
934
  Object.defineProperty(exports, 'prerenderJson', {
866
935
  enumerable: true,
867
936
  get: function () {
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as moost from 'moost';
2
2
  import { TInterceptorPriority, TOvertakeFn, TInterceptorDef, TClassConstructor, TMoostAdapter, MOOST_ADAPTER_BRAND, TIsolatedSlot, EventContext, Moost, TConsoleBase, TMoostAdapterOptions } from 'moost';
3
3
  import * as _wooksjs_event_http from '@wooksjs/event-http';
4
- import { TCookieAttributes as TCookieAttributes$1, TCookieAttributesInput, WooksHttp, TWooksHttpOptions } from '@wooksjs/event-http';
5
- export { HttpError, TCacheControl, TCookieAttributesInput, TPrerenderJsonOptions, TSetCookieData, httpKind, prerenderJson, useHttpContext } from '@wooksjs/event-http';
4
+ import { TCookieAttributes as TCookieAttributes$1, TCookieAttributesInput, THttpCompressionOptions, WooksHttp, TWooksHttpOptions } from '@wooksjs/event-http';
5
+ export { HttpError, TCacheControl, TCookieAttributesInput, THttpCompressionEncoding, THttpCompressionOptions, TPrerenderJsonOptions, TSetCookieData, httpKind, isCompressibleType, prerenderJson, useHttpContext } from '@wooksjs/event-http';
6
6
  import { IncomingMessage, ServerResponse } from 'http';
7
7
  import { Buffer } from 'buffer';
8
8
  import { ListenOptions } from 'net';
@@ -328,6 +328,7 @@ declare function SetStatus(...args: Parameters<typeof setStatusInterceptor>): Cl
328
328
 
329
329
  /**
330
330
  * Creates an interceptor that sets the maximum allowed inflated body size in bytes.
331
+ * Non-HTTP events are left alone.
331
332
  *
332
333
  * @param n - Maximum body size in bytes after decompression.
333
334
  * @returns Interceptor def to enforce the limit.
@@ -335,6 +336,7 @@ declare function SetStatus(...args: Parameters<typeof setStatusInterceptor>): Cl
335
336
  declare const globalBodySizeLimit: (n: number) => moost.TInterceptorDef;
336
337
  /**
337
338
  * Creates an interceptor that sets the maximum allowed compressed body size in bytes.
339
+ * Non-HTTP events are left alone.
338
340
  *
339
341
  * @param n - Maximum body size in bytes before decompression.
340
342
  * @returns Interceptor def to enforce the limit.
@@ -342,6 +344,7 @@ declare const globalBodySizeLimit: (n: number) => moost.TInterceptorDef;
342
344
  declare const globalCompressedBodySizeLimit: (n: number) => moost.TInterceptorDef;
343
345
  /**
344
346
  * Creates an interceptor that sets the timeout for reading the request body.
347
+ * Non-HTTP events are left alone.
345
348
  *
346
349
  * @param n - Timeout in milliseconds.
347
350
  * @returns Interceptor def to enforce the timeout.
@@ -366,6 +369,44 @@ declare const CompressedBodySizeLimit: (n: number) => ClassDecorator & MethodDec
366
369
  */
367
370
  declare const BodyReadTimeoutMs: (n: number) => ClassDecorator & MethodDecorator;
368
371
 
372
+ /**
373
+ * Overrides response compression for a handler or a whole controller.
374
+ *
375
+ * Calls `useResponse().setCompression(value)` before guards, argument resolution and the
376
+ * handler run, so the override also applies to error responses (401, 400, …).
377
+ * A method-level `@Compress` replaces a class-level one: it starts from the app settings
378
+ * rather than layering over the class value. Non-HTTP events of a controller are left alone.
379
+ *
380
+ * - `true` (default) — compress with the app settings (`new MoostHttp({ compression })`),
381
+ * or the defaults when the app has compression off.
382
+ * - `false` — never compress this response (e.g. a body that mixes a secret with
383
+ * reflected input — see BREACH).
384
+ * - options object — compress with these settings layered over the app settings.
385
+ *
386
+ * ```ts
387
+ * import { Compress, Get } from '@moostjs/event-http'
388
+ * import { Controller } from 'moost'
389
+ *
390
+ * @Controller()
391
+ * export class ReportsController {
392
+ * @Get('report')
393
+ * @Compress({ brotliQuality: 6 })
394
+ * report() {
395
+ * return buildReport()
396
+ * }
397
+ *
398
+ * @Get('session')
399
+ * @Compress(false)
400
+ * session() {
401
+ * return { token, echo: query }
402
+ * }
403
+ * }
404
+ * ```
405
+ *
406
+ * @param value compression override, defaults to `true`
407
+ */
408
+ declare const Compress: (value?: boolean | THttpCompressionOptions) => ClassDecorator & MethodDecorator;
409
+
369
410
  type TPathBuilder<ParamsType = Record<string, string | string[]>> = (params?: ParamsType) => string;
370
411
  /** Handler metadata for HTTP events, carrying the HTTP method and route path. */
371
412
  interface THttpHandlerMeta {
@@ -526,5 +567,5 @@ declare class MoostHttp implements TMoostAdapter<THttpHandlerMeta> {
526
567
  */
527
568
  declare function enableLocalFetch(http: MoostHttp): () => void;
528
569
 
529
- export { All, AuthGuard, Authenticate, Authorization, Body, BodyReadTimeoutMs, BodySizeLimit, CompressedBodySizeLimit, Cookie, CookieAttrsRef, CookieRef, Delete, Get, Header, HeaderRef, HttpMethod, Ip, IpList, Method, MoostHttp, Patch, Post, Put, Query, RawBody, Req, ReqId, Res, SetCookie, SetHeader, SetStatus, StatusRef, Upgrade, Url, defineAuthGuard, enableLocalFetch, extractTransports, globalBodyReadTimeoutMs, globalBodySizeLimit, globalCompressedBodySizeLimit };
570
+ export { All, AuthGuard, Authenticate, Authorization, Body, BodyReadTimeoutMs, BodySizeLimit, Compress, CompressedBodySizeLimit, Cookie, CookieAttrsRef, CookieRef, Delete, Get, Header, HeaderRef, HttpMethod, Ip, IpList, Method, MoostHttp, Patch, Post, Put, Query, RawBody, Req, ReqId, Res, SetCookie, SetHeader, SetStatus, StatusRef, Upgrade, Url, defineAuthGuard, enableLocalFetch, extractTransports, globalBodyReadTimeoutMs, globalBodySizeLimit, globalCompressedBodySizeLimit };
530
571
  export type { TAuthGuardClass, TAuthGuardDef, TAuthGuardHandler, TAuthTransportApiKey, TAuthTransportBasic, TAuthTransportBearer, TAuthTransportCookie, TAuthTransportDeclaration, TAuthTransportValues, TCookieAttributes, TCookieRef, THeaderRef, THttpHandlerMeta, TMoostHttpInvokeOptions, TStatusRef };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { current } from "@wooksjs/event-core";
2
- import { HttpError, HttpError as HttpError$1, WooksHttp, WooksHttpResponse, createHttpApp, httpKind, httpKind as httpKind$1, prerenderJson, useAuthorization, useCookies, useHeaders, useHttpContext, useRequest, useResponse, useUrlParams } from "@wooksjs/event-http";
1
+ import { current, eventTypeKey, key } from "@wooksjs/event-core";
2
+ import { HttpError, HttpError as HttpError$1, WooksHttp, WooksHttpResponse, createHttpApp, httpKind, httpKind as httpKind$1, isCompressibleType, prerenderJson, useAuthorization, useCookies, useHeaders, useHttpContext, useRequest, useResponse, useUrlParams } from "@wooksjs/event-http";
3
3
  import { Before, Intercept, Interceptor, MOOST_ADAPTER_BRAND, Overtake, Resolve, TInterceptorPriority, current as current$1, defineBeforeInterceptor, defineMoostEventHandler, forkEventContext, getMoostMate, globalKey, run } from "moost";
4
4
  import { seedBody, useBody } from "@wooksjs/http-body";
5
5
  import { createProvideRegistry } from "@prostojs/infact";
@@ -375,13 +375,27 @@ function createRef(getter, setter) {
375
375
  return Resolve(() => useBody().rawBody(), "body");
376
376
  }
377
377
 
378
+ //#endregion
379
+ //#region packages/event-http/src/decorators/http-only.ts
380
+ /**
381
+ * Wraps the callback of an HTTP-only interceptor so it runs for HTTP events only (an in-process
382
+ * `MoostHttp.invoke()` included). Any other event of a mixed controller — a CLI command, a
383
+ * workflow step, a WebSocket message — skips it, also when it runs as a child of an HTTP request:
384
+ * the parent's request and response are not its own.
385
+ */ function forHttpEvents(fn) {
386
+ return () => {
387
+ const ctx = current();
388
+ if (ctx.has(eventTypeKey) && ctx.get(eventTypeKey) === httpKind$1.name) fn(ctx);
389
+ };
390
+ }
391
+
378
392
  //#endregion
379
393
  //#region packages/event-http/src/decorators/set.decorator.ts
380
394
  const setHeaderInterceptor = (name, value, opts) => {
381
- const cb = () => {
382
- const response = useResponse();
395
+ const cb = forHttpEvents((ctx) => {
396
+ const response = useResponse(ctx);
383
397
  if ((!response.getHeader(name) || opts?.force) && (!opts?.status || opts.status === response.status)) response.setHeader(name, value);
384
- };
398
+ });
385
399
  const def = { priority: TInterceptorPriority.AFTER_ALL };
386
400
  if (opts?.when !== "error") def.after = cb;
387
401
  if (opts?.when === "always" || opts?.when === "error") def.error = cb;
@@ -427,10 +441,10 @@ const setHeaderInterceptor = (name, value, opts) => {
427
441
  return Intercept(setHeaderInterceptor(...args));
428
442
  }
429
443
  const setCookieInterceptor = (name, value, attrs) => ({
430
- after() {
431
- const response = useResponse();
444
+ after: forHttpEvents((ctx) => {
445
+ const response = useResponse(ctx);
432
446
  if (!response.getCookie(name)) response.setCookie(name, value, attrs);
433
- },
447
+ }),
434
448
  priority: TInterceptorPriority.AFTER_ALL
435
449
  });
436
450
  /**
@@ -457,10 +471,10 @@ const setCookieInterceptor = (name, value, attrs) => ({
457
471
  return Intercept(setCookieInterceptor(...args));
458
472
  }
459
473
  const setStatusInterceptor = (code, opts) => ({
460
- after() {
461
- const response = useResponse();
474
+ after: forHttpEvents((ctx) => {
475
+ const response = useResponse(ctx);
462
476
  if (!response.status || opts?.force) response.status = code;
463
- },
477
+ }),
464
478
  priority: TInterceptorPriority.AFTER_ALL
465
479
  });
466
480
  /**
@@ -489,28 +503,31 @@ const setStatusInterceptor = (code, opts) => ({
489
503
  //#region packages/event-http/src/decorators/limits.decorator.ts
490
504
  /**
491
505
  * Creates an interceptor that sets the maximum allowed inflated body size in bytes.
506
+ * Non-HTTP events are left alone.
492
507
  *
493
508
  * @param n - Maximum body size in bytes after decompression.
494
509
  * @returns Interceptor def to enforce the limit.
495
- */ const globalBodySizeLimit = (n) => defineBeforeInterceptor(() => {
496
- useRequest().setMaxInflated(n);
497
- }, TInterceptorPriority.BEFORE_ALL);
510
+ */ const globalBodySizeLimit = (n) => defineBeforeInterceptor(forHttpEvents((ctx) => {
511
+ useRequest(ctx).setMaxInflated(n);
512
+ }), TInterceptorPriority.BEFORE_ALL);
498
513
  /**
499
514
  * Creates an interceptor that sets the maximum allowed compressed body size in bytes.
515
+ * Non-HTTP events are left alone.
500
516
  *
501
517
  * @param n - Maximum body size in bytes before decompression.
502
518
  * @returns Interceptor def to enforce the limit.
503
- */ const globalCompressedBodySizeLimit = (n) => defineBeforeInterceptor(() => {
504
- useRequest().setMaxCompressed(n);
505
- }, TInterceptorPriority.BEFORE_ALL);
519
+ */ const globalCompressedBodySizeLimit = (n) => defineBeforeInterceptor(forHttpEvents((ctx) => {
520
+ useRequest(ctx).setMaxCompressed(n);
521
+ }), TInterceptorPriority.BEFORE_ALL);
506
522
  /**
507
523
  * Creates an interceptor that sets the timeout for reading the request body.
524
+ * Non-HTTP events are left alone.
508
525
  *
509
526
  * @param n - Timeout in milliseconds.
510
527
  * @returns Interceptor def to enforce the timeout.
511
- */ const globalBodyReadTimeoutMs = (n) => defineBeforeInterceptor(() => {
512
- useRequest().setReadTimeoutMs(n);
513
- }, TInterceptorPriority.BEFORE_ALL);
528
+ */ const globalBodyReadTimeoutMs = (n) => defineBeforeInterceptor(forHttpEvents((ctx) => {
529
+ useRequest(ctx).setReadTimeoutMs(n);
530
+ }), TInterceptorPriority.BEFORE_ALL);
514
531
  /**
515
532
  * Decorator to limit the maximum inflated body size for the request. Default: 10 MB
516
533
  *
@@ -527,6 +544,51 @@ const setStatusInterceptor = (code, opts) => ({
527
544
  * @param n - Timeout duration in milliseconds.
528
545
  */ const BodyReadTimeoutMs = (n) => Intercept(globalBodyReadTimeoutMs(n));
529
546
 
547
+ //#endregion
548
+ //#region packages/event-http/src/decorators/compress.decorator.ts
549
+ /** Compression settings of the response before the first `@Compress` of the event ran. */ const compressionBase = key("moost.http.compressionBase");
550
+ /**
551
+ * Overrides response compression for a handler or a whole controller.
552
+ *
553
+ * Calls `useResponse().setCompression(value)` before guards, argument resolution and the
554
+ * handler run, so the override also applies to error responses (401, 400, …).
555
+ * A method-level `@Compress` replaces a class-level one: it starts from the app settings
556
+ * rather than layering over the class value. Non-HTTP events of a controller are left alone.
557
+ *
558
+ * - `true` (default) — compress with the app settings (`new MoostHttp({ compression })`),
559
+ * or the defaults when the app has compression off.
560
+ * - `false` — never compress this response (e.g. a body that mixes a secret with
561
+ * reflected input — see BREACH).
562
+ * - options object — compress with these settings layered over the app settings.
563
+ *
564
+ * ```ts
565
+ * import { Compress, Get } from '@moostjs/event-http'
566
+ * import { Controller } from 'moost'
567
+ *
568
+ * @Controller()
569
+ * export class ReportsController {
570
+ * @Get('report')
571
+ * @Compress({ brotliQuality: 6 })
572
+ * report() {
573
+ * return buildReport()
574
+ * }
575
+ *
576
+ * @Get('session')
577
+ * @Compress(false)
578
+ * session() {
579
+ * return { token, echo: query }
580
+ * }
581
+ * }
582
+ * ```
583
+ *
584
+ * @param value compression override, defaults to `true`
585
+ */ const Compress = (value = true) => Intercept(defineBeforeInterceptor(forHttpEvents((ctx) => {
586
+ const response = useResponse(ctx);
587
+ if (ctx.hasOwn(compressionBase)) response.setCompression(ctx.getOwn(compressionBase));
588
+ else ctx.setOwn(compressionBase, response.compression);
589
+ response.setCompression(value);
590
+ }), TInterceptorPriority.BEFORE_ALL));
591
+
530
592
  //#endregion
531
593
  //#region packages/event-http/src/event-http.ts
532
594
  function _define_property(obj, key, value) {
@@ -753,7 +815,7 @@ const LOGGER_TITLE = "moost-http";
753
815
  image: "https://moost.org/moost-full-logo.svg",
754
816
  link: "https://moost.org/",
755
817
  poweredBy: "moostjs",
756
- version: "0.6.48"
818
+ version: "0.6.50"
757
819
  });
758
820
  if (httpApp && httpApp instanceof WooksHttp) this.httpApp = httpApp;
759
821
  else if (httpApp) this.httpApp = createHttpApp({
@@ -804,4 +866,4 @@ function isLocalOrigin(url) {
804
866
  }
805
867
 
806
868
  //#endregion
807
- export { All, AuthGuard, Authenticate, Authorization, Body, BodyReadTimeoutMs, BodySizeLimit, CompressedBodySizeLimit, Cookie, CookieAttrsRef, CookieRef, Delete, Get, Header, HeaderRef, HttpError, HttpMethod, Ip, IpList, Method, MoostHttp, Patch, Post, Put, Query, RawBody, Req, ReqId, Res, SetCookie, SetHeader, SetStatus, StatusRef, Upgrade, Url, defineAuthGuard, enableLocalFetch, extractTransports, globalBodyReadTimeoutMs, globalBodySizeLimit, globalCompressedBodySizeLimit, httpKind, prerenderJson, useHttpContext };
869
+ export { All, AuthGuard, Authenticate, Authorization, Body, BodyReadTimeoutMs, BodySizeLimit, Compress, CompressedBodySizeLimit, Cookie, CookieAttrsRef, CookieRef, Delete, Get, Header, HeaderRef, HttpError, HttpMethod, Ip, IpList, Method, MoostHttp, Patch, Post, Put, Query, RawBody, Req, ReqId, Res, SetCookie, SetHeader, SetStatus, StatusRef, Upgrade, Url, defineAuthGuard, enableLocalFetch, extractTransports, globalBodyReadTimeoutMs, globalBodySizeLimit, globalCompressedBodySizeLimit, httpKind, isCompressibleType, prerenderJson, useHttpContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moostjs/event-http",
3
- "version": "0.6.48",
3
+ "version": "0.6.50",
4
4
  "description": "@moostjs/event-http",
5
5
  "keywords": [
6
6
  "composables",
@@ -38,16 +38,17 @@
38
38
  }
39
39
  },
40
40
  "dependencies": {
41
- "@wooksjs/event-http": "^0.7.27",
42
- "@wooksjs/http-body": "^0.7.27"
41
+ "@wooksjs/event-http": "^0.7.28",
42
+ "@wooksjs/http-body": "^0.7.28"
43
43
  },
44
44
  "devDependencies": {
45
- "vitest": "3.2.7"
45
+ "vitest": "3.2.7",
46
+ "@moostjs/event-wf": "^0.6.50"
46
47
  },
47
48
  "peerDependencies": {
48
49
  "@prostojs/infact": "^0.6.1",
49
- "@wooksjs/event-core": "^0.7.27",
50
- "moost": "^0.6.48"
50
+ "@wooksjs/event-core": "^0.7.28",
51
+ "moost": "^0.6.50"
51
52
  },
52
53
  "scripts": {
53
54
  "pub": "pnpm publish --access public",