@jaypie/express 1.2.4-rc3 → 1.2.4-rc5

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,9 +30,26 @@ export declare class LambdaResponseBuffered extends Writable {
30
30
  get headers(): Record<string, string | string[] | undefined>;
31
31
  writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
32
32
  get headersSent(): boolean;
33
+ /**
34
+ * Express-style alias for getHeader().
35
+ * Used by middleware like decorateResponse that use res.get().
36
+ * Note: Directly accesses _headers to avoid prototype chain issues with bundled code.
37
+ */
38
+ get(name: string): number | string | string[] | undefined;
39
+ /**
40
+ * Express-style alias for setHeader().
41
+ * Used by middleware like decorateResponse that use res.set().
42
+ * Note: Directly accesses _headers to avoid prototype chain issues with bundled code.
43
+ */
44
+ set(name: string, value: number | string | string[]): this;
33
45
  status(code: number): this;
34
46
  json(data: unknown): this;
35
47
  send(body?: Buffer | object | string): this;
48
+ /**
49
+ * Add a field to the Vary response header.
50
+ * Used by CORS middleware to indicate response varies by Origin.
51
+ */
52
+ vary(field: string): this;
36
53
  _write(chunk: Buffer | string, encoding: BufferEncoding, // eslint-disable-line no-undef
37
54
  callback: (error?: Error | null) => void): void;
38
55
  _final(callback: (error?: Error | null) => void): void;
@@ -31,9 +31,26 @@ export declare class LambdaResponseStreaming extends Writable {
31
31
  writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
32
32
  get headersSent(): boolean;
33
33
  flushHeaders(): void;
34
+ /**
35
+ * Express-style alias for getHeader().
36
+ * Used by middleware like decorateResponse that use res.get().
37
+ * Note: Directly accesses _headers to avoid prototype chain issues with bundled code.
38
+ */
39
+ get(name: string): number | string | string[] | undefined;
40
+ /**
41
+ * Express-style alias for setHeader().
42
+ * Used by middleware like decorateResponse that use res.set().
43
+ * Note: Directly accesses _headers to avoid prototype chain issues with bundled code.
44
+ */
45
+ set(name: string, value: number | string | string[]): this;
34
46
  status(code: number): this;
35
47
  json(data: unknown): this;
36
48
  send(body?: Buffer | object | string): this;
49
+ /**
50
+ * Add a field to the Vary response header.
51
+ * Used by CORS middleware to indicate response varies by Origin.
52
+ */
53
+ vary(field: string): this;
37
54
  _write(chunk: Buffer | string, encoding: BufferEncoding, // eslint-disable-line no-undef
38
55
  callback: (error?: Error | null) => void): void;
39
56
  _final(callback: (error?: Error | null) => void): void;
@@ -299,6 +299,25 @@ class LambdaResponseBuffered extends node_stream.Writable {
299
299
  //
300
300
  // Express compatibility methods
301
301
  //
302
+ /**
303
+ * Express-style alias for getHeader().
304
+ * Used by middleware like decorateResponse that use res.get().
305
+ * Note: Directly accesses _headers to avoid prototype chain issues with bundled code.
306
+ */
307
+ get(name) {
308
+ return this._headers.get(name.toLowerCase());
309
+ }
310
+ /**
311
+ * Express-style alias for setHeader().
312
+ * Used by middleware like decorateResponse that use res.set().
313
+ * Note: Directly accesses _headers to avoid prototype chain issues with bundled code.
314
+ */
315
+ set(name, value) {
316
+ if (!this._headersSent) {
317
+ this._headers.set(name.toLowerCase(), String(value));
318
+ }
319
+ return this;
320
+ }
302
321
  status(code) {
303
322
  this.statusCode = code;
304
323
  return this;
@@ -315,6 +334,26 @@ class LambdaResponseBuffered extends node_stream.Writable {
315
334
  this.end(body);
316
335
  return this;
317
336
  }
337
+ /**
338
+ * Add a field to the Vary response header.
339
+ * Used by CORS middleware to indicate response varies by Origin.
340
+ */
341
+ vary(field) {
342
+ const existing = this.getHeader("vary");
343
+ if (!existing) {
344
+ this.setHeader("vary", field);
345
+ }
346
+ else {
347
+ // Append to existing Vary header if field not already present
348
+ const fields = String(existing)
349
+ .split(",")
350
+ .map((f) => f.trim().toLowerCase());
351
+ if (!fields.includes(field.toLowerCase())) {
352
+ this.setHeader("vary", `${existing}, ${field}`);
353
+ }
354
+ }
355
+ return this;
356
+ }
318
357
  //
319
358
  // Writable stream implementation
320
359
  //
@@ -519,6 +558,25 @@ class LambdaResponseStreaming extends node_stream.Writable {
519
558
  //
520
559
  // Express compatibility methods
521
560
  //
561
+ /**
562
+ * Express-style alias for getHeader().
563
+ * Used by middleware like decorateResponse that use res.get().
564
+ * Note: Directly accesses _headers to avoid prototype chain issues with bundled code.
565
+ */
566
+ get(name) {
567
+ return this._headers.get(name.toLowerCase());
568
+ }
569
+ /**
570
+ * Express-style alias for setHeader().
571
+ * Used by middleware like decorateResponse that use res.set().
572
+ * Note: Directly accesses _headers to avoid prototype chain issues with bundled code.
573
+ */
574
+ set(name, value) {
575
+ if (!this._headersSent) {
576
+ this._headers.set(name.toLowerCase(), String(value));
577
+ }
578
+ return this;
579
+ }
522
580
  status(code) {
523
581
  this.statusCode = code;
524
582
  return this;
@@ -535,6 +593,26 @@ class LambdaResponseStreaming extends node_stream.Writable {
535
593
  this.end(body);
536
594
  return this;
537
595
  }
596
+ /**
597
+ * Add a field to the Vary response header.
598
+ * Used by CORS middleware to indicate response varies by Origin.
599
+ */
600
+ vary(field) {
601
+ const existing = this.getHeader("vary");
602
+ if (!existing) {
603
+ this.setHeader("vary", field);
604
+ }
605
+ else {
606
+ // Append to existing Vary header if field not already present
607
+ const fields = String(existing)
608
+ .split(",")
609
+ .map((f) => f.trim().toLowerCase());
610
+ if (!fields.includes(field.toLowerCase())) {
611
+ this.setHeader("vary", `${existing}, ${field}`);
612
+ }
613
+ }
614
+ return this;
615
+ }
538
616
  //
539
617
  // Writable stream implementation
540
618
  //