File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
Filter options
Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## next
4
+
5
+ - fix(types): fix Logger type
6
+
3
7
## [ v3.0.5] ( https://github.com/chimurai/http-proxy-middleware/releases/tag/v3.0.5 )
4
8
5
9
- fix(fixRequestBody): check readableLength ([ #1096 ] ( https://github.com/chimurai/http-proxy-middleware/pull/1096 ) )
Original file line number Diff line number Diff line change @@ -136,5 +136,5 @@ export interface Options<TReq = http.IncomingMessage, TRes = http.ServerResponse
136
136
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/logger.md
137
137
* @since v3.0.0
138
138
*/
139
- logger ?: Logger | any ;
139
+ logger ?: Logger ;
140
140
}
Original file line number Diff line number Diff line change @@ -101,6 +101,33 @@ describe('http-proxy-middleware TypeScript Types', () => {
101
101
options = { logger : console } ;
102
102
expect ( options ) . toBeDefined ( ) ;
103
103
} ) ;
104
+
105
+ it ( 'should allow custom logger option' , ( ) => {
106
+ const customLogger = {
107
+ info : ( ) => { } ,
108
+ warn : ( ) => { } ,
109
+ error : ( ) => { } ,
110
+ } ;
111
+ options = { logger : customLogger } ;
112
+ expect ( options ) . toBeDefined ( ) ;
113
+ } ) ;
114
+
115
+ it ( 'should fail when custom logger has missing log function' , ( ) => {
116
+ const customLogger = {
117
+ info : ( ) => { } ,
118
+ // warn: () => {},
119
+ error : ( ) => { } ,
120
+ } ;
121
+ // @ts -expect-error explanation: should error when customLogger has a missing log function
122
+ options = { logger : customLogger } ;
123
+ expect ( options ) . toBeDefined ( ) ;
124
+ } ) ;
125
+
126
+ it ( 'should fail when invalid logger is provided' , ( ) => {
127
+ // @ts -expect-error explanation: should error when invalid logger is provided
128
+ options = { logger : 500 } ;
129
+ expect ( options ) . toBeDefined ( ) ;
130
+ } ) ;
104
131
} ) ;
105
132
106
133
describe ( 'on' , ( ) => {
You can’t perform that action at this time.
0 commit comments