@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.
package/dist/esm/index.js CHANGED
@@ -233,6 +233,43 @@ class LambdaResponseBuffered extends Writable {
233
233
  getHeaderNames() {
234
234
  return Array.from(this._headers.keys());
235
235
  }
236
+ /**
237
+ * Proxy for direct header access (e.g., res.headers['content-type']).
238
+ * Required for compatibility with middleware like helmet that access headers directly.
239
+ */
240
+ get headers() {
241
+ return new Proxy({}, {
242
+ deleteProperty: (_target, prop) => {
243
+ this.removeHeader(String(prop));
244
+ return true;
245
+ },
246
+ get: (_target, prop) => {
247
+ if (typeof prop === "symbol")
248
+ return undefined;
249
+ return this.getHeader(String(prop));
250
+ },
251
+ getOwnPropertyDescriptor: (_target, prop) => {
252
+ if (this.hasHeader(String(prop))) {
253
+ return {
254
+ configurable: true,
255
+ enumerable: true,
256
+ value: this.getHeader(String(prop)),
257
+ };
258
+ }
259
+ return undefined;
260
+ },
261
+ has: (_target, prop) => {
262
+ return this.hasHeader(String(prop));
263
+ },
264
+ ownKeys: () => {
265
+ return this.getHeaderNames();
266
+ },
267
+ set: (_target, prop, value) => {
268
+ this.setHeader(String(prop), value);
269
+ return true;
270
+ },
271
+ });
272
+ }
236
273
  writeHead(statusCode, statusMessageOrHeaders, headers) {
237
274
  this.statusCode = statusCode;
238
275
  let headersToSet;
@@ -392,6 +429,43 @@ class LambdaResponseStreaming extends Writable {
392
429
  getHeaderNames() {
393
430
  return Array.from(this._headers.keys());
394
431
  }
432
+ /**
433
+ * Proxy for direct header access (e.g., res.headers['content-type']).
434
+ * Required for compatibility with middleware like helmet that access headers directly.
435
+ */
436
+ get headers() {
437
+ return new Proxy({}, {
438
+ deleteProperty: (_target, prop) => {
439
+ this.removeHeader(String(prop));
440
+ return true;
441
+ },
442
+ get: (_target, prop) => {
443
+ if (typeof prop === "symbol")
444
+ return undefined;
445
+ return this.getHeader(String(prop));
446
+ },
447
+ getOwnPropertyDescriptor: (_target, prop) => {
448
+ if (this.hasHeader(String(prop))) {
449
+ return {
450
+ configurable: true,
451
+ enumerable: true,
452
+ value: this.getHeader(String(prop)),
453
+ };
454
+ }
455
+ return undefined;
456
+ },
457
+ has: (_target, prop) => {
458
+ return this.hasHeader(String(prop));
459
+ },
460
+ ownKeys: () => {
461
+ return this.getHeaderNames();
462
+ },
463
+ set: (_target, prop, value) => {
464
+ this.setHeader(String(prop), value);
465
+ return true;
466
+ },
467
+ });
468
+ }
395
469
  writeHead(statusCode, statusMessageOrHeaders, headers) {
396
470
  if (this._headersSent) {
397
471
  return this;