@moostjs/event-http 0.3.3 → 0.3.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.
package/dist/index.cjs CHANGED
@@ -584,15 +584,21 @@ function RawBody() {
584
584
  }
585
585
 
586
586
  const setHeaderInterceptor = (name, value, opts) => {
587
- const fn = (before, after) => {
587
+ const fn = (_before, after, onError) => {
588
588
  const h = eventHttp.useSetHeader(name);
589
589
  const status = eventHttp.useStatus();
590
- after(() => {
590
+ const cb = () => {
591
591
  if ((!h.value || (opts === null || opts === void 0 ? void 0 : opts.force)) &&
592
592
  (!(opts === null || opts === void 0 ? void 0 : opts.status) || opts.status === status.value)) {
593
593
  h.value = value;
594
594
  }
595
- });
595
+ };
596
+ if ((opts === null || opts === void 0 ? void 0 : opts.when) !== 'error') {
597
+ after(cb);
598
+ }
599
+ if ((opts === null || opts === void 0 ? void 0 : opts.when) === 'always' || (opts === null || opts === void 0 ? void 0 : opts.when) === 'error') {
600
+ onError(cb);
601
+ }
596
602
  };
597
603
  fn.priority = moost.TInterceptorPriority.AFTER_ALL;
598
604
  return fn;
package/dist/index.d.ts CHANGED
@@ -267,6 +267,7 @@ export declare function SetHeader(...args: Parameters<typeof setHeaderIntercepto
267
267
  declare const setHeaderInterceptor: (name: string, value: string, opts?: {
268
268
  force?: boolean;
269
269
  status?: number;
270
+ when?: 'always' | 'error' | 'ok';
270
271
  }) => TInterceptorFn;
271
272
 
272
273
  /**
package/dist/index.mjs CHANGED
@@ -583,15 +583,21 @@ function RawBody() {
583
583
  }
584
584
 
585
585
  const setHeaderInterceptor = (name, value, opts) => {
586
- const fn = (before, after) => {
586
+ const fn = (_before, after, onError) => {
587
587
  const h = useSetHeader(name);
588
588
  const status = useStatus();
589
- after(() => {
589
+ const cb = () => {
590
590
  if ((!h.value || (opts === null || opts === void 0 ? void 0 : opts.force)) &&
591
591
  (!(opts === null || opts === void 0 ? void 0 : opts.status) || opts.status === status.value)) {
592
592
  h.value = value;
593
593
  }
594
- });
594
+ };
595
+ if ((opts === null || opts === void 0 ? void 0 : opts.when) !== 'error') {
596
+ after(cb);
597
+ }
598
+ if ((opts === null || opts === void 0 ? void 0 : opts.when) === 'always' || (opts === null || opts === void 0 ? void 0 : opts.when) === 'error') {
599
+ onError(cb);
600
+ }
595
601
  };
596
602
  fn.priority = TInterceptorPriority.AFTER_ALL;
597
603
  return fn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moostjs/event-http",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "@moostjs/event-http",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -37,7 +37,7 @@
37
37
  "homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-http#readme",
38
38
  "peerDependencies": {},
39
39
  "dependencies": {
40
- "moost": "0.3.3",
40
+ "moost": "0.3.5",
41
41
  "@wooksjs/event-core": "^0.4.4",
42
42
  "@wooksjs/event-http": "^0.4.4",
43
43
  "@prostojs/infact": "^0.1.13",