@jaypie/express 1.2.4-rc2 → 1.2.4-rc3

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.
@@ -23,6 +23,11 @@ export declare class LambdaResponseBuffered extends Writable {
23
23
  getHeaders(): OutgoingHttpHeaders;
24
24
  hasHeader(name: string): boolean;
25
25
  getHeaderNames(): string[];
26
+ /**
27
+ * Proxy for direct header access (e.g., res.headers['content-type']).
28
+ * Required for compatibility with middleware like helmet that access headers directly.
29
+ */
30
+ get headers(): Record<string, string | string[] | undefined>;
26
31
  writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
27
32
  get headersSent(): boolean;
28
33
  status(code: number): this;
@@ -23,6 +23,11 @@ export declare class LambdaResponseStreaming extends Writable {
23
23
  getHeaders(): OutgoingHttpHeaders;
24
24
  hasHeader(name: string): boolean;
25
25
  getHeaderNames(): string[];
26
+ /**
27
+ * Proxy for direct header access (e.g., res.headers['content-type']).
28
+ * Required for compatibility with middleware like helmet that access headers directly.
29
+ */
30
+ get headers(): Record<string, string | string[] | undefined>;
26
31
  writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
27
32
  get headersSent(): boolean;
28
33
  flushHeaders(): void;
@@ -235,6 +235,43 @@ class LambdaResponseBuffered extends node_stream.Writable {
235
235
  getHeaderNames() {
236
236
  return Array.from(this._headers.keys());
237
237
  }
238
+ /**
239
+ * Proxy for direct header access (e.g., res.headers['content-type']).
240
+ * Required for compatibility with middleware like helmet that access headers directly.
241
+ */
242
+ get headers() {
243
+ return new Proxy({}, {
244
+ deleteProperty: (_target, prop) => {
245
+ this.removeHeader(String(prop));
246
+ return true;
247
+ },
248
+ get: (_target, prop) => {
249
+ if (typeof prop === "symbol")
250
+ return undefined;
251
+ return this.getHeader(String(prop));
252
+ },
253
+ getOwnPropertyDescriptor: (_target, prop) => {
254
+ if (this.hasHeader(String(prop))) {
255
+ return {
256
+ configurable: true,
257
+ enumerable: true,
258
+ value: this.getHeader(String(prop)),
259
+ };
260
+ }
261
+ return undefined;
262
+ },
263
+ has: (_target, prop) => {
264
+ return this.hasHeader(String(prop));
265
+ },
266
+ ownKeys: () => {
267
+ return this.getHeaderNames();
268
+ },
269
+ set: (_target, prop, value) => {
270
+ this.setHeader(String(prop), value);
271
+ return true;
272
+ },
273
+ });
274
+ }
238
275
  writeHead(statusCode, statusMessageOrHeaders, headers) {
239
276
  this.statusCode = statusCode;
240
277
  let headersToSet;
@@ -394,6 +431,43 @@ class LambdaResponseStreaming extends node_stream.Writable {
394
431
  getHeaderNames() {
395
432
  return Array.from(this._headers.keys());
396
433
  }
434
+ /**
435
+ * Proxy for direct header access (e.g., res.headers['content-type']).
436
+ * Required for compatibility with middleware like helmet that access headers directly.
437
+ */
438
+ get headers() {
439
+ return new Proxy({}, {
440
+ deleteProperty: (_target, prop) => {
441
+ this.removeHeader(String(prop));
442
+ return true;
443
+ },
444
+ get: (_target, prop) => {
445
+ if (typeof prop === "symbol")
446
+ return undefined;
447
+ return this.getHeader(String(prop));
448
+ },
449
+ getOwnPropertyDescriptor: (_target, prop) => {
450
+ if (this.hasHeader(String(prop))) {
451
+ return {
452
+ configurable: true,
453
+ enumerable: true,
454
+ value: this.getHeader(String(prop)),
455
+ };
456
+ }
457
+ return undefined;
458
+ },
459
+ has: (_target, prop) => {
460
+ return this.hasHeader(String(prop));
461
+ },
462
+ ownKeys: () => {
463
+ return this.getHeaderNames();
464
+ },
465
+ set: (_target, prop, value) => {
466
+ this.setHeader(String(prop), value);
467
+ return true;
468
+ },
469
+ });
470
+ }
397
471
  writeHead(statusCode, statusMessageOrHeaders, headers) {
398
472
  if (this._headersSent) {
399
473
  return this;