Skip to content

Commit 89f1401

Browse files
committed
fix(rest): Fix compilation error caused by @types/node
@types/node@8.0.56 introduces a breaking change for URL and our build fails due to imcompatible types
1 parent 0316f28 commit 89f1401

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@commitlint/config-angular": "^4.3.0",
1616
"@commitlint/config-lerna-scopes": "^4.3.0",
1717
"@types/mocha": "^2.2.44",
18-
"@types/node": "^8.0.50",
18+
"@types/node": "^8.0.56",
1919
"@types/request": "^2.0.7",
2020
"@types/request-promise": "^4.1.39",
2121
"coveralls": "^3.0.0",

packages/rest/src/internal-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface ParsedRequest extends ServerRequest {
1111
// see http://expressjs.com/en/4x/api.html#req.path
1212
path: string;
1313
// see http://expressjs.com/en/4x/api.html#req.query
14-
query: {[key: string]: string};
14+
query: {[key: string]: string | string[]};
1515
// see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/15808
1616
url: string;
1717
pathname: string;

packages/rest/src/router/routing-table.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ export function parseRequestUrl(request: ServerRequest): ParsedRequest {
4545
const parsedRequest = request as ParsedRequest;
4646
const parsedUrl = url.parse(parsedRequest.url, true);
4747
parsedRequest.path = parsedUrl.pathname || '/';
48-
parsedRequest.query = parsedUrl.query;
48+
// parsedUrl.query cannot be a string as it is parsed with
49+
// parseQueryString = true
50+
if (parsedUrl.query != null && typeof parsedUrl.query !== 'string') {
51+
parsedRequest.query = parsedUrl.query;
52+
} else {
53+
parsedRequest.query = {};
54+
}
4955
return parsedRequest;
5056
}
5157

0 commit comments

Comments
 (0)