@jaypie/express 1.2.4-rc12 → 1.2.4-rc13

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.
@@ -30,6 +30,7 @@ export declare class LambdaResponseBuffered extends Writable {
30
30
  /**
31
31
  * Proxy for direct header access (e.g., res.headers['content-type']).
32
32
  * Required for compatibility with middleware like helmet that access headers directly.
33
+ * Uses direct _headers access to bypass dd-trace interception.
33
34
  */
34
35
  get headers(): Record<string, string | string[] | undefined>;
35
36
  writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
@@ -30,6 +30,7 @@ export declare class LambdaResponseStreaming extends Writable {
30
30
  /**
31
31
  * Proxy for direct header access (e.g., res.headers['content-type']).
32
32
  * Required for compatibility with middleware like helmet that access headers directly.
33
+ * Uses direct _headers access to bypass dd-trace interception.
33
34
  */
34
35
  get headers(): Record<string, string | string[] | undefined>;
35
36
  writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
package/dist/esm/index.js CHANGED
@@ -301,36 +301,40 @@ class LambdaResponseBuffered extends Writable {
301
301
  /**
302
302
  * Proxy for direct header access (e.g., res.headers['content-type']).
303
303
  * Required for compatibility with middleware like helmet that access headers directly.
304
+ * Uses direct _headers access to bypass dd-trace interception.
304
305
  */
305
306
  get headers() {
306
307
  return new Proxy({}, {
307
308
  deleteProperty: (_target, prop) => {
308
- this.removeHeader(String(prop));
309
+ this._headers.delete(String(prop).toLowerCase());
309
310
  return true;
310
311
  },
311
312
  get: (_target, prop) => {
312
313
  if (typeof prop === "symbol")
313
314
  return undefined;
314
- return this.getHeader(String(prop));
315
+ return this._headers.get(String(prop).toLowerCase());
315
316
  },
316
317
  getOwnPropertyDescriptor: (_target, prop) => {
317
- if (this.hasHeader(String(prop))) {
318
+ const lowerProp = String(prop).toLowerCase();
319
+ if (this._headers.has(lowerProp)) {
318
320
  return {
319
321
  configurable: true,
320
322
  enumerable: true,
321
- value: this.getHeader(String(prop)),
323
+ value: this._headers.get(lowerProp),
322
324
  };
323
325
  }
324
326
  return undefined;
325
327
  },
326
328
  has: (_target, prop) => {
327
- return this.hasHeader(String(prop));
329
+ return this._headers.has(String(prop).toLowerCase());
328
330
  },
329
331
  ownKeys: () => {
330
- return this.getHeaderNames();
332
+ return Array.from(this._headers.keys());
331
333
  },
332
334
  set: (_target, prop, value) => {
333
- this.setHeader(String(prop), value);
335
+ if (!this._headersSent) {
336
+ this._headers.set(String(prop).toLowerCase(), value);
337
+ }
334
338
  return true;
335
339
  },
336
340
  });
@@ -347,9 +351,10 @@ class LambdaResponseBuffered extends Writable {
347
351
  headersToSet = statusMessageOrHeaders;
348
352
  }
349
353
  if (headersToSet) {
354
+ // Use direct _headers access to bypass dd-trace interception
350
355
  for (const [key, value] of Object.entries(headersToSet)) {
351
356
  if (value !== undefined) {
352
- this.setHeader(key, value);
357
+ this._headers.set(key.toLowerCase(), String(value));
353
358
  }
354
359
  }
355
360
  }
@@ -386,7 +391,8 @@ class LambdaResponseBuffered extends Writable {
386
391
  return this;
387
392
  }
388
393
  json(data) {
389
- this.setHeader("content-type", "application/json");
394
+ // Use direct _headers access to bypass dd-trace interception
395
+ this._headers.set("content-type", "application/json");
390
396
  this.end(JSON.stringify(data));
391
397
  return this;
392
398
  }
@@ -606,36 +612,42 @@ class LambdaResponseStreaming extends Writable {
606
612
  /**
607
613
  * Proxy for direct header access (e.g., res.headers['content-type']).
608
614
  * Required for compatibility with middleware like helmet that access headers directly.
615
+ * Uses direct _headers access to bypass dd-trace interception.
609
616
  */
610
617
  get headers() {
611
618
  return new Proxy({}, {
612
619
  deleteProperty: (_target, prop) => {
613
- this.removeHeader(String(prop));
620
+ if (!this._headersSent) {
621
+ this._headers.delete(String(prop).toLowerCase());
622
+ }
614
623
  return true;
615
624
  },
616
625
  get: (_target, prop) => {
617
626
  if (typeof prop === "symbol")
618
627
  return undefined;
619
- return this.getHeader(String(prop));
628
+ return this._headers.get(String(prop).toLowerCase());
620
629
  },
621
630
  getOwnPropertyDescriptor: (_target, prop) => {
622
- if (this.hasHeader(String(prop))) {
631
+ const lowerProp = String(prop).toLowerCase();
632
+ if (this._headers.has(lowerProp)) {
623
633
  return {
624
634
  configurable: true,
625
635
  enumerable: true,
626
- value: this.getHeader(String(prop)),
636
+ value: this._headers.get(lowerProp),
627
637
  };
628
638
  }
629
639
  return undefined;
630
640
  },
631
641
  has: (_target, prop) => {
632
- return this.hasHeader(String(prop));
642
+ return this._headers.has(String(prop).toLowerCase());
633
643
  },
634
644
  ownKeys: () => {
635
- return this.getHeaderNames();
645
+ return Array.from(this._headers.keys());
636
646
  },
637
647
  set: (_target, prop, value) => {
638
- this.setHeader(String(prop), value);
648
+ if (!this._headersSent) {
649
+ this._headers.set(String(prop).toLowerCase(), value);
650
+ }
639
651
  return true;
640
652
  },
641
653
  });
@@ -655,9 +667,10 @@ class LambdaResponseStreaming extends Writable {
655
667
  headersToSet = statusMessageOrHeaders;
656
668
  }
657
669
  if (headersToSet) {
670
+ // Use direct _headers access to bypass dd-trace interception
658
671
  for (const [key, value] of Object.entries(headersToSet)) {
659
672
  if (value !== undefined) {
660
- this.setHeader(key, value);
673
+ this._headers.set(key.toLowerCase(), String(value));
661
674
  }
662
675
  }
663
676
  }
@@ -715,7 +728,8 @@ class LambdaResponseStreaming extends Writable {
715
728
  return this;
716
729
  }
717
730
  json(data) {
718
- this.setHeader("content-type", "application/json");
731
+ // Use direct _headers access to bypass dd-trace interception
732
+ this._headers.set("content-type", "application/json");
719
733
  this.end(JSON.stringify(data));
720
734
  return this;
721
735
  }