Commit a5fa2c6
committed
refactor: remove setting req.body to undefined
Reasoning: the various parsers should not modify the request object until it is clear it should be applied. Setting a property, even to undefined, may affect assumptions elsewhere. For example, `'req' in body` would be truthy even if the rest of the middleware was not applied.
It can be removed entirely since all tests are still passing without it. However, I recognize that some third-party consumers may still need it to be set.
In either case, the current version is not compatible with, for example, tRPC v11 when using FormData. So without this change, the workaround is to add a condition to avoid applying the middleware at all. Example:
```js
const json = express.json();
app.use((req, res, next) => {
if (req.url.includes('trpc')) return next();
return json(req, res, next);
});
```1 parent 1fd3222 commit a5fa2c6
1 file changed
+0
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 47 | | |
52 | 48 | | |
53 | 49 | | |
| |||
0 commit comments