@jaypie/express 1.2.33 → 1.2.34

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.
@@ -178,6 +178,13 @@ declare class LambdaResponseBuffered extends Writable {
178
178
  */
179
179
  get headers(): Record<string, string | string[] | undefined>;
180
180
  writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
181
+ /**
182
+ * Node's implicit-header hook, called before the first body byte commits.
183
+ * Routes through this.writeHead resolved at call time so wrappers installed
184
+ * mid-request (on-headers, and through it express-session, morgan,
185
+ * compression, express-openid-connect) run their listeners.
186
+ */
187
+ _implicitHeader(): void;
181
188
  get headersSent(): boolean;
182
189
  /**
183
190
  * Express-style alias for getHeader().
@@ -241,8 +248,16 @@ declare class LambdaResponseStreaming extends Writable {
241
248
  */
242
249
  get headers(): Record<string, string | string[] | undefined>;
243
250
  writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
251
+ /**
252
+ * Node's implicit-header hook, called before the first body byte commits.
253
+ * Routes through this.writeHead resolved at call time so wrappers installed
254
+ * mid-request (on-headers, and through it express-session, morgan,
255
+ * compression, express-openid-connect) run their listeners.
256
+ */
257
+ _implicitHeader(): void;
244
258
  get headersSent(): boolean;
245
259
  flushHeaders(): void;
260
+ private _commitHeaders;
246
261
  /**
247
262
  * Express-style alias for getHeader().
248
263
  * Used by middleware like decorateResponse that use res.get().
@@ -36,6 +36,13 @@ export declare class LambdaResponseBuffered extends Writable {
36
36
  */
37
37
  get headers(): Record<string, string | string[] | undefined>;
38
38
  writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
39
+ /**
40
+ * Node's implicit-header hook, called before the first body byte commits.
41
+ * Routes through this.writeHead resolved at call time so wrappers installed
42
+ * mid-request (on-headers, and through it express-session, morgan,
43
+ * compression, express-openid-connect) run their listeners.
44
+ */
45
+ _implicitHeader(): void;
39
46
  get headersSent(): boolean;
40
47
  /**
41
48
  * Express-style alias for getHeader().
@@ -36,8 +36,16 @@ export declare class LambdaResponseStreaming extends Writable {
36
36
  */
37
37
  get headers(): Record<string, string | string[] | undefined>;
38
38
  writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
39
+ /**
40
+ * Node's implicit-header hook, called before the first body byte commits.
41
+ * Routes through this.writeHead resolved at call time so wrappers installed
42
+ * mid-request (on-headers, and through it express-session, morgan,
43
+ * compression, express-openid-connect) run their listeners.
44
+ */
45
+ _implicitHeader(): void;
39
46
  get headersSent(): boolean;
40
47
  flushHeaders(): void;
48
+ private _commitHeaders;
41
49
  /**
42
50
  * Express-style alias for getHeader().
43
51
  * Used by middleware like decorateResponse that use res.get().
@@ -178,6 +178,13 @@ declare class LambdaResponseBuffered extends Writable {
178
178
  */
179
179
  get headers(): Record<string, string | string[] | undefined>;
180
180
  writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
181
+ /**
182
+ * Node's implicit-header hook, called before the first body byte commits.
183
+ * Routes through this.writeHead resolved at call time so wrappers installed
184
+ * mid-request (on-headers, and through it express-session, morgan,
185
+ * compression, express-openid-connect) run their listeners.
186
+ */
187
+ _implicitHeader(): void;
181
188
  get headersSent(): boolean;
182
189
  /**
183
190
  * Express-style alias for getHeader().
@@ -241,8 +248,16 @@ declare class LambdaResponseStreaming extends Writable {
241
248
  */
242
249
  get headers(): Record<string, string | string[] | undefined>;
243
250
  writeHead(statusCode: number, statusMessageOrHeaders?: OutgoingHttpHeaders | string, headers?: OutgoingHttpHeaders): this;
251
+ /**
252
+ * Node's implicit-header hook, called before the first body byte commits.
253
+ * Routes through this.writeHead resolved at call time so wrappers installed
254
+ * mid-request (on-headers, and through it express-session, morgan,
255
+ * compression, express-openid-connect) run their listeners.
256
+ */
257
+ _implicitHeader(): void;
244
258
  get headersSent(): boolean;
245
259
  flushHeaders(): void;
260
+ private _commitHeaders;
246
261
  /**
247
262
  * Express-style alias for getHeader().
248
263
  * Used by middleware like decorateResponse that use res.get().
package/dist/esm/index.js CHANGED
@@ -382,6 +382,7 @@ class LambdaResponseBuffered extends Writable {
382
382
  this.getHeaders = this.getHeaders.bind(this);
383
383
  this.getHeaderNames = this.getHeaderNames.bind(this);
384
384
  this.writeHead = this.writeHead.bind(this);
385
+ this._implicitHeader = this._implicitHeader.bind(this);
385
386
  this.get = this.get.bind(this);
386
387
  this.set = this.set.bind(this);
387
388
  this.status = this.status.bind(this);
@@ -538,6 +539,9 @@ class LambdaResponseBuffered extends Writable {
538
539
  });
539
540
  }
540
541
  writeHead(statusCode, statusMessageOrHeaders, headers) {
542
+ if (this._headersSent) {
543
+ return this;
544
+ }
541
545
  this.statusCode = statusCode;
542
546
  let headersToSet;
543
547
  if (typeof statusMessageOrHeaders === "string") {
@@ -559,6 +563,17 @@ class LambdaResponseBuffered extends Writable {
559
563
  this._headersSent = true;
560
564
  return this;
561
565
  }
566
+ /**
567
+ * Node's implicit-header hook, called before the first body byte commits.
568
+ * Routes through this.writeHead resolved at call time so wrappers installed
569
+ * mid-request (on-headers, and through it express-session, morgan,
570
+ * compression, express-openid-connect) run their listeners.
571
+ */
572
+ _implicitHeader() {
573
+ if (!this._headersSent) {
574
+ this.writeHead(this.statusCode);
575
+ }
576
+ }
562
577
  get headersSent() {
563
578
  return this._headersSent;
564
579
  }
@@ -630,11 +645,13 @@ class LambdaResponseBuffered extends Writable {
630
645
  const buffer = Buffer.isBuffer(chunk)
631
646
  ? chunk
632
647
  : Buffer.from(chunk, encoding);
648
+ this._implicitHeader();
633
649
  this._chunks.push(buffer);
634
650
  this._headersSent = true;
635
651
  callback();
636
652
  }
637
653
  _final(callback) {
654
+ this._implicitHeader();
638
655
  this._ended = true;
639
656
  if (this._resolve) {
640
657
  this._resolve(this.buildResult());
@@ -726,6 +743,8 @@ class LambdaResponseStreaming extends Writable {
726
743
  this.getHeaderNames = this.getHeaderNames.bind(this);
727
744
  this.writeHead = this.writeHead.bind(this);
728
745
  this.flushHeaders = this.flushHeaders.bind(this);
746
+ this._implicitHeader = this._implicitHeader.bind(this);
747
+ this._commitHeaders = this._commitHeaders.bind(this);
729
748
  this.get = this.get.bind(this);
730
749
  this.set = this.set.bind(this);
731
750
  this.status = this.status.bind(this);
@@ -890,13 +909,27 @@ class LambdaResponseStreaming extends Writable {
890
909
  }
891
910
  }
892
911
  }
893
- this.flushHeaders();
912
+ this._commitHeaders();
894
913
  return this;
895
914
  }
915
+ /**
916
+ * Node's implicit-header hook, called before the first body byte commits.
917
+ * Routes through this.writeHead resolved at call time so wrappers installed
918
+ * mid-request (on-headers, and through it express-session, morgan,
919
+ * compression, express-openid-connect) run their listeners.
920
+ */
921
+ _implicitHeader() {
922
+ if (!this._headersSent) {
923
+ this.writeHead(this.statusCode);
924
+ }
925
+ }
896
926
  get headersSent() {
897
927
  return this._headersSent;
898
928
  }
899
929
  flushHeaders() {
930
+ this._implicitHeader();
931
+ }
932
+ _commitHeaders() {
900
933
  if (this._headersSent) {
901
934
  return;
902
935
  }
@@ -1002,7 +1035,7 @@ class LambdaResponseStreaming extends Writable {
1002
1035
  // Buffer writes until headers are sent
1003
1036
  this._pendingWrites.push({ callback: () => callback(), chunk: buffer });
1004
1037
  // Auto-flush headers on first write
1005
- this.flushHeaders();
1038
+ this._implicitHeader();
1006
1039
  }
1007
1040
  else {
1008
1041
  this._wrappedStream.write(buffer);
@@ -1010,9 +1043,7 @@ class LambdaResponseStreaming extends Writable {
1010
1043
  }
1011
1044
  }
1012
1045
  _final(callback) {
1013
- if (!this._headersSent) {
1014
- this.flushHeaders();
1015
- }
1046
+ this._implicitHeader();
1016
1047
  // For converted 204 responses, write empty JSON body
1017
1048
  // Lambda streaming requires body content for metadata to be transmitted
1018
1049
  if (this._convertedFrom204 && this._wrappedStream) {