Skip to content

Commit

Permalink
Also mock the content type from headers
Browse files Browse the repository at this point in the history
  • Loading branch information
joehoyle committed Mar 5, 2024
1 parent 78e568d commit 6dda3aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ declare type ResponseStream = {
setContentType( type: string ): void;
write( stream: string | Buffer ): void;
end(): void;
metadata?: any;
};

declare type StreamifyHandler = ( event: APIGatewayProxyEventV2, response: ResponseStream ) => Promise<any>;
Expand Down
1 change: 1 addition & 0 deletions src/lambda-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ if ( typeof awslambda === 'undefined' ) {
from( response: ResponseStream, metadata: {
headers?: Record<string, string>,
} ): ResponseStream {
response.metadata = metadata;
return response;
},
},
Expand Down
6 changes: 6 additions & 0 deletions tests/test-private-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ test( 'Test get private upload', async () => {
* End the response.
*/
end(): void {
if ( this.metadata.headers['Cache-Control'] ) {
contentType = this.metadata.headers['Content-Type'];
}
},
} );

Expand Down Expand Up @@ -115,6 +118,9 @@ test( 'Test get private upload with presign params', async () => {
* End the response.
*/
end(): void {
if ( this.metadata.headers['Cache-Control'] ) {
contentType = this.metadata.headers['Content-Type'];
}
},
} );

Expand Down

0 comments on commit 6dda3aa

Please sign in to comment.