File tree Expand file tree Collapse file tree 2 files changed +8
-17
lines changed Expand file tree Collapse file tree 2 files changed +8
-17
lines changed Original file line number Diff line number Diff line change 1- // ATTRIBUTION: https://github.com/dougmoscrop/serverless-http
2-
31import { IncomingMessage } from 'http' ;
42import { Socket } from 'net' ;
53
@@ -14,20 +12,13 @@ interface ServerlessRequestOptions {
1412 isBase64Encoded : boolean ;
1513}
1614
17- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
18- // eslint-disable-next-line @typescript-eslint/no-explicit-any
19- const NO_OP : ( ...args : any [ ] ) => any = ( ) => void 0 ;
15+ const NO_OP : ( ...args : unknown [ ] ) => unknown = ( ) => void 0 ;
2016
2117export default class ServerlessRequest extends IncomingMessage {
22- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
23- // @ts -expect-error
2418 ip : string ;
25- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
26- // @ts -expect-error
19+
2720 body : Buffer | string ;
2821
29- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
30- // @ts -expect-error
3122 isBase64Encoded : boolean ;
3223
3324 constructor ( {
@@ -55,18 +46,19 @@ export default class ServerlessRequest extends IncomingMessage {
5546 ) ;
5647
5748 Object . assign ( this , {
58- ip : remoteAddress ,
5949 complete : true ,
6050 httpVersion : '1.1' ,
6151 httpVersionMajor : '1' ,
6252 httpVersionMinor : '1' ,
6353 method,
64- body,
6554 url,
6655 headers : combinedHeaders ,
67- isBase64Encoded,
6856 } ) ;
6957
58+ this . body = body ;
59+ this . ip = remoteAddress ;
60+ this . isBase64Encoded = isBase64Encoded ;
61+
7062 this . _read = ( ) => {
7163 this . push ( body ) ;
7264 this . push ( null ) ;
Original file line number Diff line number Diff line change 1- // ATTRIBUTION: https://github.com/dougmoscrop/serverless-http
2-
31import { IncomingHttpHeaders , ServerResponse } from 'http' ;
42import { IncomingMessage } from 'node:http' ;
53import ServerlessRequest from './serverlessRequest' ;
64import { Socket } from 'node:net' ;
5+ import { debug } from './common' ;
76
87const headerEnd = '\r\n\r\n' ;
98
@@ -25,8 +24,8 @@ const getString = (data: unknown): string => {
2524const addData = ( stream : ServerlessResponse , data : Buffer | string | Uint8Array ) : void => {
2625 try {
2726 stream [ BODY ] . push ( Buffer . from ( data ) ) ;
28- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2927 } catch ( err ) {
28+ debug ( `Error adding data to response: ${ err } ` ) ;
3029 throw new Error ( `response.write() of unexpected type: ${ typeof data } ` ) ;
3130 }
3231} ;
You can’t perform that action at this time.
0 commit comments