Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cf72bcd

Browse filesBrowse files
authored
fix(types): fix Logger type (#1104)
1 parent d3851ed commit cf72bcd
Copy full SHA for cf72bcd

File tree

Expand file treeCollapse file tree

3 files changed

+32
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+32
-1
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## next
4+
5+
- fix(types): fix Logger type
6+
37
## [v3.0.5](https://github.com/chimurai/http-proxy-middleware/releases/tag/v3.0.5)
48

59
- fix(fixRequestBody): check readableLength ([#1096](https://github.com/chimurai/http-proxy-middleware/pull/1096))

‎src/types.ts

Copy file name to clipboardExpand all lines: src/types.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,5 @@ export interface Options<TReq = http.IncomingMessage, TRes = http.ServerResponse
136136
* @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/logger.md
137137
* @since v3.0.0
138138
*/
139-
logger?: Logger | any;
139+
logger?: Logger;
140140
}

‎test/types.spec.ts

Copy file name to clipboardExpand all lines: test/types.spec.ts
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,33 @@ describe('http-proxy-middleware TypeScript Types', () => {
101101
options = { logger: console };
102102
expect(options).toBeDefined();
103103
});
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+
});
104131
});
105132

106133
describe('on', () => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.