Skip to content

Commit

Permalink
fix(server): allow Request's properties to be redefined
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Nov 4, 2024
1 parent 14ee800 commit 323a519
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-chefs-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@whatwg-node/server': patch
---

Allow other libs to redefine `Request`'s properties
8 changes: 8 additions & 0 deletions packages/server/src/uwebsockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,31 @@ export function getRequestFromUWSRequest({ req, res, fetchAPI, signal }: GetRequ
get() {
return getBody();
},
configurable: true,
enumerable: true,
},
json: {
value() {
return collectBuffer()
.then(b => b.toString('utf8'))
.then(t => JSON.parse(t));
},
configurable: true,
enumerable: true,
},
text: {
value() {
return collectBuffer().then(b => b.toString('utf8'));
},
configurable: true,
enumerable: true,
},
arrayBuffer: {
value() {
return collectBuffer();
},
configurable: true,
enumerable: true,
},
});
return request;
Expand Down

0 comments on commit 323a519

Please sign in to comment.