1- import { Duplex , Readable , Writable } from 'node:stream' ;
1+ import { Duplex , Readable } from 'node:stream' ;
22import {
33 isRecord ,
44 isRegExp ,
@@ -18,9 +18,9 @@ import type {
1818 HandlerResponse ,
1919 HttpMethod ,
2020 HttpStatusCode ,
21- ResponseStream as IResponseStream ,
2221 Middleware ,
2322 Path ,
23+ ResponseStream ,
2424 ValidationResult ,
2525} from '../types/rest.js' ;
2626import {
@@ -306,35 +306,35 @@ export const resolvePrefixedPath = (path: Path, prefix?: Path): Path => {
306306 return `${ prefix } ${ path } ` . replace ( / \/ $ / , '' ) as Path ;
307307} ;
308308
309- export class ResponseStream extends Writable implements IResponseStream {
310- // biome-ignore lint/correctness/noUnusedPrivateClassMembers: This is how the Lambda RIC implements it
311- #contentType: string | undefined ;
312- readonly #chunks: Buffer [ ] = [ ] ;
313- public _onBeforeFirstWrite ?: (
314- write : ( data : Uint8Array | string ) => void
315- ) => void ;
316- #firstWrite = true ;
317-
318- setContentType ( contentType : string ) {
319- this . #contentType = contentType ;
320- }
321-
322- _write ( chunk : Buffer , _encoding : string , callback : ( ) => void ) : void {
323- /* v8 ignore else -- @preserve */
324- if ( this . #firstWrite && this . _onBeforeFirstWrite ) {
325- this . _onBeforeFirstWrite ( ( data : Uint8Array | string ) => {
326- this . #chunks. push ( Buffer . from ( data ) ) ;
327- } ) ;
328- this . #firstWrite = false ;
329- }
330- this . #chunks. push ( chunk ) ;
331- callback ( ) ;
332- }
333-
334- public getBuffer ( ) : Buffer {
335- return Buffer . concat ( this . #chunks) ;
336- }
337- }
309+ // export class ResponseStream extends Writable implements IResponseStream {
310+ // // biome-ignore lint/correctness/noUnusedPrivateClassMembers: This is how the Lambda RIC implements it
311+ // #contentType: string | undefined;
312+ // readonly #chunks: Buffer[] = [];
313+ // public _onBeforeFirstWrite?: (
314+ // write: (data: Uint8Array | string) => void
315+ // ) => void;
316+ // #firstWrite = true;
317+ //
318+ // setContentType(contentType: string) {
319+ // this.#contentType = contentType;
320+ // }
321+ //
322+ // _write(chunk: Buffer, _encoding: string, callback: () => void): void {
323+ // /* v8 ignore else -- @preserve */
324+ // if (this.#firstWrite && this._onBeforeFirstWrite) {
325+ // this._onBeforeFirstWrite((data: Uint8Array | string) => {
326+ // this.#chunks.push(Buffer.from(data));
327+ // });
328+ // this.#firstWrite = false;
329+ // }
330+ // this.#chunks.push(chunk);
331+ // callback();
332+ // }
333+ //
334+ // public getBuffer(): Buffer {
335+ // return Buffer.concat(this.#chunks);
336+ // }
337+ // }
338338
339339export const HttpResponseStream =
340340 globalThis . awslambda ?. HttpResponseStream ??
@@ -428,7 +428,7 @@ const streamifyResponse =
428428
429429 /* v8 ignore next -- @preserve */
430430 const output : Buffer =
431- ( responseStream as IResponseStream ) . getBuffer ?.( ) ?? Buffer . from ( [ ] ) ;
431+ ( responseStream as ResponseStream ) . getBuffer ?.( ) ?? Buffer . from ( [ ] ) ;
432432 const nullBytes = Buffer . from ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) ;
433433 const separatorIndex = output . indexOf ( nullBytes ) ;
434434
0 commit comments