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
-
3
1
import { IncomingMessage } from 'http' ;
4
2
import { Socket } from 'net' ;
5
3
@@ -14,20 +12,13 @@ interface ServerlessRequestOptions {
14
12
isBase64Encoded : boolean ;
15
13
}
16
14
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 ;
20
16
21
17
export default class ServerlessRequest extends IncomingMessage {
22
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
23
- // @ts -expect-error
24
18
ip : string ;
25
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
26
- // @ts -expect-error
19
+
27
20
body : Buffer | string ;
28
21
29
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
30
- // @ts -expect-error
31
22
isBase64Encoded : boolean ;
32
23
33
24
constructor ( {
@@ -55,18 +46,19 @@ export default class ServerlessRequest extends IncomingMessage {
55
46
) ;
56
47
57
48
Object . assign ( this , {
58
- ip : remoteAddress ,
59
49
complete : true ,
60
50
httpVersion : '1.1' ,
61
51
httpVersionMajor : '1' ,
62
52
httpVersionMinor : '1' ,
63
53
method,
64
- body,
65
54
url,
66
55
headers : combinedHeaders ,
67
- isBase64Encoded,
68
56
} ) ;
69
57
58
+ this . body = body ;
59
+ this . ip = remoteAddress ;
60
+ this . isBase64Encoded = isBase64Encoded ;
61
+
70
62
this . _read = ( ) => {
71
63
this . push ( body ) ;
72
64
this . push ( null ) ;
Original file line number Diff line number Diff line change 1
- // ATTRIBUTION: https://github.com/dougmoscrop/serverless-http
2
-
3
1
import { IncomingHttpHeaders , ServerResponse } from 'http' ;
4
2
import { IncomingMessage } from 'node:http' ;
5
3
import ServerlessRequest from './serverlessRequest' ;
6
4
import { Socket } from 'node:net' ;
5
+ import { debug } from './common' ;
7
6
8
7
const headerEnd = '\r\n\r\n' ;
9
8
@@ -25,8 +24,8 @@ const getString = (data: unknown): string => {
25
24
const addData = ( stream : ServerlessResponse , data : Buffer | string | Uint8Array ) : void => {
26
25
try {
27
26
stream [ BODY ] . push ( Buffer . from ( data ) ) ;
28
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
27
} catch ( err ) {
28
+ debug ( `Error adding data to response: ${ err } ` ) ;
30
29
throw new Error ( `response.write() of unexpected type: ${ typeof data } ` ) ;
31
30
}
32
31
} ;
You can’t perform that action at this time.
0 commit comments