Skip to content

Commit

Permalink
refactor: stricter typing for headers and method
Browse files Browse the repository at this point in the history
  • Loading branch information
kanadgupta committed Aug 15, 2023
1 parent d4e9622 commit 1585f05
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/node/src/lib/process-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export default function processRequest(
}

const requestData = {
method: req.method,
method: req.method || '',
url: url.format({
// Handle cases where some reverse proxies put two protocols into x-forwarded-proto
// This line does the following: "https,http" -> "https"
Expand All @@ -206,20 +206,20 @@ export default function processRequest(
query: qs.parse(reqUrl.search.substring(1)),
}),
httpVersion: `${getProto(req).toUpperCase()}/${req.httpVersion}`,
headers: objectToArray(req.headers),
headers: objectToArray(req.headers, { castToString: true }),
queryString: searchToArray(reqUrl.searchParams),
postData,
// TODO: When readme starts accepting these, send the correct values
cookies: [] as Cookie[],
headersSize: -1,
bodySize: -1,
};
} as const;

if (typeof requestData.postData === 'undefined') {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { postData: postDataToBeOmitted, ...remainingRequestData } = requestData;
return remainingRequestData as Request;
return remainingRequestData;
}

return requestData as Request;
return requestData;
}

0 comments on commit 1585f05

Please sign in to comment.